void annotated(Map<String,Map<String,String>> components, Clazz c, Map<String,String> info) throws Exception { // Get the component definition // from the annotations Map<String,String> map = ComponentAnnotationReader.getDefinition(c, this); // Pick the name, the annotation can override // the name. String localname = map.get(COMPONENT_NAME); if (localname == null) localname = c.getFQN(); // Override the component info without manifest // entries. We merge the properties though. String merged = Processor.merge(info.remove(COMPONENT_PROPERTIES), map.remove(COMPONENT_PROPERTIES)); if (merged != null && merged.length() > 0) map.put(COMPONENT_PROPERTIES, merged); map.putAll(info); createComponentResource(components, localname, map); }
void annotated(Map<String,Map<String,String>> components, Clazz c, Map<String,String> info) throws Exception { // Get the component definition // from the annotations Map<String,String> map = ComponentAnnotationReader.getDefinition(c, this); // Pick the name, the annotation can override // the name. String localname = map.get(COMPONENT_NAME); if (localname == null) localname = c.getFQN(); // Override the component info without manifest // entries. We merge the properties though. String merged = Processor.merge(info.remove(COMPONENT_PROPERTIES), map.remove(COMPONENT_PROPERTIES)); if (merged != null && merged.length() > 0) map.put(COMPONENT_PROPERTIES, merged); map.putAll(info); createComponentResource(components, localname, map); }
void annotated(Map<String,Map<String,String>> components, Clazz c, Map<String,String> info) throws Exception { // Get the component definition // from the annotations Map<String,String> map = ComponentAnnotationReader.getDefinition(c, this); // Pick the name, the annotation can override // the name. String localname = map.get(COMPONENT_NAME); if (localname == null) localname = c.getFQN(); // Override the component info without manifest // entries. We merge the properties though. String merged = Processor.merge(info.remove(COMPONENT_PROPERTIES), map.remove(COMPONENT_PROPERTIES)); if (merged != null && merged.length() > 0) map.put(COMPONENT_PROPERTIES, merged); map.putAll(info); createComponentResource(components, localname, map); }
public boolean analyzeJar(Analyzer analyzer) throws Exception { Parameters map = analyzer.parseHeader(analyzer.getProperty(Constants.METATYPE)); Jar jar = analyzer.getJar(); for (String name : map.keySet()) { Collection<Clazz> metatypes = analyzer.getClasses("", QUERY.ANNOTATED.toString(), Meta.OCD.class.getName(), // QUERY.NAMED.toString(), name // ); for (Clazz c : metatypes) { jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c, analyzer)); } } return false; } }
public boolean analyzeJar(Analyzer analyzer) throws Exception { Parameters map = analyzer.parseHeader(analyzer.getProperty(Constants.METATYPE)); Jar jar = analyzer.getJar(); for (String name : map.keySet()) { Collection<Clazz> metatypes = analyzer.getClasses("", QUERY.ANNOTATED.toString(), Meta.OCD.class.getName(), // QUERY.NAMED.toString(), name // ); for (Clazz c : metatypes) { jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c, analyzer)); } } return false; } @Override
public boolean analyzeJar(Analyzer analyzer) throws Exception { Parameters map = analyzer.parseHeader(analyzer.getProperty(Constants.METATYPE)); Jar jar = analyzer.getJar(); for (String name : map.keySet()) { Collection<Clazz> metatypes = analyzer.getClasses("", QUERY.ANNOTATED.toString(), Meta.OCD.class.getName(), // QUERY.NAMED.toString(), name // ); for (Clazz c : metatypes) { jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c, analyzer)); } } return false; } @Override
analyzer.exception(e, "The Requirement annotation with namespace %s applied to class %s has invalid filter information.", annotation.namespace(), current.getFQN());
analyzer.exception(e, "The version declared by the Capability annotation attached to type %s is invalid", current.getFQN());
for (Instruction instruction : instructions.keySet()) { if (instruction.matches(c.getFQN())) { if (instruction.isNegated()) break;
public boolean analyzeJar(Analyzer analyzer) throws Exception { Parameters header = OSGiHeader.parseHeader(analyzer.getProperty(Constants.DSANNOTATIONS)); if (header.size() == 0) return false; Instructions instructions = new Instructions(header); Collection<Clazz> list = analyzer.getClassspace().values(); String sc = analyzer.getProperty(Constants.SERVICE_COMPONENT); List<String> names = new ArrayList<String>(); if (sc != null && sc.trim().length() > 0) names.add(sc); for (Clazz c: list) { for (Instruction instruction : instructions.keySet()) { if (instruction.matches(c.getFQN())) { if (instruction.isNegated()) break; ComponentDef definition = AnnotationReader.getDefinition(c, analyzer); if (definition != null) { definition.sortReferences(); definition.prepare(analyzer); String name = "OSGI-INF/" + analyzer.validResourcePath(definition.name, "Invalid component name") + ".xml"; names.add(name); analyzer.getJar().putResource(name, new TagResource(definition.getTag())); } } } } sc = Processor.append(names.toArray(new String[names.size()])); analyzer.setProperty(Constants.SERVICE_COMPONENT, sc); return false; }
public boolean analyzeJar(Analyzer analyzer) throws Exception { Parameters header = OSGiHeader.parseHeader(analyzer.getProperty(Constants.DSANNOTATIONS)); if (header.size() == 0) return false; Instructions instructions = new Instructions(header); Collection<Clazz> list = analyzer.getClassspace().values(); String sc = analyzer.getProperty(Constants.SERVICE_COMPONENT); List<String> names = new ArrayList<String>(); if (sc != null && sc.trim().length() > 0) names.add(sc); for (Clazz c: list) { for (Instruction instruction : instructions.keySet()) { if (instruction.matches(c.getFQN())) { if (instruction.isNegated()) break; ComponentDef definition = AnnotationReader.getDefinition(c, analyzer); if (definition != null) { definition.sortReferences(); definition.prepare(analyzer); String name = "OSGI-INF/" + analyzer.validResourcePath(definition.name, "Invalid component name") + ".xml"; names.add(name); analyzer.getJar().putResource(name, new TagResource(definition.getTag())); } } } } sc = Processor.append(names.toArray(new String[names.size()])); analyzer.setProperty(Constants.SERVICE_COMPONENT, sc); return false; }
clazz.getFQN()); TypeRef cname = clazz.getClassName(); String source = analyzer.getSourceFileFor(cname);
public void finish() { set(COMPONENT_MULTIPLE, multiple); set(COMPONENT_DYNAMIC, dynamic); set(COMPONENT_OPTIONAL, optional); set(COMPONENT_IMPLEMENTATION, clazz.getFQN(), "<>"); set(COMPONENT_PROPERTIES, properties); if (version != null) { set(COMPONENT_VERSION, version, "<>"); reporter.trace("Component %s is v1.1", map); } set(COMPONENT_DESCRIPTORS, descriptors); }
public void finish() { set(COMPONENT_MULTIPLE, multiple); set(COMPONENT_DYNAMIC, dynamic); set(COMPONENT_OPTIONAL, optional); set(COMPONENT_IMPLEMENTATION, clazz.getFQN(), "<>"); set(COMPONENT_PROPERTIES, properties); if (version != null) { set(COMPONENT_VERSION, version, "<>"); reporter.trace("Component %s is v1.1", map); } set(COMPONENT_DESCRIPTORS, descriptors); }
public void finish() { set(COMPONENT_MULTIPLE, multiple); set(COMPONENT_DYNAMIC, dynamic); set(COMPONENT_OPTIONAL, optional); set(COMPONENT_IMPLEMENTATION, clazz.getFQN(), "<>"); set(COMPONENT_PROPERTIES, properties); if (version != null) { set(COMPONENT_VERSION, version, "<>"); reporter.trace("Component %s is v1.1", map); } set(COMPONENT_DESCRIPTORS, descriptors); }
/** * Check if an annotation applied on the component class is a component property type. * (the following is adapted from the original bnd DS AnnotationReader class) */ private void handlePossibleComponentPropertyAnnotation(Annotation annotation) { m_logger.debug("Checking possible component property annotations %s", annotation); try { Clazz clazz = m_analyzer.findClass(annotation.getName()); if (clazz == null) { m_logger.debug( "Unable to find the annotation %s applied to type %s from project build path (ignoring it).", annotation.getName().getFQN(), m_currentClassName); return; } if (clazz.is(ANNOTATED, DS_PROPERTY_TYPE, m_analyzer) || clazz.is(ANNOTATED, DM_PROPERTY_TYPE, m_analyzer)) { m_logger.debug("Found component property type %s", annotation); m_componentPropertyTypes.add(annotation); } else { m_logger.debug("The annotation %s on component type %s will not be used for properties as the annotation is not annotated with @ComponentPropertyType", clazz.getFQN(), m_currentClassName); return; } } catch (Exception e) { m_logger.error("An error occurred when attempting to process annotation %s, applied to component %s", e, annotation.getName().getFQN(), m_currentClassName); } }
logger.debug( "The annotation {} on component type {} will not be used for properties as the annotation is not annotated with @ComponentPropertyType", clazz.getFQN(), className.getFQN()); return;
next.setProperty("@class", current.getFQN()); next.setProperty("@class-short", current.getClassName() .getShortName());
private void add(String name, String value) { if (value == null) return; Processor next = new Processor(analyzer); next.setProperty("@class", current.getFQN()); next.setProperty("@class-short", current.getClassName().getShortName()); PackageRef pref = current.getClassName().getPackageRef(); next.setProperty("@package", pref.getFQN()); Attrs info = analyzer.getClasspathExports().get(pref); if (info == null) info = analyzer.getContained().get(pref); if (info != null && info.containsKey("version")) { next.setProperty("@version", info.get("version")); } Macro macro = next.getReplacer(); /* * These strings come from code, which might also be included from * external parties. So we just do not want to call any system commands * from these sources */ boolean prev = macro.setNosystem(true); try { value = macro.process(value); headers.add(name, value); next.close(); } finally { macro.setNosystem(prev); } }
private void add(String name, String value) { if (value == null) return; Processor next = new Processor(analyzer); next.setProperty("@class", current.getFQN()); next.setProperty("@class-short", current.getClassName().getShortName()); PackageRef pref = current.getClassName().getPackageRef(); next.setProperty("@package", pref.getFQN()); Attrs info = analyzer.getClasspathExports().get(pref); if (info == null) info = analyzer.getContained().get(pref); if (info != null && info.containsKey("version")) { next.setProperty("@version", info.get("version")); } Macro macro = next.getReplacer(); /* * These strings come from code, which might also be included from * external parties. So we just do not want to call any system commands * from these sources */ boolean prev = macro.setNosystem(true); try { value = macro.process(value); headers.add(name, value); next.close(); } finally { macro.setNosystem(prev); } }