felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r880638 - in /felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager: ServiceDependency.java ServiceRegistrationImpl.java
Date Mon, 16 Nov 2009 07:39:04 GMT
Author: marrs
Date: Mon Nov 16 07:38:49 2009
New Revision: 880638

URL: http://svn.apache.org/viewvc?rev=880638&view=rev
Log:
FELIX-303 applied the suggested fix for getCallbackInstances(), FELIX-1546 added invocation
of callbacks for required dependencies (work on this issue is ongoing).

Modified:
    felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
    felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java

Modified: felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java?rev=880638&r1=880637&r2=880638&view=diff
==============================================================================
--- felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
(original)
+++ felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
Mon Nov 16 07:38:49 2009
@@ -337,13 +337,14 @@
     public void addedService(ServiceReference ref, Object service) {
         if (makeAvailable()) {
             m_service.dependencyAvailable(this);
+            // try to invoke callback, if specified, but only for optional dependencies
+            // because callbacks for required dependencies are handled differently
+            if (!isRequired()) {
+                invokeAdded(ref, service);
+            }
         }
         else {
             m_service.dependencyChanged(this);
-        }
-        // try to invoke callback, if specified, but only for optional dependencies
-        // because callbacks for required dependencies are handled differently
-        if (!isRequired()) {
             invokeAdded(ref, service);
         }
     }
@@ -355,7 +356,7 @@
     public void invokeAdded(ServiceReference reference, Object serviceInstance) {
         Object[] callbackInstances = getCallbackInstances();
         if ((callbackInstances != null) && (m_callbackAdded != null)) {
-                invokeCallbackMethod(callbackInstances, m_callbackAdded, reference, serviceInstance);
+            invokeCallbackMethod(callbackInstances, m_callbackAdded, reference, serviceInstance);
         }
     }
 
@@ -372,20 +373,21 @@
     public void invokeChanged(ServiceReference reference, Object serviceInstance) {
         Object[] callbackInstances = getCallbackInstances();
         if ((callbackInstances != null) && (m_callbackChanged != null)) {
-                if (m_reference == null) {
-                    Thread.dumpStack();
-                }
-                invokeCallbackMethod(callbackInstances, m_callbackChanged, reference, serviceInstance);
+            invokeCallbackMethod(callbackInstances, m_callbackChanged, reference, serviceInstance);
         }
     }
 
     public void removedService(ServiceReference ref, Object service) {
         if (makeUnavailable()) {
             m_service.dependencyUnavailable(this);
+            // try to invoke callback, if specified, but only for optional dependencies
+            // because callbacks for required dependencies are handled differently
+            if (!isRequired()) {
+                invokeRemoved(ref, service);
+            }
         }
-        // try to invoke callback, if specified, but only for optional dependencies
-        // because callbacks for required dependencies are handled differently
-        if (!isRequired()) {
+        else {
+            m_service.dependencyChanged(this);
             invokeRemoved(ref, service);
         }
         
@@ -400,10 +402,7 @@
     public void invokeRemoved(ServiceReference reference, Object serviceInstance) {
         Object[] callbackInstances = getCallbackInstances();
         if ((callbackInstances != null) && (m_callbackRemoved != null)) {
-                if (m_reference == null) {
-                    Thread.dumpStack();
-                }
-                invokeCallbackMethod(callbackInstances, m_callbackRemoved, reference, serviceInstance);
+            invokeCallbackMethod(callbackInstances, m_callbackRemoved, reference, serviceInstance);
         }
     }
     
@@ -424,14 +423,7 @@
     }
     
     private synchronized Object[] getCallbackInstances() {
-        Object[] callbackInstances = ((ServiceImpl) m_service).getCompositionInstances();
-        if (m_callbackInstance == null) {
-            return callbackInstances;
-        }
-        Object[] res = new Object[callbackInstances.length + 1];
-        res[0] = m_callbackInstance; //this could also be extended to an array...?
-        System.arraycopy(callbackInstances, 0, res, 1, callbackInstances.length);
-        return res;
+        return m_callbackInstance != null ? new Object[] { m_callbackInstance } : ((ServiceImpl)
m_service).getCompositionInstances();
     }
 
     private void invokeCallbackMethod(Object[] instances, String methodName, ServiceReference
reference, Object service) {

Modified: felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java?rev=880638&r1=880637&r2=880638&view=diff
==============================================================================
--- felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
(original)
+++ felix/trunk/dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceRegistrationImpl.java
Mon Nov 16 07:38:49 2009
@@ -31,7 +31,7 @@
  */
 public final class ServiceRegistrationImpl implements ServiceRegistration {
     public static final ServiceRegistrationImpl ILLEGAL_STATE = new ServiceRegistrationImpl();
-    private ServiceRegistration m_registration;
+    private volatile ServiceRegistration m_registration;
 
     public ServiceRegistrationImpl() {
         m_registration = null;



Mime
View raw message