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); }
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); }
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); }
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); }
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; }
String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(definition.id, "Invalid resource name") + ".xml"; analyzer.getJar()
String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(definition.id, "Invalid resource name") + ".xml"; analyzer.getJar()
definition.prepare(analyzer); String name = "OSGI-INF/" + analyzer.validResourcePath(definition.name, "Invalid component name") + ".xml"; names.add(name);
definition.prepare(analyzer); String name = "OSGI-INF/" + analyzer.validResourcePath(definition.name, "Invalid component name") + ".xml"; names.add(name);
definition.prepare(analyzer); classToOCDMap.put(c.getClassName().getBinary(), definition); String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(definition.id, "Invalid resource name") + ".xml"; analyzer.getJar().putResource(name, new TagResource(definition.getTag())); if (designate != null) { designate.prepare(analyzer); String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(c.getFQN(), "Invalid resource name") + ".xml"; analyzer.getJar().putResource(name, new TagResource(designate.getTag()));
definition.prepare(analyzer); classToOCDMap.put(c.getClassName().getBinary(), definition); String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(definition.id, "Invalid resource name") + ".xml"; analyzer.getJar().putResource(name, new TagResource(definition.getTag())); if (designate != null) { designate.prepare(analyzer); String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(c.getFQN(), "Invalid resource name") + ".xml"; analyzer.getJar().putResource(name, new TagResource(designate.getTag()));