Latest bnd code
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1350613 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/Make.java b/bundleplugin/src/main/java/aQute/bnd/make/Make.java
index 2b0ce8a..a42b5e0 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/Make.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/Make.java
@@ -9,34 +9,34 @@
import aQute.libg.header.*;
public class Make {
- Builder builder;
- Map<Instruction, Map<String, String>> make;
+ Builder builder;
+ Map<Instruction,Map<String,String>> make;
public Make(Builder builder) {
this.builder = builder;
}
public Resource process(String source) {
- Map<Instruction, Map<String, String>> make = getMakeHeader();
+ Map<Instruction,Map<String,String>> make = getMakeHeader();
builder.trace("make " + source);
- for (Map.Entry<Instruction, Map<String, String>> entry : make.entrySet()) {
+ for (Map.Entry<Instruction,Map<String,String>> entry : make.entrySet()) {
Instruction instr = entry.getKey();
Matcher m = instr.getMatcher(source);
if (m.matches() || instr.isNegated()) {
- Map<String, String> arguments = replace(m, entry.getValue());
+ Map<String,String> arguments = replace(m, entry.getValue());
List<MakePlugin> plugins = builder.getPlugins(MakePlugin.class);
for (MakePlugin plugin : plugins) {
try {
Resource resource = plugin.make(builder, source, arguments);
if (resource != null) {
- builder.trace("Made " + source + " from args " + arguments + " with "
- + plugin);
+ builder.trace("Made " + source + " from args " + arguments + " with " + plugin);
return resource;
}
- } catch (Exception e) {
- builder.error("Plugin " + plugin + " generates error when use in making "
- + source + " with args " + arguments, e);
+ }
+ catch (Exception e) {
+ builder.error("Plugin " + plugin + " generates error when use in making " + source
+ + " with args " + arguments, e);
}
}
}
@@ -44,9 +44,9 @@
return null;
}
- private Map<String, String> replace(Matcher m, Map<String, String> value) {
- Map<String, String> newArgs = Processor.newMap();
- for (Map.Entry<String, String> entry : value.entrySet()) {
+ private Map<String,String> replace(Matcher m, Map<String,String> value) {
+ Map<String,String> newArgs = Processor.newMap();
+ for (Map.Entry<String,String> entry : value.entrySet()) {
String s = entry.getValue();
s = replace(m, s);
newArgs.put(entry.getKey(), s);
@@ -77,15 +77,15 @@
return sb.toString();
}
- Map<Instruction, Map<String, String>> getMakeHeader() {
+ Map<Instruction,Map<String,String>> getMakeHeader() {
if (make != null)
return make;
make = Processor.newMap();
String s = builder.getProperty(Builder.MAKE);
Parameters make = builder.parseHeader(s);
-
- for (Entry<String, Attrs> entry : make.entrySet()) {
+
+ for (Entry<String,Attrs> entry : make.entrySet()) {
String pattern = Processor.removeDuplicateMarker(entry.getKey());
Instruction instr = new Instruction(pattern);
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/MakeBnd.java b/bundleplugin/src/main/java/aQute/bnd/make/MakeBnd.java
index 581deb7..29e5353 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/MakeBnd.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/MakeBnd.java
@@ -9,57 +9,55 @@
import aQute.lib.osgi.*;
public class MakeBnd implements MakePlugin, Constants {
- final static Pattern JARFILE = Pattern.compile("(.+)\\.(jar|ipa)");
+ final static Pattern JARFILE = Pattern.compile("(.+)\\.(jar|ipa)");
- public Resource make(Builder builder, String destination,
- Map<String, String> argumentsOnMake) throws Exception {
- String type = argumentsOnMake.get("type");
- if (!"bnd".equals(type))
- return null;
+ public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
+ String type = argumentsOnMake.get("type");
+ if (!"bnd".equals(type))
+ return null;
- String recipe = argumentsOnMake.get("recipe");
- if (recipe == null) {
- builder.error("No recipe specified on a make instruction for "
- + destination);
- return null;
- }
- File bndfile = builder.getFile(recipe);
- if (bndfile.isFile()) {
- // We do not use a parent because then we would
- // build ourselves again. So we can not blindly
- // inherit the properties.
- Builder bchild = builder.getSubBuilder();
- bchild.removeBundleSpecificHeaders();
-
- // We must make sure that we do not include ourselves again!
- bchild.setProperty(Analyzer.INCLUDE_RESOURCE, "");
- bchild.setProperty(Analyzer.INCLUDERESOURCE, "");
- bchild.setProperties(bndfile, builder.getBase());
-
- Jar jar = bchild.build();
- Jar dot = builder.getTarget();
+ String recipe = argumentsOnMake.get("recipe");
+ if (recipe == null) {
+ builder.error("No recipe specified on a make instruction for " + destination);
+ return null;
+ }
+ File bndfile = builder.getFile(recipe);
+ if (bndfile.isFile()) {
+ // We do not use a parent because then we would
+ // build ourselves again. So we can not blindly
+ // inherit the properties.
+ Builder bchild = builder.getSubBuilder();
+ bchild.removeBundleSpecificHeaders();
- if (builder.hasSources()) {
- for (String key : jar.getResources().keySet()) {
- if (key.startsWith("OSGI-OPT/src"))
- dot.putResource(key, jar.getResource(key));
- }
- }
- builder.getInfo(bchild, bndfile.getName() +": ");
- String debug = bchild.getProperty(DEBUG);
- if (Processor.isTrue(debug)) {
- if ( builder instanceof ProjectBuilder ) {
- ProjectBuilder pb = (ProjectBuilder) builder;
- File target = pb.getProject().getTarget();
- String bsn = bchild.getBsn();
- File output = new File(target, bsn+".jar");
- jar.write(output);
- pb.getProject().getWorkspace().changedFile(output);
- }
- }
- return new JarResource(jar);
- } else
- return null;
- }
+ // We must make sure that we do not include ourselves again!
+ bchild.setProperty(Analyzer.INCLUDE_RESOURCE, "");
+ bchild.setProperty(Analyzer.INCLUDERESOURCE, "");
+ bchild.setProperties(bndfile, builder.getBase());
+
+ Jar jar = bchild.build();
+ Jar dot = builder.getTarget();
+
+ if (builder.hasSources()) {
+ for (String key : jar.getResources().keySet()) {
+ if (key.startsWith("OSGI-OPT/src"))
+ dot.putResource(key, jar.getResource(key));
+ }
+ }
+ builder.getInfo(bchild, bndfile.getName() + ": ");
+ String debug = bchild.getProperty(DEBUG);
+ if (Processor.isTrue(debug)) {
+ if (builder instanceof ProjectBuilder) {
+ ProjectBuilder pb = (ProjectBuilder) builder;
+ File target = pb.getProject().getTarget();
+ String bsn = bchild.getBsn();
+ File output = new File(target, bsn + ".jar");
+ jar.write(output);
+ pb.getProject().getWorkspace().changedFile(output);
+ }
+ }
+ return new JarResource(jar);
+ } else
+ return null;
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/MakeCopy.java b/bundleplugin/src/main/java/aQute/bnd/make/MakeCopy.java
index 3d5e4c8..74d2921 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/MakeCopy.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/MakeCopy.java
@@ -9,37 +9,34 @@
public class MakeCopy implements MakePlugin {
- public Resource make(Builder builder, String destination,
- Map<String, String> argumentsOnMake) throws Exception {
- String type = argumentsOnMake.get("type");
- if (!type.equals("copy"))
- return null;
+ public Resource make(Builder builder, String destination, Map<String,String> argumentsOnMake) throws Exception {
+ String type = argumentsOnMake.get("type");
+ if (!type.equals("copy"))
+ return null;
- String from = argumentsOnMake.get("from");
- if (from == null) {
- String content = argumentsOnMake.get("content");
- if (content == null)
- throw new IllegalArgumentException(
- "No 'from' or 'content' field in copy "
- + argumentsOnMake);
- return new EmbeddedResource(content.getBytes("UTF-8"),0);
- } else {
+ String from = argumentsOnMake.get("from");
+ if (from == null) {
+ String content = argumentsOnMake.get("content");
+ if (content == null)
+ throw new IllegalArgumentException("No 'from' or 'content' field in copy " + argumentsOnMake);
+ return new EmbeddedResource(content.getBytes("UTF-8"), 0);
+ } else {
- File f = builder.getFile(from);
- if (f.isFile())
- return new FileResource(f);
- else {
- try {
- URL url = new URL(from);
- return new URLResource(url);
- } catch(MalformedURLException mfue) {
- // We ignore this
- }
- throw new IllegalArgumentException(
- "Copy source does not exist " + from
- + " for destination " + destination);
- }
- }
- }
+ File f = builder.getFile(from);
+ if (f.isFile())
+ return new FileResource(f);
+ else {
+ try {
+ URL url = new URL(from);
+ return new URLResource(url);
+ }
+ catch (MalformedURLException mfue) {
+ // We ignore this
+ }
+ throw new IllegalArgumentException("Copy source does not exist " + from + " for destination "
+ + destination);
+ }
+ }
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java b/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java
index e06cdc5f..a41e337 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/calltree/CalltreeResource.java
@@ -14,160 +14,160 @@
* calltree ::= <using> <usedby>
* using ::= <method> *
* usedby ::= <method> *
- * method ::= <ref>
+ * method ::= <ref>
* </pre>
*
* The <code>using</code> element contains methods in the set of classes and
* their references. The <code>usedby</code> element contains the used methods
* and their references to the set of classes. The <code>ref</code> element
* contains the class, the method name, the descriptor, and a pretty print
- * version of the method.
- *
- * The XML does not contain an XML processor instruction to make it easier to
- * include in other XML. The encoding is always UTF-8.
- *
- * This class can be used as a resource, just add it to a JAR and the data is
+ * version of the method. The XML does not contain an XML processor instruction
+ * to make it easier to include in other XML. The encoding is always UTF-8. This
+ * class can be used as a resource, just add it to a JAR and the data is
* generated when the resource is written (saving time when the JAR is up to
* date and does not have to be generated). However, the actual write method is
* a static method and can be called as well:
* {@link #writeCalltree(PrintWriter, Collection)}.
*/
public class CalltreeResource extends WriteResource {
- Collection<Clazz> classes;
+ Collection<Clazz> classes;
- /**
- * Create a resource for inclusion that will print a call tree.
- *
- * @param values the classes for which the call tree is generated.
- */
- public CalltreeResource(Collection<Clazz> values) {
- this.classes = values;
- System.err.println(values);
- }
+ /**
+ * Create a resource for inclusion that will print a call tree.
+ *
+ * @param values
+ * the classes for which the call tree is generated.
+ */
+ public CalltreeResource(Collection<Clazz> values) {
+ this.classes = values;
+ System.err.println(values);
+ }
- /**
- * We set the last modified to 0 so this resource does not force
- * a new JAR if all other resources are up to date.
- */
- public long lastModified() {
- return 0;
- }
+ /**
+ * We set the last modified to 0 so this resource does not force a new JAR
+ * if all other resources are up to date.
+ */
+ public long lastModified() {
+ return 0;
+ }
- /**
- * The write method is called to write the resource. We just call the static
- * method.
- */
- public void write(OutputStream out) throws Exception {
- OutputStreamWriter osw = new OutputStreamWriter(out, Constants.DEFAULT_CHARSET);
- PrintWriter pw = new PrintWriter(osw);
- try {
- writeCalltree(pw, classes);
- } finally {
- pw.flush();
- }
- }
-
- /**
- * Print the call tree in XML.
- *
- * @param out The output writer
- * @param classes The set of classes
- * @throws IOException Any errors
- */
- public static void writeCalltree(PrintWriter out, Collection<Clazz> classes)
- throws Exception {
-
- final Map<Clazz.MethodDef, Set<Clazz.MethodDef>> using = new TreeMap<Clazz.MethodDef, Set<Clazz.MethodDef>>(COMPARATOR);
- final Map<Clazz.MethodDef, Set<Clazz.MethodDef>> usedby = new TreeMap<Clazz.MethodDef, Set<Clazz.MethodDef>>(COMPARATOR);
-
- ClassDataCollector cd = new ClassDataCollector() {
- Clazz.MethodDef source;
-
- // Before a method is parsed
- public void method(Clazz.MethodDef source) {
- this.source = source;
- xref(using, source, null);
- xref(usedby, source, null);
- }
-
- // For any reference in the previous method.
- public void reference(Clazz.MethodDef reference) {
- xref(using, source, reference);
- xref(usedby, reference, source);
- }
- };
- for (Clazz clazz : classes) {
- clazz.parseClassFileWithCollector(cd);
- }
-
- out.println("<calltree>");
- xref(out, "using", using);
- xref(out, "usedby", usedby);
- out.println("</calltree>");
- }
-
- /*
- * Add a new reference
- */
- static Comparator<Clazz.MethodDef> COMPARATOR = new Comparator<Clazz.MethodDef>() {
-
- public int compare(MethodDef a, MethodDef b) {
- int r =a.getName().compareTo(b.getName());
- return r != 0 ? r : a.getDescriptor().toString().compareTo(b.getDescriptor().toString());
+ /**
+ * The write method is called to write the resource. We just call the static
+ * method.
+ */
+ public void write(OutputStream out) throws Exception {
+ OutputStreamWriter osw = new OutputStreamWriter(out, Constants.DEFAULT_CHARSET);
+ PrintWriter pw = new PrintWriter(osw);
+ try {
+ writeCalltree(pw, classes);
}
- };
- private static void xref(
- Map<Clazz.MethodDef, Set<Clazz.MethodDef>> references,
- Clazz.MethodDef source, Clazz.MethodDef reference) {
- Set<Clazz.MethodDef> set = references.get(source);
- if (set == null)
- references.put(source, set=new TreeSet<Clazz.MethodDef>(COMPARATOR));
- if ( reference != null)
- set.add(reference);
- }
+ finally {
+ pw.flush();
+ }
+ }
- /*
- * Print out either using or usedby sets
- */
- private static void xref(PrintWriter out, String group,
- Map<Clazz.MethodDef, Set<Clazz.MethodDef>> references) {
- out.println(" <" + group + ">");
- for (Map.Entry<Clazz.MethodDef, Set<Clazz.MethodDef>> entry : references
- .entrySet()) {
- Clazz.MethodDef source = entry.getKey();
- Set<Clazz.MethodDef> refs = entry.getValue();
- method(out, "method", source, ">");
- for (Clazz.MethodDef ref : refs) {
- method(out, "ref", ref, "/>");
- }
- out.println(" </method>");
- }
- out.println(" </" + group + ">");
- }
+ /**
+ * Print the call tree in XML.
+ *
+ * @param out
+ * The output writer
+ * @param classes
+ * The set of classes
+ * @throws IOException
+ * Any errors
+ */
+ public static void writeCalltree(PrintWriter out, Collection<Clazz> classes) throws Exception {
- /*
- * Print out a method.
- */
- private static void method(PrintWriter out, String element,
- Clazz.MethodDef source, String closeElement) {
- out.println(" <" + element + " class='" + source.getContainingClass().getFQN() + "'"
- + getAccess(source.getAccess()) +
- ( source.isConstructor() ? "" : " name='" + source.getName() + "'") + " descriptor='" + source.getDescriptor() + "' pretty='"
- + source.toString() + "'" + closeElement);
- }
+ final Map<Clazz.MethodDef,Set<Clazz.MethodDef>> using = new TreeMap<Clazz.MethodDef,Set<Clazz.MethodDef>>(
+ COMPARATOR);
+ final Map<Clazz.MethodDef,Set<Clazz.MethodDef>> usedby = new TreeMap<Clazz.MethodDef,Set<Clazz.MethodDef>>(
+ COMPARATOR);
- private static String getAccess(int access) {
- StringBuilder sb = new StringBuilder();
- if ( Modifier.isPublic(access) )
- sb.append(" public='true'");
- if ( Modifier.isStatic(access) )
- sb.append(" static='true'");
- if ( Modifier.isProtected(access) )
- sb.append(" protected='true'");
- if ( Modifier.isInterface(access) )
- sb.append(" interface='true'");
-
- return sb.toString();
- }
+ ClassDataCollector cd = new ClassDataCollector() {
+ Clazz.MethodDef source;
+
+ // Before a method is parsed
+ public void method(Clazz.MethodDef source) {
+ this.source = source;
+ xref(using, source, null);
+ xref(usedby, source, null);
+ }
+
+ // For any reference in the previous method.
+ public void reference(Clazz.MethodDef reference) {
+ xref(using, source, reference);
+ xref(usedby, reference, source);
+ }
+ };
+ for (Clazz clazz : classes) {
+ clazz.parseClassFileWithCollector(cd);
+ }
+
+ out.println("<calltree>");
+ xref(out, "using", using);
+ xref(out, "usedby", usedby);
+ out.println("</calltree>");
+ }
+
+ /*
+ * Add a new reference
+ */
+ static Comparator<Clazz.MethodDef> COMPARATOR = new Comparator<Clazz.MethodDef>() {
+
+ public int compare(MethodDef a, MethodDef b) {
+ int r = a.getName().compareTo(b.getName());
+ return r != 0 ? r : a.getDescriptor().toString()
+ .compareTo(b.getDescriptor().toString());
+ }
+ };
+
+ private static void xref(Map<Clazz.MethodDef,Set<Clazz.MethodDef>> references, Clazz.MethodDef source,
+ Clazz.MethodDef reference) {
+ Set<Clazz.MethodDef> set = references.get(source);
+ if (set == null)
+ references.put(source, set = new TreeSet<Clazz.MethodDef>(COMPARATOR));
+ if (reference != null)
+ set.add(reference);
+ }
+
+ /*
+ * Print out either using or usedby sets
+ */
+ private static void xref(PrintWriter out, String group, Map<Clazz.MethodDef,Set<Clazz.MethodDef>> references) {
+ out.println(" <" + group + ">");
+ for (Map.Entry<Clazz.MethodDef,Set<Clazz.MethodDef>> entry : references.entrySet()) {
+ Clazz.MethodDef source = entry.getKey();
+ Set<Clazz.MethodDef> refs = entry.getValue();
+ method(out, "method", source, ">");
+ for (Clazz.MethodDef ref : refs) {
+ method(out, "ref", ref, "/>");
+ }
+ out.println(" </method>");
+ }
+ out.println(" </" + group + ">");
+ }
+
+ /*
+ * Print out a method.
+ */
+ private static void method(PrintWriter out, String element, Clazz.MethodDef source, String closeElement) {
+ out.println(" <" + element + " class='" + source.getContainingClass().getFQN() + "'"
+ + getAccess(source.getAccess()) + (source.isConstructor() ? "" : " name='" + source.getName() + "'")
+ + " descriptor='" + source.getDescriptor() + "' pretty='" + source.toString() + "'" + closeElement);
+ }
+
+ private static String getAccess(int access) {
+ StringBuilder sb = new StringBuilder();
+ if (Modifier.isPublic(access))
+ sb.append(" public='true'");
+ if (Modifier.isStatic(access))
+ sb.append(" static='true'");
+ if (Modifier.isProtected(access))
+ sb.append(" protected='true'");
+ if (Modifier.isInterface(access))
+ sb.append(" interface='true'");
+
+ return sb.toString();
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java b/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java
index 1a586b4..7c776b3 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/component/ComponentAnnotationReader.java
@@ -22,18 +22,20 @@
static Pattern ACTIVATEDESCRIPTOR = Pattern
.compile("\\(((Lorg/osgi/service/component/ComponentContext;)|(Lorg/osgi/framework/BundleContext;)|(Ljava/util/Map;))*\\)V");
static Pattern OLDACTIVATEDESCRIPTOR = Pattern
- .compile("\\(Lorg/osgi/service/component/ComponentContext;\\)V");
-
-
+ .compile("\\(Lorg/osgi/service/component/ComponentContext;\\)V");
+
static Pattern OLDBINDDESCRIPTOR = Pattern.compile("\\(L([^;]*);\\)V");
static Pattern REFERENCEBINDDESCRIPTOR = Pattern
.compile("\\(Lorg/osgi/framework/ServiceReference;\\)V");
static String[] ACTIVATE_ARGUMENTS = {
- "org.osgi.service.component.ComponentContext", "org.osgi.framework.BundleContext",
- Map.class.getName(), "org.osgi.framework.BundleContext" };
- static String[] OLD_ACTIVATE_ARGUMENTS = { "org.osgi.service.component.ComponentContext" };
-
+ "org.osgi.service.component.ComponentContext", "org.osgi.framework.BundleContext", Map.class.getName(),
+ "org.osgi.framework.BundleContext"
+ };
+ static String[] OLD_ACTIVATE_ARGUMENTS = {
+ "org.osgi.service.component.ComponentContext"
+ };
+
Reporter reporter = new Processor();
MethodDef method;
TypeRef className;
@@ -43,7 +45,7 @@
Set<String> optional = new HashSet<String>();
Set<String> dynamic = new HashSet<String>();
- Map<String, String> map = new TreeMap<String, String>();
+ Map<String,String> map = new TreeMap<String,String>();
Set<String> descriptors = new HashSet<String>();
List<String> properties = new ArrayList<String>();
String version = null;
@@ -62,11 +64,11 @@
return this.reporter;
}
- public static Map<String, String> getDefinition(Clazz c) throws Exception {
+ public static Map<String,String> getDefinition(Clazz c) throws Exception {
return getDefinition(c, new Processor());
}
- public static Map<String, String> getDefinition(Clazz c, Reporter reporter) throws Exception {
+ public static Map<String,String> getDefinition(Clazz c, Reporter reporter) throws Exception {
ComponentAnnotationReader r = new ComponentAnnotationReader(c);
r.setReporter(reporter);
c.parseClassFileWithCollector(r);
@@ -76,7 +78,7 @@
public void annotation(Annotation annotation) {
String fqn = annotation.getName().getFQN();
-
+
if (fqn.equals(Component.class.getName())) {
set(COMPONENT_NAME, annotation.get(Component.NAME), "<>");
set(COMPONENT_FACTORY, annotation.get(Component.FACTORY), false);
@@ -296,9 +298,8 @@
}
/**
- * Skip L and ; and replace / for . in an object descriptor.
- *
- * A string like Lcom/acme/Foo; becomes com.acme.Foo
+ * Skip L and ; and replace / for . in an object descriptor. A string like
+ * Lcom/acme/Foo; becomes com.acme.Foo
*
* @param string
* @return
@@ -315,15 +316,18 @@
return sb.toString();
}
- @Override public void classBegin(int access, TypeRef name) {
+ @Override
+ public void classBegin(int access, TypeRef name) {
className = name;
}
- @Override public void implementsInterfaces(TypeRef[] interfaces) {
+ @Override
+ public void implementsInterfaces(TypeRef[] interfaces) {
this.interfaces = interfaces;
}
- @Override public void method(Clazz.MethodDef method) {
+ @Override
+ public void method(Clazz.MethodDef method) {
this.method = method;
descriptors.add(method.getName());
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java b/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java
index 1e5989f..653c48d 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/component/ServiceComponent.java
@@ -26,7 +26,7 @@
ComponentMaker m = new ComponentMaker(analyzer);
- Map<String, Map<String, String>> l = m.doServiceComponent();
+ Map<String,Map<String,String>> l = m.doServiceComponent();
analyzer.setProperty(Constants.SERVICE_COMPONENT, Processor.printClauses(l));
@@ -50,21 +50,20 @@
* <li>An XML file reference</li>
* <li>A FQN/wildcard with a set of attributes</li>
* </ol>
- *
* An XML reference is immediately expanded, an FQN/wildcard is more
* complicated and is delegated to
* {@link #componentEntry(Map, String, Map)}.
*
* @throws Exception
*/
- Map<String, Map<String, String>> doServiceComponent() throws Exception {
- Map<String, Map<String, String>> serviceComponents = newMap();
+ Map<String,Map<String,String>> doServiceComponent() throws Exception {
+ Map<String,Map<String,String>> serviceComponents = newMap();
String header = getProperty(SERVICE_COMPONENT);
Parameters sc = parseHeader(header);
- for (Entry<String, Attrs> entry : sc.entrySet()) {
+ for (Entry<String,Attrs> entry : sc.entrySet()) {
String name = entry.getKey();
- Map<String, String> info = entry.getValue();
+ Map<String,String> info = entry.getValue();
try {
if (name.indexOf('/') >= 0 || name.endsWith(".xml")) {
@@ -73,7 +72,8 @@
} else {
componentEntry(serviceComponents, name, info);
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
e.printStackTrace();
error("Invalid Service-Component header: %s %s, throws %s", name, info, e);
}
@@ -89,17 +89,16 @@
* <li>A wildcard expression for finding annotated components.</li>
* </ol>
* The problem is the distinction between an FQN and a wildcard because
- * an FQN can also be used as a wildcard.
- *
- * If the info specifies {@link Constants#NOANNOTATIONS} then wildcards
- * are an error and the component must be fully described by the info.
- * Otherwise the FQN/wildcard is expanded into a list of classes with
- * annotations. If this list is empty, the FQN case is interpreted as a
- * complete component definition. For the wildcard case, it is checked
- * if any matching classes for the wildcard have been compiled for a
- * class file format that does not support annotations, this can be a
- * problem with JSR14 who silently ignores annotations. An error is
- * reported in such a case.
+ * an FQN can also be used as a wildcard. If the info specifies
+ * {@link Constants#NOANNOTATIONS} then wildcards are an error and the
+ * component must be fully described by the info. Otherwise the
+ * FQN/wildcard is expanded into a list of classes with annotations. If
+ * this list is empty, the FQN case is interpreted as a complete
+ * component definition. For the wildcard case, it is checked if any
+ * matching classes for the wildcard have been compiled for a class file
+ * format that does not support annotations, this can be a problem with
+ * JSR14 who silently ignores annotations. An error is reported in such
+ * a case.
*
* @param serviceComponents
* @param name
@@ -107,8 +106,8 @@
* @throws Exception
* @throws IOException
*/
- private void componentEntry(Map<String, Map<String, String>> serviceComponents,
- String name, Map<String, String> info) throws Exception, IOException {
+ private void componentEntry(Map<String,Map<String,String>> serviceComponents, String name,
+ Map<String,String> info) throws Exception, IOException {
boolean annotations = !Processor.isTrue(info.get(NOANNOTATIONS));
boolean fqn = Verifier.isFQN(name);
@@ -117,8 +116,8 @@
// Annotations possible!
- Collection<Clazz> annotatedComponents = analyzer.getClasses("",
- QUERY.ANNOTATED.toString(), Component.class.getName(), //
+ Collection<Clazz> annotatedComponents = analyzer.getClasses("", QUERY.ANNOTATED.toString(),
+ Component.class.getName(), //
QUERY.NAMED.toString(), name //
);
@@ -169,9 +168,9 @@
private Collection<Clazz> checkAnnotationsFeasible(String name) throws Exception {
Collection<Clazz> not = analyzer.getClasses("", QUERY.NAMED.toString(), name //
);
-
+
if (not.isEmpty())
- if ( "*".equals(name))
+ if ("*".equals(name))
return not;
else
error("Specified %s but could not find any class matching this pattern", name);
@@ -180,18 +179,17 @@
if (c.getFormat().hasAnnotations())
return not;
}
-
+
warning("Wildcards are used (%s) requiring annotations to decide what is a component. Wildcard maps to classes that are compiled with java.target < 1.5. Annotations were introduced in Java 1.5",
name);
-
+
return not;
}
- void annotated(Map<String, Map<String, String>> components, Clazz c,
- Map<String, String> info) throws Exception {
+ 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);
+ Map<String,String> map = ComponentAnnotationReader.getDefinition(c, this);
// Pick the name, the annotation can override
// the name.
@@ -202,16 +200,15 @@
// Override the component info without manifest
// entries. We merge the properties though.
- String merged = Processor.merge(info.remove(COMPONENT_PROPERTIES),
- map.remove(COMPONENT_PROPERTIES));
+ 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);
}
- private void createComponentResource(Map<String, Map<String, String>> components,
- String name, Map<String, String> info) throws IOException {
+ private void createComponentResource(Map<String,Map<String,String>> components, String name,
+ Map<String,String> info) throws IOException {
// We can override the name in the parameters
if (info.containsKey(COMPONENT_NAME))
@@ -264,9 +261,7 @@
analyzer.getJar().putResource(rname, r);
} else {
- analyzer.error(
- "Cannot find designated configuration class %s for component %s", c,
- name);
+ analyzer.error("Cannot find designated configuration class %s for component %s", c, name);
}
}
return true;
@@ -280,8 +275,7 @@
* @param info
* @throws UnsupportedEncodingException
*/
- Resource createComponentResource(String name, String impl, Map<String, String> info)
- throws IOException {
+ Resource createComponentResource(String name, String impl, Map<String,String> info) throws IOException {
String namespace = getNamespace(info);
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, Constants.DEFAULT_CHARSET));
@@ -295,8 +289,8 @@
doAttribute(pw, info.get(COMPONENT_FACTORY), "factory");
doAttribute(pw, info.get(COMPONENT_IMMEDIATE), "immediate", "false", "true");
doAttribute(pw, info.get(COMPONENT_ENABLED), "enabled", "true", "false");
- doAttribute(pw, info.get(COMPONENT_CONFIGURATION_POLICY), "configuration-policy",
- "optional", "require", "ignore");
+ doAttribute(pw, info.get(COMPONENT_CONFIGURATION_POLICY), "configuration-policy", "optional", "require",
+ "ignore");
doAttribute(pw, info.get(COMPONENT_ACTIVATE), "activate", JIDENTIFIER);
doAttribute(pw, info.get(COMPONENT_DEACTIVATE), "deactivate", JIDENTIFIER);
doAttribute(pw, info.get(COMPONENT_MODIFIED), "modified", JIDENTIFIER);
@@ -335,13 +329,12 @@
if (matches.length != 0) {
if (matches.length == 1 && matches[0].equals(JIDENTIFIER)) {
if (!Verifier.isIdentifier(value))
- error("Component attribute %s has value %s but is not a Java identifier",
- name, value);
+ error("Component attribute %s has value %s but is not a Java identifier", name, value);
} else {
if (!Verifier.isMember(value, matches))
- error("Component attribute %s has value %s but is not a member of %s",
- name, value, Arrays.toString(matches));
+ error("Component attribute %s has value %s but is not a member of %s", name, value,
+ Arrays.toString(matches));
}
}
pw.print(" ");
@@ -358,15 +351,15 @@
* @param info
* @return
*/
- private String getNamespace(Map<String, String> info) {
+ private String getNamespace(Map<String,String> info) {
String version = info.get(COMPONENT_VERSION);
if (version != null) {
try {
Version v = new Version(version);
return NAMESPACE_STEM + "/v" + v;
- } catch (Exception e) {
- error("version: specified on component header but not a valid version: "
- + version);
+ }
+ catch (Exception e) {
+ error("version: specified on component header but not a valid version: " + version);
return null;
}
}
@@ -384,7 +377,7 @@
* @param pw
* @param info
*/
- void properties(PrintWriter pw, Map<String, String> info) {
+ void properties(PrintWriter pw, Map<String,String> info) {
Collection<String> properties = split(info.get(COMPONENT_PROPERTIES));
for (Iterator<String> p = properties.iterator(); p.hasNext();) {
String clause = p.next();
@@ -468,21 +461,20 @@
* @param pw
*/
- void reference(Map<String, String> info, PrintWriter pw) {
+ void reference(Map<String,String> info, PrintWriter pw) {
Collection<String> dynamic = new ArrayList<String>(split(info.get(COMPONENT_DYNAMIC)));
Collection<String> optional = new ArrayList<String>(split(info.get(COMPONENT_OPTIONAL)));
Collection<String> multiple = new ArrayList<String>(split(info.get(COMPONENT_MULTIPLE)));
Collection<String> descriptors = split(info.get(COMPONENT_DESCRIPTORS));
- for (Map.Entry<String, String> entry : info.entrySet()) {
+ for (Map.Entry<String,String> entry : info.entrySet()) {
// Skip directives
String referenceName = entry.getKey();
if (referenceName.endsWith(":")) {
if (!SET_COMPONENT_DIRECTIVES.contains(referenceName))
- error("Unrecognized directive in Service-Component header: "
- + referenceName);
+ error("Unrecognized directive in Service-Component header: " + referenceName);
continue;
}
@@ -508,15 +500,14 @@
}
} else if (Character.isLowerCase(referenceName.charAt(0))) {
unbindCalculated = true;
- bind = "set" + Character.toUpperCase(referenceName.charAt(0))
- + referenceName.substring(1);
+ bind = "set" + Character.toUpperCase(referenceName.charAt(0)) + referenceName.substring(1);
unbind = "un" + bind;
}
String interfaceName = entry.getValue();
if (interfaceName == null || interfaceName.length() == 0) {
- error("Invalid Interface Name for references in Service Component: "
- + referenceName + "=" + interfaceName);
+ error("Invalid Interface Name for references in Service Component: " + referenceName + "="
+ + interfaceName);
continue;
}
@@ -603,21 +594,21 @@
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
- case '<':
- sb.append("<");
- break;
- case '>':
- sb.append(">");
- break;
- case '&':
- sb.append("&");
- break;
- case '\'':
- sb.append(""");
- break;
- default:
- sb.append(c);
- break;
+ case '<' :
+ sb.append("<");
+ break;
+ case '>' :
+ sb.append(">");
+ break;
+ case '&' :
+ sb.append("&");
+ break;
+ case '\'' :
+ sb.append(""");
+ break;
+ default :
+ sb.append(c);
+ break;
}
}
return sb.toString();
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java b/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java
index 020b85a..024b5fe 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/coverage/Coverage.java
@@ -11,89 +11,84 @@
* This class can create a coverage table between two classspaces. The
* destination class space is used to create a table of methods. All source
* methods that refer to a specific dest are then filled into the table.
- *
*/
public class Coverage {
- /**
- * Create a cross reference table from source to dest.
- *
- * @param source
- * The methods that refer to dest
- * @param dest
- * The methods that are being referred to
- * @return A mapping of source methods to destination methods.
- * @throws IOException
- */
- public static Map<MethodDef, List<MethodDef>> getCrossRef(
- Collection<Clazz> source, Collection<Clazz> dest)
- throws Exception {
- final Map<MethodDef, List<MethodDef>> catalog = buildCatalog(dest);
- crossRef(source, catalog);
- return catalog;
- }
+ /**
+ * Create a cross reference table from source to dest.
+ *
+ * @param source
+ * The methods that refer to dest
+ * @param dest
+ * The methods that are being referred to
+ * @return A mapping of source methods to destination methods.
+ * @throws IOException
+ */
+ public static Map<MethodDef,List<MethodDef>> getCrossRef(Collection<Clazz> source, Collection<Clazz> dest)
+ throws Exception {
+ final Map<MethodDef,List<MethodDef>> catalog = buildCatalog(dest);
+ crossRef(source, catalog);
+ return catalog;
+ }
- private static void crossRef(Collection<Clazz> source,
- final Map<MethodDef, List<MethodDef>> catalog) throws Exception {
- for (final Clazz clazz : source) {
- clazz.parseClassFileWithCollector(new ClassDataCollector() {
- MethodDef source;
+ private static void crossRef(Collection<Clazz> source, final Map<MethodDef,List<MethodDef>> catalog)
+ throws Exception {
+ for (final Clazz clazz : source) {
+ clazz.parseClassFileWithCollector(new ClassDataCollector() {
+ MethodDef source;
- public void implementsInterfaces(TypeRef names[]) {
- MethodDef def = clazz.getMethodDef(0,
- "<implements>", "()V");
- // TODO
- for (TypeRef interfaceName : names) {
- for (Map.Entry<MethodDef, List<MethodDef>> entry : catalog
- .entrySet()) {
- String catalogClass = entry.getKey().getContainingClass().getFQN();
- List<MethodDef> references = entry.getValue();
+ public void implementsInterfaces(TypeRef names[]) {
+ MethodDef def = clazz.getMethodDef(0, "<implements>", "()V");
+ // TODO
+ for (TypeRef interfaceName : names) {
+ for (Map.Entry<MethodDef,List<MethodDef>> entry : catalog.entrySet()) {
+ String catalogClass = entry.getKey().getContainingClass().getFQN();
+ List<MethodDef> references = entry.getValue();
- if (catalogClass.equals(interfaceName.getFQN())) {
- references.add(def);
- }
- }
- }
- }
+ if (catalogClass.equals(interfaceName.getFQN())) {
+ references.add(def);
+ }
+ }
+ }
+ }
- // Method definitions
- public void method(MethodDef source) {
- this.source = source;
- }
+ // Method definitions
+ public void method(MethodDef source) {
+ this.source = source;
+ }
- public void reference(MethodDef reference) {
- List<MethodDef> references = catalog.get(reference);
- if (references != null) {
- references.add(source);
- }
- }
- });
- }
- }
+ public void reference(MethodDef reference) {
+ List<MethodDef> references = catalog.get(reference);
+ if (references != null) {
+ references.add(source);
+ }
+ }
+ });
+ }
+ }
- private static Map<MethodDef, List<MethodDef>> buildCatalog(
- Collection<Clazz> sources) throws Exception {
- final Map<MethodDef, List<MethodDef>> catalog = new TreeMap<MethodDef, List<MethodDef>>(new Comparator<MethodDef>() {
- public int compare(MethodDef a, MethodDef b) {
- return a.getName().compareTo(b.getName());
- }
- });
- for (final Clazz clazz : sources) {
- clazz.parseClassFileWithCollector(new ClassDataCollector() {
+ private static Map<MethodDef,List<MethodDef>> buildCatalog(Collection<Clazz> sources) throws Exception {
+ final Map<MethodDef,List<MethodDef>> catalog = new TreeMap<MethodDef,List<MethodDef>>(
+ new Comparator<MethodDef>() {
+ public int compare(MethodDef a, MethodDef b) {
+ return a.getName().compareTo(b.getName());
+ }
+ });
+ for (final Clazz clazz : sources) {
+ clazz.parseClassFileWithCollector(new ClassDataCollector() {
- public boolean classStart(int access, TypeRef name) {
- return clazz.isPublic();
- }
+ public boolean classStart(int access, TypeRef name) {
+ return clazz.isPublic();
+ }
- public void method(MethodDef source) {
- if (source.isPublic()
- || source.isProtected())
- catalog.put(source, new ArrayList<MethodDef>());
- }
+ public void method(MethodDef source) {
+ if (source.isPublic() || source.isProtected())
+ catalog.put(source, new ArrayList<MethodDef>());
+ }
- });
- }
- return catalog;
- }
+ });
+ }
+ return catalog;
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/coverage/CoverageResource.java b/bundleplugin/src/main/java/aQute/bnd/make/coverage/CoverageResource.java
index d879e53..0a1b8ab 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/coverage/CoverageResource.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/coverage/CoverageResource.java
@@ -12,80 +12,78 @@
/**
* Creates an XML Coverage report. This class can be used as a resource so the
* report is created only when the JAR is written.
- *
*/
public class CoverageResource extends WriteResource {
- Collection<Clazz> testsuite;
- Collection<Clazz> service;
+ Collection<Clazz> testsuite;
+ Collection<Clazz> service;
- public CoverageResource(Collection<Clazz> testsuite,
- Collection<Clazz> service) {
- this.testsuite = testsuite;
- this.service = service;
- }
+ public CoverageResource(Collection<Clazz> testsuite, Collection<Clazz> service) {
+ this.testsuite = testsuite;
+ this.service = service;
+ }
- @Override
- public long lastModified() {
- return 0;
- }
+ @Override
+ public long lastModified() {
+ return 0;
+ }
- @Override
- public void write(OutputStream out) throws IOException {
- try {
- Map<MethodDef, List<MethodDef>> table = getCrossRef(testsuite,
- service);
- Tag coverage = toTag(table);
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(out,
- Constants.DEFAULT_CHARSET));
- try {
- coverage.print(0, pw);
- } finally {
- pw.flush();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ @Override
+ public void write(OutputStream out) throws IOException {
+ try {
+ Map<MethodDef,List<MethodDef>> table = getCrossRef(testsuite, service);
+ Tag coverage = toTag(table);
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, Constants.DEFAULT_CHARSET));
+ try {
+ coverage.print(0, pw);
+ }
+ finally {
+ pw.flush();
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- public static Tag toTag(Map<MethodDef, List<MethodDef>> catalog) {
- Tag coverage = new Tag("coverage");
- String currentClass = null;
- Tag classTag = null;
+ public static Tag toTag(Map<MethodDef,List<MethodDef>> catalog) {
+ Tag coverage = new Tag("coverage");
+ String currentClass = null;
+ Tag classTag = null;
- for (Map.Entry<MethodDef, List<MethodDef>> m : catalog.entrySet()) {
- String className = m.getKey().getContainingClass().getFQN();
- if (!className.equals(currentClass)) {
- classTag = new Tag("class");
- classTag.addAttribute("name", className);
- classTag.addAttribute("package", Descriptors.getPackage(className));
- classTag.addAttribute("short", Descriptors.getShortName(className));
- coverage.addContent(classTag);
- currentClass = className;
- }
- Tag method = doMethod(new Tag("method"), m.getKey());
- classTag.addContent(method);
- for (MethodDef r : m.getValue()) {
- Tag ref = doMethod(new Tag("ref"), r);
- method.addContent(ref);
- }
- }
- return coverage;
- }
+ for (Map.Entry<MethodDef,List<MethodDef>> m : catalog.entrySet()) {
+ String className = m.getKey().getContainingClass().getFQN();
+ if (!className.equals(currentClass)) {
+ classTag = new Tag("class");
+ classTag.addAttribute("name", className);
+ classTag.addAttribute("package", Descriptors.getPackage(className));
+ classTag.addAttribute("short", Descriptors.getShortName(className));
+ coverage.addContent(classTag);
+ currentClass = className;
+ }
+ Tag method = doMethod(new Tag("method"), m.getKey());
+ classTag.addContent(method);
+ for (MethodDef r : m.getValue()) {
+ Tag ref = doMethod(new Tag("ref"), r);
+ method.addContent(ref);
+ }
+ }
+ return coverage;
+ }
- private static Tag doMethod(Tag tag, MethodDef method) {
- tag.addAttribute("pretty", method.toString());
- if (method.isPublic())
- tag.addAttribute("public", true);
- if (method.isStatic())
- tag.addAttribute("static", true);
- if (method.isProtected())
- tag.addAttribute("protected", true);
- if (method.isInterface())
- tag.addAttribute("interface", true);
- tag.addAttribute("constructor", method.isConstructor());
- if (!method.isConstructor())
- tag.addAttribute("name", method.getName());
- tag.addAttribute("descriptor", method.getDescriptor());
- return tag;
- }
+ private static Tag doMethod(Tag tag, MethodDef method) {
+ tag.addAttribute("pretty", method.toString());
+ if (method.isPublic())
+ tag.addAttribute("public", true);
+ if (method.isStatic())
+ tag.addAttribute("static", true);
+ if (method.isProtected())
+ tag.addAttribute("protected", true);
+ if (method.isInterface())
+ tag.addAttribute("interface", true);
+ tag.addAttribute("constructor", method.isConstructor());
+ if (!method.isConstructor())
+ tag.addAttribute("name", method.getName());
+ tag.addAttribute("descriptor", method.getDescriptor());
+ return tag;
+ }
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java b/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java
index ae541d6..beb1a36 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetaTypeReader.java
@@ -12,33 +12,34 @@
import aQute.libg.generics.*;
public class MetaTypeReader extends WriteResource {
- final Analyzer reporter;
- Clazz clazz;
- String interfaces[];
- Tag metadata = new Tag("metatype:MetaData", new String[] {
- "xmlns:metatype", "http://www.osgi.org/xmlns/metatype/v1.1.0" });
- Tag ocd = new Tag(metadata, "OCD");
- Tag designate = new Tag(metadata, "Designate");
- Tag object = new Tag(designate, "Object");
+ final Analyzer reporter;
+ Clazz clazz;
+ String interfaces[];
+ Tag metadata = new Tag("metatype:MetaData", new String[] {
+ "xmlns:metatype", "http://www.osgi.org/xmlns/metatype/v1.1.0"
+ });
+ Tag ocd = new Tag(metadata, "OCD");
+ Tag designate = new Tag(metadata, "Designate");
+ Tag object = new Tag(designate, "Object");
// Resource
- String extra;
+ String extra;
// One time init
- boolean finished;
+ boolean finished;
// Designate
- boolean override;
- String designatePid;
- boolean factory;
+ boolean override;
+ String designatePid;
+ boolean factory;
// AD
- Map<MethodDef, Meta.AD> methods = new LinkedHashMap<MethodDef, Meta.AD>();
+ Map<MethodDef,Meta.AD> methods = new LinkedHashMap<MethodDef,Meta.AD>();
// OCD
- Annotation ocdAnnotation;
+ Annotation ocdAnnotation;
- MethodDef method;
+ MethodDef method;
public MetaTypeReader(Clazz clazz, Analyzer reporter) {
this.clazz = clazz;
@@ -58,13 +59,12 @@
* @param optionValues
*/
- static Pattern COLLECTION = Pattern
- .compile("(.*(Collection|Set|List|Queue|Stack|Deque))<(L.+;)>");
+ static Pattern COLLECTION = Pattern.compile("(.*(Collection|Set|List|Queue|Stack|Deque))<(L.+;)>");
private void addMethod(MethodDef method, Meta.AD ad) throws Exception {
// Set all the defaults.
-
+
String rtype = method.getGenericReturnType();
String id = Configurable.mangleMethodName(method.getName());
String name = Clazz.unCamel(id);
@@ -88,8 +88,8 @@
}
Meta.Type type = getType(rtype);
-
- boolean required = ad ==null || ad.required();
+
+ boolean required = ad == null || ad.required();
String deflt = null;
String max = null;
String min = null;
@@ -114,15 +114,15 @@
cardinality = ad.cardinality();
if (ad.type() != null)
type = ad.type();
-// if (ad.required() || ad.deflt() == null)
-// required = true;
+ // if (ad.required() || ad.deflt() == null)
+ // required = true;
if (ad.description() != null)
description = ad.description();
if (ad.optionLabels() != null)
optionLabels = ad.optionLabels();
- if (ad.optionValues() != null )
+ if (ad.optionValues() != null)
optionValues = ad.optionValues();
if (ad.min() != null)
@@ -208,13 +208,15 @@
}
class Find extends ClassDataCollector {
-
- @Override public void method(MethodDef mdef) {
+
+ @Override
+ public void method(MethodDef mdef) {
method = mdef;
methods.put(mdef, null);
}
-
- @Override public void annotation(Annotation annotation) {
+
+ @Override
+ public void annotation(Annotation annotation) {
try {
Meta.OCD ocd = annotation.getAnnotation(Meta.OCD.class);
Meta.AD ad = annotation.getAnnotation(Meta.AD.class);
@@ -225,20 +227,20 @@
assert method != null;
methods.put(method, ad);
}
- } catch (Exception e) {
+ }
+ catch (Exception e) {
reporter.error("Error during annotation parsing %s : %s", clazz, e);
e.printStackTrace();
}
}
}
-
-
public void write(OutputStream out) throws IOException {
try {
finish();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new RuntimeException(e);
}
PrintWriter pw = new PrintWriter(new OutputStreamWriter(out, "UTF-8"));
@@ -255,8 +257,7 @@
if (this.ocdAnnotation != null)
ocd = this.ocdAnnotation.getAnnotation(Meta.OCD.class);
else
- ocd = Configurable.createConfigurable(Meta.OCD.class,
- new HashMap<String, Object>());
+ ocd = Configurable.createConfigurable(Meta.OCD.class, new HashMap<String,Object>());
// defaults
String id = clazz.getClassName().getFQN();
@@ -268,7 +269,6 @@
if (ocd.id() != null)
id = ocd.id();
-
if (ocd.name() != null)
name = ocd.name();
@@ -295,7 +295,7 @@
this.ocd.addAttribute("localization", localization);
// do ADs
- for (Map.Entry<MethodDef, Meta.AD> entry : methods.entrySet())
+ for (Map.Entry<MethodDef,Meta.AD> entry : methods.entrySet())
addMethod(entry.getKey(), entry.getValue());
this.designate.addAttribute("pid", pid);
@@ -313,7 +313,8 @@
this.designatePid = pid;
}
- @Override public long lastModified() {
+ @Override
+ public long lastModified() {
return 0;
}
}
diff --git a/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetatypePlugin.java b/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetatypePlugin.java
index ff43613..c6218a1 100644
--- a/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetatypePlugin.java
+++ b/bundleplugin/src/main/java/aQute/bnd/make/metatype/MetatypePlugin.java
@@ -9,26 +9,23 @@
import aQute.libg.header.*;
/**
- * This class is responsible for meta type types. It is a plugin that can
+ * This class is responsible for meta type types. It is a plugin that can
+ *
* @author aqute
- *
*/
public class MetatypePlugin implements AnalyzerPlugin {
public boolean analyzeJar(Analyzer analyzer) throws Exception {
- Parameters map = analyzer.parseHeader(analyzer
- .getProperty(Constants.METATYPE));
+ 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(), //
+ 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));
+ jar.putResource("OSGI-INF/metatype/" + c.getFQN() + ".xml", new MetaTypeReader(c, analyzer));
}
}
return false;