Update annotations to add latest added feature on dependency management
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@652175 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Bind.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Bind.java
index aeef012..9179258 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Bind.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Bind.java
@@ -20,6 +20,7 @@
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
+import java.util.Comparator;
/**
* This annotation declares a bind method.
@@ -64,5 +65,11 @@
* Default: dynamic.
*/
String policy() default "dynamic";
+
+ /**
+ * Set the comparator.
+ * The indicated class must implement {@link Comparator}
+ */
+ Class comparator() default Comparator.class;
}
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java
index 15794ef..e69836c 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java
@@ -20,6 +20,7 @@
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
+import java.util.Comparator;
/**
* This annotation declares a service requirement.
@@ -55,9 +56,10 @@
/**
* Set the default-implementation to use if the dependency is optional,
* and no providers are available.
+ * The class must implement the required service interface.
* Default : no default-implementation
*/
- String defaultimplementation() default "";
+ Class defaultimplementation() default Class.class;
/**
* Set the binding policy.
@@ -65,4 +67,10 @@
* Default: dynamic.
*/
String policy() default "dynamic";
+
+ /**
+ * Set the comparator.
+ * The indicated class must implement {@link Comparator}
+ */
+ Class comparator() default Comparator.class;
}
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java
index 711b52f..b178938 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java
@@ -20,6 +20,7 @@
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
+import java.util.Comparator;
/**
* This annotation declares an unbind method.
@@ -65,5 +66,11 @@
* Default: dynamic.
*/
String policy() default "dynamic";
+
+ /**
+ * Set the comparator.
+ * The indicated class must implement {@link Comparator}
+ */
+ Class comparator() default Comparator.class;
}
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
index fad5a30..bd47ef5 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
@@ -557,7 +557,7 @@
// Check type if not already set
if (type == null) {
if (field == null) {
- throw new ConfigurationException("The property " + name + " has neither type neither field.");
+ throw new ConfigurationException("The property " + name + " has neither type nor field.");
}
FieldMetadata fieldMeta = manipulation.getField(field);
if (fieldMeta == null) {
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
index 38b9a8b..ee78e6a 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
@@ -32,7 +32,7 @@
/**
* Abstract dependency model. This class is the parent class of every service dependency. It manages the most part of dependency management. This
- * class creates an insterface between the service tracker and the concrete dependency.
+ * class creates an interface between the service tracker and the concrete dependency.
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public abstract class DependencyModel implements TrackerCustomizer {
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
index 408b40a..6c30f03 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
@@ -22,6 +22,7 @@
import org.apache.felix.ipojo.metadata.Element;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Type;
import org.objectweb.asm.commons.EmptyVisitor;
/**
@@ -151,6 +152,11 @@
private String m_nullable;
/**
+ * Comparator.
+ */
+ private String m_comparator;
+
+ /**
* Constructor.
* @param name : field name.
*/
@@ -182,7 +188,8 @@
return;
}
if (arg0.equals("defaultimplementation")) {
- m_defaultImplementation = arg1.toString();
+ Type type = Type.getType(arg1.toString());
+ m_defaultImplementation = type.getClassName();
return;
}
if (arg0.equals("specification")) {
@@ -193,6 +200,11 @@
m_id = arg1.toString();
return;
}
+ if (arg0.equals("comparator")) {
+ Type type = Type.getType(arg1.toString());
+ m_comparator = type.getClassName();
+ return;
+ }
}
/**
@@ -237,6 +249,9 @@
if (m_id != null) {
req.addAttribute(new Attribute("id", m_id));
}
+ if (m_comparator != null) {
+ req.addAttribute(new Attribute("comparator", m_comparator));
+ }
if (m_id != null) {
m_collector.getIds().put(m_id, req);
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
index 0b36062..0f751f6 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
@@ -21,6 +21,7 @@
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
import org.objectweb.asm.commons.EmptyVisitor;
/**
@@ -192,6 +193,11 @@
* Binding policy.
*/
private String m_policy;
+
+ /**
+ * Comparator.
+ */
+ private String m_comparator;
/**
* Constructor.
@@ -234,6 +240,12 @@
m_id = arg1.toString();
return;
}
+ if (arg0.equals("comparator")) {
+ Type type = Type.getType(arg1.toString());
+ m_comparator = type.getClassName();
+ return;
+ }
+
}
/**
@@ -275,6 +287,71 @@
if (m_id != null) {
req.addAttribute(new Attribute("id", m_id));
}
+ if (m_comparator != null) {
+ req.addAttribute(new Attribute("comparator", m_comparator));
+ }
+ } else {
+ String itf = req.getAttribute("interface");
+ String aggregate = req.getAttribute("aggregate");
+ String optional = req.getAttribute("optional");
+ String filter = req.getAttribute("filter");
+ String policy = req.getAttribute("policy");
+ String comparator = req.getAttribute("comparator");
+
+ if (m_specification != null) {
+ if (itf == null) {
+ req.addAttribute(new Attribute("interface", m_specification));
+ } else if (! m_specification.equals(itf)) {
+ System.err.println("The required specification is not the same than previouly : " + m_specification + " & " + itf);
+ return;
+ }
+ }
+
+ if (m_optional != null) {
+ if (optional == null) {
+ req.addAttribute(new Attribute("optional", m_optional));
+ } else if (! m_optional.equals(optional)) {
+ System.err.println("The optional attribute is not always the same");
+ return;
+ }
+ }
+
+ if (m_aggregate != null) {
+ if (aggregate == null) {
+ req.addAttribute(new Attribute("aggregate", m_aggregate));
+ } else if (! m_aggregate.equals(aggregate)) {
+ System.err.println("The aggregate attribute is not always the same");
+ return;
+ }
+ }
+
+ if (m_filter != null) {
+ if (filter == null) {
+ req.addAttribute(new Attribute("filter", m_filter));
+ } else if (! m_filter.equals(filter)) {
+ System.err.println("The filter attribute is not always the same");
+ return;
+ }
+ }
+
+ if (m_policy != null) {
+ if (policy == null) {
+ req.addAttribute(new Attribute("policy", m_policy));
+ } else if (! m_policy.equals(policy)) {
+ System.err.println("The policy attribute is not always the same");
+ return;
+ }
+ }
+
+ if (m_comparator != null) {
+ if (comparator == null) {
+ req.addAttribute(new Attribute("comparator", m_comparator));
+ } else if (! m_comparator.equals(policy)) {
+ System.err.println("The comparator attribute is not always the same");
+ return;
+ }
+ }
+
}
Element method = new Element("callback", "");
method.addAttribute(new Attribute("method", m_name));