Fix the issue Felix-603. Allow arch to display all the available information on a service dependency such as the state, the binding-policy, the comparator ...
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@666698 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/pom.xml b/ipojo/core/pom.xml
index b8eaedb..420bd82 100644
--- a/ipojo/core/pom.xml
+++ b/ipojo/core/pom.xml
@@ -64,6 +64,9 @@
<Bundle-Vendor>
The Apache Software Foundation
</Bundle-Vendor>
+ <Bundle-SymbolicName>
+ org.apache.felix.ipojo
+ </Bundle-SymbolicName>
<Bundle-Description>
iPOJO Core Framework
</Bundle-Description>
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
index dcb7271..9020820 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
@@ -519,5 +519,17 @@
}
}
}
+
+ /**
+ * Gets true if the dependency use Nullable objects.
+ * @return true if the dependency is optional and supports nullable objects.
+ */
+ public boolean supportsNullable() {
+ return m_supportNullable;
+ }
+
+ public String getDefaultImplementation() {
+ return m_di;
+ }
}
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
index 6c09bd5..ae5aa33 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
@@ -43,6 +43,21 @@
* Optional ?
*/
private boolean m_optional;
+
+ /**
+ * Binding policy.
+ */
+ private int m_bindingPolicy;
+
+ /**
+ * Does the dependency use a nullable object?
+ */
+ private boolean m_useNullable;
+
+ /**
+ * Does the dependency use a default-implementation?
+ */
+ private String m_defaultImplementation;
/**
* State (VALID | INVALID).
@@ -53,6 +68,17 @@
* Filter.
*/
private String m_filter;
+
+ /**
+ * Is the provider set frozen ?
+ */
+ private boolean m_isFrozen;
+
+ /**
+ * Comparator used by the dependency.
+ * Null means OSGi default comparator.
+ */
+ private String m_comparator;
/**
* Set[service reference] of the used service.
@@ -70,15 +96,25 @@
* @param multiple : is the dependency a multiple dependency ?
* @param optional : is the dependency optional ?
* @param filter : the filter
+ * @param policy : binding policy
+ * @param nullable : does the dependency support nullable object
+ * @param defaultImpl : does the dependency use a default implementation
+ * @param comparator : does the dependency use a special comparator
+ * @param frozen : is the provider set frozen
* @param state : the state
*/
- public DependencyDescription(String itf, boolean multiple, boolean optional, String filter, int state) {
+ public DependencyDescription(String itf, boolean multiple, boolean optional, String filter, int policy, boolean nullable, String defaultImpl, String comparator, boolean frozen, int state) {
super();
m_interface = itf;
m_multiple = multiple;
m_optional = optional;
m_filter = filter;
m_state = state;
+ m_bindingPolicy = policy;
+ m_useNullable = nullable;
+ m_defaultImplementation = defaultImpl;
+ m_comparator = comparator;
+ m_isFrozen = frozen;
}
public boolean isMultiple() { return m_multiple; }
@@ -90,6 +126,20 @@
public String getInterface() { return m_interface; }
public int getState() { return m_state; }
+
+ /**
+ * Gets true if the dependency uses Nullable objects.
+ * @return true if the dependency is optional and supports nullable object.
+ */
+ public boolean supportsNullable() { return m_useNullable; }
+
+ public String getDefaultImplementation() { return m_defaultImplementation; }
+
+ public int getPolicy() { return m_bindingPolicy; }
+
+ public String getComparator() { return m_comparator; }
+
+ public boolean isFrozen() { return m_isFrozen; }
/**
* Get the service reference list.
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 fe50970..ed08ba3 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
@@ -434,7 +434,7 @@
Dependency dep = getDependencies()[j];
// Create & add the dependency description
DependencyDescription desc =
- new DependencyDescription(dep.getSpecification().getName(), dep.isAggregate(), dep.isOptional(), dep.getFilter(), dep.getState());
+ new DependencyDescription(dep.getSpecification().getName(), dep.isAggregate(), dep.isOptional(), dep.getFilter(), dep.getBindingPolicy(), dep.supportsNullable(), dep.getDefaultImplementation(), dep.getComparator(), dep.isFrozen(), dep.getState());
desc.setServiceReferences(dep.getServiceReferencesAsList());
desc.setUsedServices(dep.getUsedServiceReferences());
dhd.addDependency(desc);
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
index aaf5baa..79e8f70 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
@@ -25,6 +25,7 @@
import org.apache.felix.ipojo.architecture.HandlerDescription;
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.util.DependencyModel;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
@@ -85,10 +86,10 @@
Element deps = super.getHandlerInfo();
for (int i = 0; i < m_dependencies.length; i++) {
String state = "resolved";
- if (m_dependencies[i].getState() == 2) {
+ if (m_dependencies[i].getState() == DependencyModel.UNRESOLVED) {
state = "unresolved";
}
- if (m_dependencies[i].getState() == 3) {
+ if (m_dependencies[i].getState() == DependencyModel.BROKEN) {
state = "broken";
}
Element dep = new Element("Requires", "");
@@ -100,6 +101,12 @@
if (m_dependencies[i].isOptional()) {
dep.addAttribute(new Attribute("Optional", "true"));
+ if (m_dependencies[i].supportsNullable()) {
+ dep.addAttribute(new Attribute("Nullable", "true"));
+ }
+ if (m_dependencies[i].getDefaultImplementation() != null) {
+ dep.addAttribute(new Attribute("Default-Implementation", m_dependencies[i].getDefaultImplementation()));
+ }
} else {
dep.addAttribute(new Attribute("Optional", "false"));
}
@@ -110,6 +117,18 @@
dep.addAttribute(new Attribute("Aggregate", "false"));
}
+ String policy = "dynamic";
+ if (m_dependencies[i].getPolicy() == DependencyModel.STATIC_BINDING_POLICY) {
+ policy = "static";
+ } else if (m_dependencies[i].getPolicy() == DependencyModel.DYNAMIC_PRIORITY_BINDING_POLICY) {
+ policy = "dynamic-priority";
+ }
+ dep.addAttribute(new Attribute("Binding-Policy", policy));
+
+ if (m_dependencies[i].getComparator() != null) {
+ dep.addAttribute(new Attribute("Comparator", m_dependencies[i].getComparator()));
+ }
+
dep.addAttribute(new Attribute("State", state));
List set = m_dependencies[i].getUsedServices();
if (set != null) {
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 bd47ef5..4bbdec6 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
@@ -396,7 +396,7 @@
* if the new state is UNRESOLVED.
*
* @param state : the new instance state.
- * @see org.apache.felix.ipojo.CompositeHandler#stateChanged(int)
+ * @see org.apache.felix.ipojo.Handler#stateChanged(int)
*/
public void stateChanged(int state) {
// If the new state is INVALID => unregister all the services
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 ee78e6a..d308287 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
@@ -723,6 +723,19 @@
m_comparator = cmp;
// NOTE: the array will be sorted at the next get.
}
+
+ /**
+ * Gets the used comparator name.
+ * Null if no comparator (i.e. OSGi one is used).
+ * @return the comparator class name or null if the dependency doesn't use a comparator.
+ */
+ public String getComparator() {
+ if (m_comparator != null) {
+ return m_comparator.getClass().getName();
+ } else {
+ return null;
+ }
+ }
/**
* Set the bundle context used by this dependency. This operation is not supported if the tracker is already opened.