Changes the 'interface' attribute of the service dependency handler to be 'specification'. This change remove a differentiation between service dependencies description. The 'interface' attribute stills supported but becomes deprecated.
The Core XML-Schema is modified according to this change.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@695456 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
index 93b3a6c..61cbc6a 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
@@ -314,7 +314,15 @@
for (int i = 0; deps != null && i < deps.length; i++) {
// Create the dependency metadata
String field = deps[i].getAttribute("field");
+
String serviceSpecification = deps[i].getAttribute("interface");
+ // the 'interface' attribute is deprecated
+ if (serviceSpecification != null) {
+ warn("The 'interface' attribute is deprecated, use the 'specification' attribute instead");
+ } else {
+ serviceSpecification = deps[i].getAttribute("specification");
+ }
+
String filter = deps[i].getAttribute("filter");
String opt = deps[i].getAttribute("optional");
boolean optional = opt != null && opt.equalsIgnoreCase("true");
@@ -426,26 +434,6 @@
}
}
-// /**
-// * GetterCallback Method.
-// * @param pojo : the pojo object on which the field is accessed
-// * @param fieldName : the field name.
-// * @param value : the value passed to the field (by the previous handler).
-// * @return the object that the dependency handler want to push.
-// * @see org.apache.felix.ipojo.Handler#onGet(Object, java.lang.String, java.lang.Object)
-// */
-// public Object onGet(Object pojo, String fieldName, Object value) {
-// for (int i = 0; i < m_dependencies.length; i++) {
-// Dependency dep = m_dependencies[i];
-// if (fieldName.equals(dep.getField())) {
-// // The field name is a dependency, return the get
-// return dep.get();
-// }
-// }
-// // Else return the value
-// return value;
-// }
-
/**
* Handler start method.
* @see org.apache.felix.ipojo.Handler#start()
diff --git a/ipojo/core/src/main/resources/core.xsd b/ipojo/core/src/main/resources/core.xsd
index fd3c636..fdba2ad 100644
--- a/ipojo/core/src/main/resources/core.xsd
+++ b/ipojo/core/src/main/resources/core.xsd
@@ -249,6 +249,7 @@
</xs:complexType>
<xs:complexType name="ServiceDependencyType">
+ <xs:attribute name="specification" type="xs:string" use="optional"/>
<xs:attribute name="optional" type="xs:boolean" use="optional">
</xs:attribute>
<xs:attribute name="aggregate" type="xs:boolean" use="optional">
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 3a12ea3..bf28d42 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
@@ -279,7 +279,7 @@
// Add the complete requires
req = new Element("requires", "");
if (m_specification != null) {
- req.addAttribute(new Attribute("interface", m_specification));
+ req.addAttribute(new Attribute("specification", m_specification));
}
if (m_aggregate != null) {
req.addAttribute(new Attribute("aggregate", m_aggregate));
@@ -303,7 +303,7 @@
req.addAttribute(new Attribute("from", m_from));
}
} else {
- String itf = req.getAttribute("interface");
+ String itf = req.getAttribute("specification");
String aggregate = req.getAttribute("aggregate");
String optional = req.getAttribute("optional");
String filter = req.getAttribute("filter");
@@ -312,7 +312,7 @@
String from = req.getAttribute("from");
if (m_specification != null) {
if (itf == null) {
- req.addAttribute(new Attribute("interface", m_specification));
+ req.addAttribute(new Attribute("specification", m_specification));
} else if (! m_specification.equals(itf)) {
System.err.println("The required specification is not the same than previouly : " + m_specification + " & " + itf);
return;
diff --git a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
index 0ce8f51..6defc2f 100644
--- a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
@@ -74,7 +74,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
name="MRefCheckServiceProvider" architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService">
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
</requires>
@@ -189,7 +189,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
name="MRefOptionalCheckServiceProvider" architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
optional="true">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
@@ -200,7 +200,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
name="MBothOptionalCheckServiceProvider" architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
optional="true">
<callback type="bind" method="bothBind" />
<callback type="unbind" method="bothUnbind" />
@@ -271,7 +271,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
name="DIMRefOptionalCheckServiceProvider" architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
optional="true"
default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
<callback type="bind" method="refBind" />
@@ -283,7 +283,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
name="DIMBothOptionalCheckServiceProvider" architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
optional="true"
default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
<callback type="bind" method="bothBind" />
@@ -348,7 +348,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
name="MRefMultipleCheckServiceProvider" architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
aggregate="true">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
@@ -418,7 +418,7 @@
name="MRefOptionalMultipleCheckServiceProvider"
architecture="true">
<requires
- interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
aggregate="true" optional="true">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
@@ -430,14 +430,14 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
name="SimpleListCheckServiceProvider" architecture="true">
- <requires field="fs" interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
name="OptionalListCheckServiceProvider"
architecture="true">
- <requires interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
<provides />
</component>
@@ -455,7 +455,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.VectorCheckService"
name="OptionalVectorCheckServiceProvider"
architecture="true">
- <requires interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
<provides />
</component>
@@ -463,14 +463,14 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
name="SimpleSetCheckServiceProvider" architecture="true">
- <requires field="fs" interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
name="OptionalSetCheckServiceProvider"
architecture="true">
- <requires interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
<provides />
</component>
@@ -478,14 +478,14 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
name="SimpleCollectionCheckServiceProvider" architecture="true">
- <requires field="fs" interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
name="OptionalCollectionCheckServiceProvider"
architecture="true">
- <requires interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
<provides />
</component>