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

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

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

Dom.resolveReference介绍

[英]Recursively decends the DOM tree and finds a DOM that has the given key and the type name.

TODO: the current algorithm does a full tree scan. Expand the model so that we can detect deadends that are statically known not to contain the kind we are looking for, and use that to cut the search space.
[中]递归地对DOM树进行去中心化,并查找具有给定键和类型名的DOM。
TODO:当前算法执行完整树扫描。扩展模型,以便我们可以检测静态已知的不包含我们正在寻找的类型的死角,并使用它来削减搜索空间。

代码示例

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

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

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

/**
 * Recursively decends the DOM tree and finds a DOM that has the given key
 * and the type name.
 *
 * <p>
 * TODO: the current algorithm does a full tree scan. Expand the model
 * so that we can detect deadends that are statically known not to contain
 * the kind we are looking for, and use that to cut the search space.
 */
public Dom resolveReference(String key, String typeName) {
  String keyedAs = model.keyedAs;
  if(keyedAs!=null && keyedAs.equals(typeName) && getKey().equals(key))
    return this; // found it
  for (Child child : children) {
    if (child instanceof NodeChild) {
      NodeChild n = (NodeChild) child;
      Dom found = n.dom.resolveReference(key,typeName);
      if(found!=null) return found;
    }
  }
  return null;
}

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

protected Object convertLeafValue(Dom parent, Class<?> returnType, String v) {
  // let's look first the fast way.
  Object candidate = parent.getHabitat().getService(returnType, v);
  if (candidate!=null) {
    return returnType.cast(candidate);
  }
  parent = parent.getSymbolSpaceRoot(v);
  Dom dom = parent.resolveReference(v,returnType.getName());
  if (dom!=null) {
    return returnType.cast(dom.get());
  } else {
    throw new IllegalArgumentException("Cannot find an instance of " + returnType + " named " + v);
  }
}

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

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.attribute(xmlName);
  // since the id is supposed to be the element's key, if no key, no element.
  if (id==null) {
    return null;
  }
  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: com.sun.enterprise/config

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

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

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

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

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

/**
   * Resolves a reference to the given type by the given id.
   */
  public final <T> T reference(Dom dom, String id, Class<T> type) {
    // TODO: this doesn't work in case where type is a subtype of indexed type.
    String name = type.getName();
    dom = dom.getSymbolSpaceRoot(name);
    return type.cast(dom.resolveReference(id,name).get());
  }
}

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

protected Object convertLeafValue(Dom parent, Class<?> returnType, String v) {
  // let's look first the fast way.
  Object candidate = parent.getHabitat().getComponent(returnType, v);
  if (candidate!=null) {
    return returnType.cast(candidate);
  }
  parent = parent.getSymbolSpaceRoot(v);
  Dom dom = parent==null?null:parent.resolveReference(v,returnType.getName());
  if (dom!=null) {
    return returnType.cast(dom.get());
  } else {
    throw new IllegalArgumentException("Cannot find an instance of " + returnType + " named " + v);
  }
}

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

protected Object convertLeafValue(Dom parent, Class<?> returnType, String v) {
  // let's look first the fast way.
  Object candidate = parent.getHabitat().getService(returnType, v);
  if (candidate!=null) {
    return returnType.cast(candidate);
  }
  parent = parent.getSymbolSpaceRoot(v);
  Dom dom = parent==null?null:parent.resolveReference(v,returnType.getName());
  if (dom!=null) {
    return returnType.cast(dom.get());
  } else {
    throw new IllegalArgumentException("Cannot find an instance of " + returnType + " named " + v);
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

protected Object convertLeafValue(Dom parent, Class<?> returnType, String v) {
  // let's look first the fast way.
  Object candidate = parent.getHabitat().getService(returnType, v);
  if (candidate!=null) {
    return returnType.cast(candidate);
  }
  parent = parent.getSymbolSpaceRoot(v);
  Dom dom = parent.resolveReference(v,returnType.getName());
  if (dom!=null) {
    return returnType.cast(dom.get());
  } else {
    throw new IllegalArgumentException("Cannot find an instance of " + returnType + " named " + v);
  }
}

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

@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: com.sun.enterprise/config

@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().getComponent(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

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

@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().getComponent(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

代码示例来源:origin: eclipse-ee4j/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: org.glassfish.hk2/config

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.attribute(xmlName);
  // since the id is supposed to be the element's key, if no key, no element.
  if (id==null) {
    return null;
  }
  Class<?> type = Types.erasure(returnType);
  
  // let's look first the fast way.
  Object candidate = dom.getHabitat().getComponent(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

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

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.attribute(xmlName);
  // since the id is supposed to be the element's key, if no key, no element.
  if (id==null) {
    return null;
  }
  Class<?> type = Types.erasure(returnType);
  
  // let's look first the fast way.
  Object candidate = dom.getHabitat().getComponent(type, id);
  if (candidate!=null) {
    return type.cast(candidate);
  }
  dom = dom.getSymbolSpaceRoot(id);
  return type.cast(dom.resolveReference(id,type.getName()).get());
}

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

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.attribute(xmlName);
  // since the id is supposed to be the element's key, if no key, no element.
  if (id==null) {
    return null;
  }
  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: eclipse-ee4j/glassfish

@Override
public Object get(Dom dom, Type returnType) {
  String id = dom.attribute(xmlName);
  // since the id is supposed to be the element's key, if no key, no element.
  if (id==null) {
    return null;
  }
  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());
}

相关文章