FELIX-2078 Fixes to resolve this bug.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@943031 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java
index 3c26dd4..b4ec6ca 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/ServiceDependencyImpl.java
@@ -67,6 +67,7 @@
private Object m_defaultImplementation;
private Object m_defaultImplementationInstance;
private boolean m_isAvailable;
+ private ServiceReference[] m_references;
private static final Comparator COMPARATOR = new Comparator() {
public int getRank(ServiceReference ref) {
@@ -752,16 +753,27 @@
}
public void invokeAdded(DependencyService service) {
- // we remember these for future reference, needed for required service callbacks
- m_reference = lookupServiceReference();
- m_serviceInstance = lookupService();
- invokeAdded(service, m_reference, m_serviceInstance);
+ ServiceReference[] refs = m_tracker.getServiceReferences();
+ if (refs != null) {
+ for (int i = 0; i < refs.length; i++) {
+ ServiceReference sr = refs[i];
+ Object svc = m_context.getService(sr);
+ invokeAdded(service, sr, svc);
+ }
+ }
+ m_references = refs;
}
-
+
public void invokeRemoved(DependencyService service) {
- invokeRemoved(service, m_reference, m_serviceInstance);
- m_reference = null;
- m_serviceInstance = null;
+ ServiceReference[] refs = m_references;
+ if (refs != null) {
+ for (int i = 0; i < refs.length; i++) {
+ ServiceReference sr = refs[i];
+ Object svc = m_context.getService(sr);
+ invokeRemoved(service, sr, svc);
+ }
+ }
+ m_references = null;
}
public Dictionary getProperties() {