aQute.bnd.osgi.Analyzer.referTo()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(92)

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

Analyzer.referTo介绍

暂无

代码示例

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

public void referToByBinaryName(String binaryClassName) {
  TypeRef ref = descriptors.getTypeRef(binaryClassName);
  referTo(ref);
}

代码示例来源:origin: biz.aQute.bnd/bnd

public void referToByBinaryName(String binaryClassName) {
  TypeRef ref = descriptors.getTypeRef(binaryClassName);
  referTo(ref);
}

代码示例来源:origin: biz.aQute.bnd/bndlib

public void referToByBinaryName(String binaryClassName) {
  TypeRef ref = descriptors.getTypeRef(binaryClassName);
  referTo(ref);
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

public void referToByBinaryName(String binaryClassName) {
  TypeRef ref = descriptors.getTypeRef(binaryClassName);
  referTo(ref);
}

代码示例来源:origin: biz.aQute/bndlib

public void referToByBinaryName(String binaryClassName) {
  TypeRef ref = descriptors.getTypeRef(binaryClassName);
  referTo(ref);
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * @param cd
 * @param provides
 */
void provide(ComponentDef cd, String provides, String impl) {
  if (provides != null) {
    StringTokenizer st = new StringTokenizer(provides, ",");
    List<TypeRef> provide = new ArrayList<>();
    while (st.hasMoreTokens()) {
      String interfaceName = st.nextToken();
      TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
      provide.add(ref);
      analyzer.referTo(ref);
      // TODO verifies the impl. class extends or implements the
      // interface
    }
    cd.service = provide.toArray(new TypeRef[0]);
  }
}

代码示例来源:origin: biz.aQute.bnd/bndlib

/**
 * @param cd
 * @param provides
 */
void provide(ComponentDef cd, String provides, String impl) {
  if (provides != null) {
    StringTokenizer st = new StringTokenizer(provides, ",");
    List<TypeRef> provide = new ArrayList<TypeRef>();
    while (st.hasMoreTokens()) {
      String interfaceName = st.nextToken();
      TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
      provide.add(ref);
      analyzer.referTo(ref);
      // TODO verifies the impl. class extends or implements the
      // interface
    }
    cd.service = provide.toArray(new TypeRef[provide.size()]);
  } 
}

代码示例来源:origin: biz.aQute/bndlib

/**
 * @param cd
 * @param provides
 */
void provide(ComponentDef cd, String provides, String impl) {
  if (provides != null) {
    StringTokenizer st = new StringTokenizer(provides, ",");
    List<TypeRef> provide = new ArrayList<TypeRef>();
    while (st.hasMoreTokens()) {
      String interfaceName = st.nextToken();
      TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
      provide.add(ref);
      analyzer.referTo(ref);
      // TODO verifies the impl. class extends or implements the
      // interface
    }
    cd.service = provide.toArray(new TypeRef[provide.size()]);
  } 
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

/**
 * @param cd
 * @param provides
 */
void provide(ComponentDef cd, String provides, String impl) {
  if (provides != null) {
    StringTokenizer st = new StringTokenizer(provides, ",");
    List<TypeRef> provide = new ArrayList<>();
    while (st.hasMoreTokens()) {
      String interfaceName = st.nextToken();
      TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
      provide.add(ref);
      analyzer.referTo(ref);
      // TODO verifies the impl. class extends or implements the
      // interface
    }
    cd.service = provide.toArray(new TypeRef[0]);
  }
}

代码示例来源:origin: biz.aQute.bnd/bnd

/**
 * @param cd
 * @param provides
 */
void provide(ComponentDef cd, String provides, String impl) {
  if (provides != null) {
    StringTokenizer st = new StringTokenizer(provides, ",");
    List<TypeRef> provide = new ArrayList<TypeRef>();
    while (st.hasMoreTokens()) {
      String interfaceName = st.nextToken();
      TypeRef ref = analyzer.getTypeRefFromFQN(interfaceName);
      provide.add(ref);
      analyzer.referTo(ref);
      // TODO verifies the impl. class extends or implements the
      // interface
    }
    cd.service = provide.toArray(new TypeRef[provide.size()]);
  } 
}

代码示例来源:origin: biz.aQute/bndlib

private void createComponentResource(Map<String,Map<String,String>> components, String name,
    Map<String,String> info) throws Exception {
  // We can override the name in the parameters
  if (info.containsKey(COMPONENT_NAME))
    name = info.get(COMPONENT_NAME);
  // Assume the impl==name, but allow override
  String impl = name;
  if (info.containsKey(COMPONENT_IMPLEMENTATION))
    impl = info.get(COMPONENT_IMPLEMENTATION);
  TypeRef implRef = analyzer.getTypeRefFromFQN(impl);
  // Check if such a class exists
  analyzer.referTo(implRef);
  boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
      || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
  // If we had a designate, we want a default configuration policy of
  // require.
  if (designate && info.get(COMPONENT_CONFIGURATION_POLICY) == null)
    info.put(COMPONENT_CONFIGURATION_POLICY, "require");
  // We have a definition, so make an XML resources
  Resource resource = createComponentResource(name, impl, info);
  analyzer.getJar().putResource("OSGI-INF/" + name + ".xml", resource);
  components.put("OSGI-INF/" + name + ".xml", EMPTY);
}

代码示例来源:origin: biz.aQute.bnd/bnd

private void createComponentResource(Map<String,Map<String,String>> components, String name,
    Map<String,String> info) throws Exception {
  // We can override the name in the parameters
  if (info.containsKey(COMPONENT_NAME))
    name = info.get(COMPONENT_NAME);
  // Assume the impl==name, but allow override
  String impl = name;
  if (info.containsKey(COMPONENT_IMPLEMENTATION))
    impl = info.get(COMPONENT_IMPLEMENTATION);
  TypeRef implRef = analyzer.getTypeRefFromFQN(impl);
  // Check if such a class exists
  analyzer.referTo(implRef);
  boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
      || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
  // If we had a designate, we want a default configuration policy of
  // require.
  if (designate && info.get(COMPONENT_CONFIGURATION_POLICY) == null)
    info.put(COMPONENT_CONFIGURATION_POLICY, "require");
  // We have a definition, so make an XML resources
  Resource resource = createComponentResource(name, impl, info);
  
  String pathSegment = analyzer.validResourcePath(name, "Invalid component name");
  analyzer.getJar().putResource("OSGI-INF/" + pathSegment + ".xml", resource);
  components.put("OSGI-INF/" + pathSegment + ".xml", EMPTY);
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

private void createComponentResource(Map<String, Map<String, String>> components, String name,
  Map<String, String> info) throws Exception {
  // We can override the name in the parameters
  if (info.containsKey(COMPONENT_NAME))
    name = info.get(COMPONENT_NAME);
  // Assume the impl==name, but allow override
  String impl = name;
  if (info.containsKey(COMPONENT_IMPLEMENTATION))
    impl = info.get(COMPONENT_IMPLEMENTATION);
  TypeRef implRef = analyzer.getTypeRefFromFQN(impl);
  // Check if such a class exists
  analyzer.referTo(implRef);
  boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
    || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
  // If we had a designate, we want a default configuration policy of
  // require.
  if (designate && info.get(COMPONENT_CONFIGURATION_POLICY) == null)
    info.put(COMPONENT_CONFIGURATION_POLICY, "require");
  // We have a definition, so make an XML resources
  Resource resource = createComponentResource(name, impl, info);
  String pathSegment = analyzer.validResourcePath(name, "Invalid component name");
  analyzer.getJar()
    .putResource("OSGI-INF/" + pathSegment + ".xml", resource);
  components.put("OSGI-INF/" + pathSegment + ".xml", EMPTY);
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

private void createComponentResource(Map<String, Map<String, String>> components, String name,
  Map<String, String> info) throws Exception {
  // We can override the name in the parameters
  if (info.containsKey(COMPONENT_NAME))
    name = info.get(COMPONENT_NAME);
  // Assume the impl==name, but allow override
  String impl = name;
  if (info.containsKey(COMPONENT_IMPLEMENTATION))
    impl = info.get(COMPONENT_IMPLEMENTATION);
  TypeRef implRef = analyzer.getTypeRefFromFQN(impl);
  // Check if such a class exists
  analyzer.referTo(implRef);
  boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
    || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
  // If we had a designate, we want a default configuration policy of
  // require.
  if (designate && info.get(COMPONENT_CONFIGURATION_POLICY) == null)
    info.put(COMPONENT_CONFIGURATION_POLICY, "require");
  // We have a definition, so make an XML resources
  Resource resource = createComponentResource(name, impl, info);
  String pathSegment = analyzer.validResourcePath(name, "Invalid component name");
  analyzer.getJar()
    .putResource("OSGI-INF/" + pathSegment + ".xml", resource);
  components.put("OSGI-INF/" + pathSegment + ".xml", EMPTY);
}

代码示例来源:origin: biz.aQute.bnd/bndlib

private void createComponentResource(Map<String,Map<String,String>> components, String name,
    Map<String,String> info) throws Exception {
  // We can override the name in the parameters
  if (info.containsKey(COMPONENT_NAME))
    name = info.get(COMPONENT_NAME);
  // Assume the impl==name, but allow override
  String impl = name;
  if (info.containsKey(COMPONENT_IMPLEMENTATION))
    impl = info.get(COMPONENT_IMPLEMENTATION);
  TypeRef implRef = analyzer.getTypeRefFromFQN(impl);
  // Check if such a class exists
  analyzer.referTo(implRef);
  boolean designate = designate(name, info.get(COMPONENT_DESIGNATE), false)
      || designate(name, info.get(COMPONENT_DESIGNATEFACTORY), true);
  // If we had a designate, we want a default configuration policy of
  // require.
  if (designate && info.get(COMPONENT_CONFIGURATION_POLICY) == null)
    info.put(COMPONENT_CONFIGURATION_POLICY, "require");
  // We have a definition, so make an XML resources
  Resource resource = createComponentResource(name, impl, info);
  
  String pathSegment = analyzer.validResourcePath(name, "Invalid component name");
  analyzer.getJar().putResource("OSGI-INF/" + pathSegment + ".xml", resource);
  components.put("OSGI-INF/" + pathSegment + ".xml", EMPTY);
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Called to prepare. If will look for any errors or inconsistencies in the
 * setup.
 * 
 * @param analyzer the analyzer to report errors and create references
 * @throws Exception
 */
void prepare(Analyzer analyzer) throws Exception {
  prepareVersion(analyzer);
  if (implementation == null) {
    analyzer.error("No Implementation defined for component %s", name);
    return;
  }
  analyzer.referTo(implementation);
  if (name == null)
    name = implementation.getFQN();
  if (service != null && service.length > 0) {
    for (TypeRef interfaceName : service)
      analyzer.referTo(interfaceName);
  } else if (scope != null && scope != ServiceScope.BUNDLE)
    analyzer.warning("The servicefactory:=true directive is set but no service is provided, ignoring it");
  if (factory == null && (!factoryProperty.isEmpty() || !factoryProperties.isEmpty())) {
    analyzer.error("The factoryProperty and/or factoryProperies elements are used on a non-factory component");
  }
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

/**
 * Called to prepare. If will look for any errors or inconsistencies in the
 * setup.
 * 
 * @param analyzer the analyzer to report errors and create references
 * @throws Exception
 */
void prepare(Analyzer analyzer) throws Exception {
  prepareVersion(analyzer);
  if (implementation == null) {
    analyzer.error("No Implementation defined for component %s", name);
    return;
  }
  analyzer.referTo(implementation);
  if (name == null)
    name = implementation.getFQN();
  if (service != null && service.length > 0) {
    for (TypeRef interfaceName : service)
      analyzer.referTo(interfaceName);
  } else if (scope != null && scope != ServiceScope.BUNDLE)
    analyzer.warning("The servicefactory:=true directive is set but no service is provided, ignoring it");
  if (factory == null && (!factoryProperty.isEmpty() || !factoryProperties.isEmpty())) {
    analyzer.error("The factoryProperty and/or factoryProperies elements are used on a non-factory component");
  }
}

代码示例来源:origin: biz.aQute/bndlib

/**
 * Create a Metatype and Designate record out of the given
 * configurations.
 * 
 * @param name
 * @param config
 */
private boolean designate(String name, String config, boolean factory) {
  if (config == null)
    return false;
  for (String c : Processor.split(config)) {
    TypeRef ref = analyzer.getTypeRefFromFQN(c);
    Clazz clazz = analyzer.getClassspace().get(ref);
    if (clazz != null) {
      analyzer.referTo(ref);
      MetaTypeReader r = new MetaTypeReader(clazz, analyzer);
      r.setDesignate(name, factory);
      String rname = "OSGI-INF/metatype/" + name + ".xml";
      analyzer.getJar().putResource(rname, r);
    } else {
      analyzer.error("Cannot find designated configuration class %s for component %s", c, name);
    }
  }
  return true;
}

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

/**
 * Create a Metatype and Designate record out of the given
 * configurations.
 * 
 * @param name
 * @param config
 * @throws Exception
 */
private boolean designate(String name, String config, boolean factory) throws Exception {
  if (config == null)
    return false;
  for (String c : Processor.split(config)) {
    TypeRef ref = analyzer.getTypeRefFromFQN(c);
    Clazz clazz = analyzer.findClass(ref);
    if (clazz != null) {
      analyzer.referTo(ref);
      MetaTypeReader r = new MetaTypeReader(clazz, analyzer);
      r.setDesignate(name, factory);
      String rname = "OSGI-INF/metatype/" + name + ".xml";
      analyzer.getJar()
        .putResource(rname, r);
    } else {
      analyzer.error("Cannot find designated configuration class %s for component %s", c, name);
    }
  }
  return true;
}

代码示例来源:origin: biz.aQute.bnd/bndlib

/**
 * Create a Metatype and Designate record out of the given
 * configurations.
 * 
 * @param name
 * @param config
 * @throws Exception 
 */
private boolean designate(String name, String config, boolean factory) throws Exception {
  if (config == null)
    return false;
  for (String c : Processor.split(config)) {
    TypeRef ref = analyzer.getTypeRefFromFQN(c);
    Clazz clazz = analyzer.findClass(ref);
    if (clazz != null) {
      analyzer.referTo(ref);
      MetaTypeReader r = new MetaTypeReader(clazz, analyzer);
      r.setDesignate(name, factory);
      String rname = "OSGI-INF/metatype/" + name + ".xml";
      analyzer.getJar().putResource(rname, r);
    } else {
      analyzer.error("Cannot find designated configuration class %s for component %s", c, name);
    }
  }
  return true;
}

相关文章

Analyzer类方法