Use local copy of latest bndlib code for pre-release testing purposes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1347815 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java b/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java
new file mode 100644
index 0000000..e451eb0
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/bnd/component/DSAnnotations.java
@@ -0,0 +1,52 @@
+package aQute.bnd.component;
+
+import java.util.*;
+
+import aQute.bnd.service.*;
+import aQute.lib.osgi.*;
+import aQute.libg.header.*;
+
+/**
+ * Analyze the class space for any classes that have an OSGi annotation for DS.
+ *
+ */
+public class DSAnnotations implements AnalyzerPlugin {
+
+ public boolean analyzeJar(Analyzer analyzer) throws Exception {
+ Parameters header = OSGiHeader.parseHeader(analyzer
+ .getProperty("-dsannotations"));
+ if ( header.size()==0)
+ return false;
+
+ Instructions instructions = new Instructions(header);
+ Set<Clazz> list = new HashSet<Clazz>(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 (Iterator<Clazz> i = list.iterator(); i.hasNext();) {
+ for (Instruction instruction : instructions.keySet()) {
+ Clazz c = i.next();
+
+ if (instruction.matches(c.getFQN())) {
+ if (instruction.isNegated())
+ i.remove();
+ else {
+ ComponentDef definition = AnnotationReader.getDefinition(c, analyzer);
+ if (definition != null) {
+ definition.prepare(analyzer);
+ String name = "OSGI-INF/" + definition.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;
+ }
+}