org.jvnet.hk2.config.Dom类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.jvnet.hk2.config.Dom类的一些代码示例,展示了Dom类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dom类的具体详情如下:
包路径:org.jvnet.hk2.config.Dom
类名称:Dom

Dom介绍

[英]Inhabitant that loads configuration from XML.

This object also captures all the configuration values in a typeless way, so that the loading of the actual classes can be deferred as much as possible.

This is the ActiveDescriptor that gets registered into ServiceLocator, so one can access this object by ServiceLocator#getServiceHandle(Class,String) family of methods.
[中]从XML加载配置的居住者。
此对象还以无类型的方式捕获所有配置值,以便尽可能延迟实际类的加载。
这是注册到ServiceLocator的ActiveDescriptor,因此可以通过ServiceLocator#getServiceHandle(类,字符串)方法族访问此对象。

代码示例

代码示例来源:origin: javaee/glassfish

public static <T extends ConfigBeanProxy> T getParent(ConfigBeanProxy self, Class<T> c) {
   Dom dom = Dom.unwrap(self);
  if (dom.parent()!=null) {
    return dom.parent().createProxy(c);
  } else {
    return null;
  }
}

代码示例来源:origin: javaee/glassfish

/**
 * Creates a strongly-typed proxy to access values in this {@link Dom} object,
 */
public <T extends ConfigBeanProxy> T createProxy() {
  return createProxy(this.<T>getProxyType());
}

代码示例来源:origin: javaee/glassfish

public void element_setIndexItems(Dom dom, org.glassfish.admingui.connector.IndexItem target) {
  List<Dom> v1 = dom.nodeElements("indexitem");
  if (v1 == null) {
    return ;
  }
  List v2 = new ArrayList<org.glassfish.admingui.connector.IndexItem>(v1 .size());
  for (Dom v3 : v1) {
    v2 .add(((org.glassfish.admingui.connector.IndexItem) v3 .get()));
  }
  target.setIndexItems(v2);
}

代码示例来源:origin: javaee/glassfish

@Override
  String elementValue(Object element) {
    return Dom.unwrap((ConfigBeanProxy) element).getKey();
  }
}

代码示例来源:origin: javaee/glassfish

@Override
  public void set(Dom dom, Object arg) {
    Dom target = (Dom) arg;
    dom.attribute(xmlName, arg==null?null:target.getKey());
  }
}

代码示例来源:origin: javaee/glassfish

public void testHabitatFromDom() {
  SimpleConnector sc = habitat.getService(SimpleConnector.class);
  EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
  Dom ejbDom = Dom.unwrap(ejb);
  assert(ejbDom.getHabitat() != null);
}

代码示例来源:origin: javaee/glassfish

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.leafElement(xmlName);
  Class<?> type = Types.erasure(returnType);
  // let's look first the fast way.
  Object candidate = dom.getHabitat().getService(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

代码示例来源:origin: javaee/glassfish

/* package */ @SuppressWarnings({ "unchecked" })
void register() {
  ServiceLocator locator = getServiceLocator();
  ActiveDescriptor<?> myselfReified = locator.reifyDescriptor(this);
  DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
  DynamicConfiguration dc = dcs.createDynamicConfiguration();
      getImplementation(), new HashSet<Annotation>());
  domDesc.setLoader(loader);
  domDescriptor = dc.addActiveDescriptor(domDesc, false);
  String key = getKey();
  for (String contract : model.contracts) {
    ActiveDescriptor<Dom> alias = new AliasDescriptor<Dom>(locator, domDescriptor, contract, key);
  serviceHandle = getHabitat().getServiceHandle(domDescriptor);

代码示例来源:origin: javaee/glassfish

public void testDom() {
  SimpleConnector sc = habitat.getService(SimpleConnector.class);
  EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
  assert(Dom.class.isAssignableFrom(Dom.unwrap(ejb).getClass())
      && ConfigBeanProxy.class.isAssignableFrom(ejb.getClass()));
}

代码示例来源:origin: javaee/glassfish

return invokeDuckMethod(method,proxy,args);
    ? getServiceLocator().getService(ConfigExtensionHandler.class, cem.value())
    : getServiceLocator().getService(ConfigExtensionHandler.class));
  return invokeConfigExtensionMethod(handler, this, model.getProxyType(), args);
  return getter(p, method.getGenericReturnType());
} else {
  throw new PropertyVetoException("Instance of " + getImplementation() + " named '" + getKey() +
      "' is not locked for writing when invoking method " + method.getName()
      + " you must use transaction semantics to access it.", null);

代码示例来源:origin: javaee/glassfish

Dom dom = Dom.unwrap(child);
    writeableParent.setter(element, dom.<ConfigBeanProxy>createProxy(), childType);
applyProperties(writeableChild, attributes);
dom.addDefaultChildren();
dom.register();

代码示例来源:origin: com.sun.grizzly/grizzly-config

public static ThreadPool findThreadPool(NetworkListener listener) {
  final NetworkListeners listeners = listener.getParent();
  List<ThreadPool> list = listeners.getThreadPool();
  if (list == null || list.isEmpty()) {
    final ConfigBeanProxy parent = listener.getParent().getParent().getParent();
    final Dom proxy = Dom.unwrap(parent).element("thread-pools");
    final List<Dom> domList = proxy.nodeElements("thread-pool");
    list = new ArrayList<ThreadPool>(domList.size());
    for (Dom dom : domList) {
      list.add(dom.<ThreadPool>createProxy());
    }
  }
  for (ThreadPool pool : list) {
    if (listener.getThreadPool().equals(pool.getName())) {
      return pool;
    }
  }
  return null;
}

代码示例来源:origin: org.glassfish.main.admin/config-api

public void transactionCommited(List<PropertyChangeEvent> changes) {
  if (!isGlassFishDocumentChanged(changes)) {
    return;
  }
  
  for (ConfigurationPersistence pers : habitat.<ConfigurationPersistence>getAllServices(ConfigurationPersistence.class)) {
    try {
      if (doc.getRoot().getProxyType().equals(Domain.class)) {
        Dom domainRoot = doc.getRoot();
        domainRoot.attribute("version", Version.getBuildVersion());
      }
      pers.save(doc);
    } catch (IOException e) {
      logger.log(Level.SEVERE, 
        ConfigApiLoggerInfo.glassFishDocumentIOException,e);
    } catch (XMLStreamException e) {
      logger.log(Level.SEVERE, 
        ConfigApiLoggerInfo.glassFishDocumentXmlException,e);
    }
  }
}

代码示例来源:origin: org.glassfish.main.admin/config-api

public Object run(ConfigBeanProxy param) {
    PropertyBag bag = (PropertyBag) param;
    final List<Property> propertyList = new ArrayList<Property>(bag.getProperty());
    setProperty(target, attribute, getValue(propertyList, property));
    final String message = MessageFormat.format("Moved {0}.property.{1} to {0}.{2}",
      Dom.convertName(Dom.unwrap(target).getProxyType().getSimpleName()),
      property,
      Dom.convertName(attribute));
    report(context, message);
    bag.getProperty().clear();
    bag.getProperty().addAll(propertyList);
    return param;
  }
}, target);

代码示例来源:origin: javaee/glassfish

Dom thisview = Dom.unwrap(defaultView);
Dom parent = thisview.parent();
    ? parent.domNodeByTypeElements(thisview.getProxyType())
    : new ArrayList<Dom>();
  String siblingKey = sibling.getKey();
  if (newValue.equals(siblingKey)) {
    bean.getLock().unlock();

代码示例来源:origin: javaee/glassfish

Dom cbo = Dom.unwrap((ConfigBeanProxy) o);
String cboKey = cbo.model.key;
if(cboKey != null && key.equals(cboKey.substring(1))){
  value = cbo.attribute(key);
Dom parent = Dom.unwrap(readView);
throw new IllegalArgumentException("A " + master.getProxyType().getSimpleName() +
    " with the same key \"" + keyValue + "\" already exists in " +
    parent.getProxyType().getSimpleName() + " " + parent.getKey()) ;

代码示例来源:origin: javaee/glassfish

/**
 * Replaces an existing {@link NodeChild} with another one.
 *
 * @see #insertAfter(Dom, String, Dom)
 */
public synchronized void replaceChild(Dom reference, String name, Dom newNode) {
  ListIterator<Child> itr = children.listIterator();
  while(itr.hasNext()) {
    Child child = itr.next();   
    if (child instanceof NodeChild) {
      NodeChild nc = (NodeChild) child;
      if(nc.dom==reference) {
        reference.release();
        newNode.domDescriptor = addWithAlias(getHabitat(), newNode,newNode.getProxyType(), newNode.getKey());
        
        itr.set(new NodeChild(name,newNode));
        return;
      }
    }
  }
  throw new IllegalArgumentException(reference+" is not a valid child of "+this+". Children="+children);
}

代码示例来源:origin: org.glassfish.main.admin/config-api

@Override
  public Object run(ConfigBeanProxy parent) throws PropertyVetoException, TransactionFailure {
    U child = parent.createChild(childElement);
    Dom unwrappedChild = Dom.unwrap(child);
    unwrappedChild.addDefaultChildren();
    configModularityUtils.getExtensions(parent).add(child);
    return child;
  }
}, extensionOwner);

代码示例来源:origin: javaee/glassfish

public static Class<? extends ConfigBeanProxy> getElementTypeByName(ConfigBeanProxy parent, String elementName)
  throws ClassNotFoundException {
  final Dom parentDom = Dom.unwrap(parent);
  DomDocument document = parentDom.document;
  ConfigModel.Property a = parentDom.model.elements.get(elementName);
  if (a!=null) {
    if (a.isLeaf()) {
      // dochez : I am not too sure, but that should be a String @Element
      return null;
    } else {
      ConfigModel childModel = ((ConfigModel.Node) a).model;
      return (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName);
    }
  }
  // global lookup
  ConfigModel model = document.getModelByElementName(elementName);
  if (model!=null) {
    return (Class<? extends ConfigBeanProxy>) model.classLoaderHolder.loadClass(model.targetTypeName);
  }
  return null;
}

代码示例来源:origin: javaee/glassfish

for (PropertyChangeEvent event : job.mEvents) {
  final Dom dom = (Dom) ((ConfigView) Proxy.getInvocationHandler(event.getSource())).getMasterView();
  configListeners.addAll(dom.getListeners());
  if (dom.parent()!=null) {
    configListeners.addAll(dom.parent().getListeners());
  Set<ConfigListener> listeners = typeListeners.get(dom.getProxyType());
  if (listeners!=null) {
    configListeners.addAll(listeners);
    Object oldValue = event.getOldValue();
    if (oldValue instanceof ConfigBeanProxy) {
      Dom domOldValue = Dom.unwrap((ConfigBeanProxy) oldValue);
      Set<ConfigListener> typedListeners = typeListeners.get(domOldValue.<ConfigBeanProxy>getProxyType());
      if (typedListeners!=null) {
        configListeners.addAll(typedListeners);

相关文章