org.jvnet.hk2.config.Dom.unwrap()方法的使用及代码示例

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

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

Dom.unwrap介绍

[英]Unwraps the proxy and returns the underlying Dom object.
[中]展开代理并返回基础Dom对象。

代码示例

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

/**
   * Coerce the given type to {@link Dom}.
   * Only handles those types that are valid to the {@link #set(Dom, Object)} method.
   */
  protected final Dom toDom(Object arg) {
    if(arg==null)
      return null;
    if(arg instanceof Dom)
      return (Dom)arg;
    if(arg instanceof ConfigBeanProxy)
      return Dom.unwrap((ConfigBeanProxy)arg);
    throw new IllegalArgumentException("Unexpected type "+arg.getClass()+" for "+xmlName);
  }
}

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

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

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

public void add(int index, Object element) {
  // update the master children list, as well as this view 'v'
  Dom child = Dom.unwrap((ConfigBeanProxy) element);
  dom.insertAfter( index==0 ? null : v.get(index-1), xmlName, child);
  v.add(index,child);
}

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

public Object set(int index, Object element) {
  Dom child = Dom.unwrap((ConfigBeanProxy) element);
  String name = "*".equals(xmlName) ? child.model.injector.getName() : xmlName;
  dom.replaceChild(v.get(index), name, child);
  return v.set(index,child).createProxy();
}

代码示例来源: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

public static ConfigBeanProxy getParent(ConfigBeanProxy self) {
  Dom dom = Dom.unwrap(self);
  if (dom.parent()!=null) {
    return dom.parent().createProxy();
  } else {
    return null;
  }
}

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

private ConfigBean _createAndSet(
        final ConfigBean parent,
        final Class<? extends ConfigBeanProxy> childType,
        final List<AttributeChanges> attributes,
        final TransactionCallBack<WriteableView> runnable)
    throws TransactionFailure {
  ConfigBeanProxy readableView = parent.getProxy(parent.getProxyType());
  ConfigBeanProxy readableChild = (ConfigBeanProxy)
      apply(new SingleConfigCode<ConfigBeanProxy>() {
    public Object run(ConfigBeanProxy param) throws PropertyVetoException, TransactionFailure {
      return addChildWithAttributes(param, parent, childType, attributes, runnable);
    }
  }, readableView);
  return (ConfigBean) Dom.unwrap(readableChild);
}

代码示例来源: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

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

added.add(Dom.unwrap(proxy));
  final NotProcessed nc = target.changed(Changed.TYPE.ADD, proxyType(proxy), proxy);
  if ( nc != null ) {
Dom eventSource = Dom.unwrap((ConfigBeanProxy) event.getSource());
if (added.contains(eventSource)) {

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

final Object toBeRemovedObj = event.getOldValue();
if ( toBeRemovedObj instanceof ConfigBeanProxy ) {
  final Dom toBeRemoved = Dom.unwrap((ConfigBeanProxy)toBeRemovedObj);
  for (int index=0;index<originalList.size();index++) {
    Object element = originalList.get(index);
    Dom dom = Dom.unwrap((ConfigBeanProxy) element);
    if (dom==toBeRemoved) {
      Object newValue = event.getNewValue();

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

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

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

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) {

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

public static ConfigBeanProxy deepCopy(ConfigBeanProxy self, ConfigBeanProxy parent) throws TransactionFailure {
  ConfigBean configBean = (ConfigBean) Dom.unwrap(self);
  // ensure the parent is locked
  Transaction t = Transaction.getTransaction(parent);
  if (t==null) {
    throw new TransactionFailure("Must use a locked parent config object for copying new config object");
  }
  ConfigBean copy = configBean.copy(configBean.parent());
  return t.enroll(copy.createProxy());
}

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

Dom dom = Dom.unwrap(child);

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

Dom thisview = Dom.unwrap(defaultView);

代码示例来源: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

public void testDomTx() {
  SimpleConnector sc = habitat.getService(SimpleConnector.class);
  EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
  Dom ejbDom = Dom.unwrap(ejb);
  assert(ejbDom.getHabitat() != null);
  String avEnabled = ejb.getAvailabilityEnabled();
  try {
    ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() {
      @Override
      public Object run(EjbContainerAvailability param)
          throws PropertyVetoException, TransactionFailure {
        param.setSfsbHaPersistenceType("coherence");
        param.setSfsbCheckpointEnabled("**MUST BE**");
        return null;
      }
    }, ejb);
    //printEjb("AFTER CHANGES", ejb);
    assert(ejb.getSfsbHaPersistenceType().equals("coherence")
        && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**")
        && ejb.getAvailabilityEnabled().equals(avEnabled));
  } catch (Exception e) {
    e.printStackTrace();
    assert(false);
  }
}

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

public void testDomTxReadOnlyAttributes() {
  SimpleConnector sc = habitat.getService(SimpleConnector.class);
  final EjbContainerAvailability ejb = sc.getEjbContainerAvailability();
  Dom ejbDom = Dom.unwrap(ejb);
  assert(ejbDom.getHabitat() != null);
  String origAVEnabled = ejb.getAvailabilityEnabled();
  final String origSFSBHaPersistenceType = ejb.getSfsbHaPersistenceType();
  try {
    ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() {
      @Override
      public Object run(EjbContainerAvailability param)
          throws PropertyVetoException, TransactionFailure {
        param.setSfsbHaPersistenceType("99999.999");
        param.setSfsbCheckpointEnabled("**MUST BE**");
        assert(origSFSBHaPersistenceType.equals(ejb.getSfsbHaPersistenceType()));
        assert(! ejb.getSfsbHaPersistenceType().equals(param.getSfsbHaPersistenceType()));
        return null;
      }
    }, ejb);
    //printEjb("AFTER CHANGES", ejb);
    assert(ejb.getSfsbHaPersistenceType().equals("99999.999")
        && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**")
        && ejb.getAvailabilityEnabled().equals(origAVEnabled));
  } catch (Exception e) {
    e.printStackTrace();
    assert(false);
  }
}

代码示例来源:origin: org.glassfish.hk2/hk2-config

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;
  }
}

相关文章