felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1493335 - in /felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo: handlers/providedservice/CreationStrategy.java handlers/providedservice/ProvidedService.java util/DependencyModel.java
Date Sat, 15 Jun 2013 10:17:34 GMT
Author: clement
Date: Sat Jun 15 10:17:34 2013
New Revision: 1493335

URL: http://svn.apache.org/r1493335
Log:
Avoid creating the service object for dependency callbacks.

Modified:
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/CreationStrategy.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/CreationStrategy.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/CreationStrategy.java?rev=1493335&r1=1493334&r2=1493335&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/CreationStrategy.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/CreationStrategy.java
Sat Jun 15 10:17:34 2013
@@ -46,7 +46,7 @@ public abstract class CreationStrategy i
     
     /**
      * Checks if the given method object is the
-     * {@link IPOJOServiceFactory#getService(ComponentInstance)}
+     * {@link org.apache.felix.ipojo.IPOJOServiceFactory#getService(org.apache.felix.ipojo.ComponentInstance)}
      * method.
      * @param method the method to check
      * @return <code>true</code> if the method is the getService method
@@ -61,7 +61,7 @@ public abstract class CreationStrategy i
     
     /**
      * Checks if the given method object is the
-     * {@link IPOJOServiceFactory#ungetService(ComponentInstance, Object)}
+     * {@link org.apache.felix.ipojo.IPOJOServiceFactory#ungetService(org.apache.felix.ipojo.ComponentInstance,
Object)}
      * method.
      * @param method the method to check
      * @return <code>true</code> if the method is the ungetService method

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java?rev=1493335&r1=1493334&r2=1493335&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
Sat Jun 15 10:17:34 2013
@@ -359,9 +359,7 @@ public class ProvidedService implements 
             if (m_serviceRegistration != null) {
                 return;
             } else {
-                if (m_handler.getInstanceManager().getState() == ComponentInstance.VALID
-                        && m_serviceRegistration == null
-                        && isAtLeastAServiceControllerValid()) {
+                if (m_handler.getInstanceManager().getState() == ComponentInstance.VALID
&& isAtLeastAServiceControllerValid()) {
                     // Build the service properties list
 
                     BundleContext bc = m_handler.getInstanceManager().getContext();

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java?rev=1493335&r1=1493334&r2=1493335&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
Sat Jun 15 10:17:34 2013
@@ -781,15 +781,20 @@ public abstract class DependencyModel {
 
         // Now call callbacks, the lock is not held anymore
         // Only one of the list is not empty..
-        for (ServiceReference ref : arrivals) {
-            onServiceArrival(ref);
-            // Notify service binding to listeners
-            notifyListeners(DependencyEventType.BINDING, ref, getService(ref, false));
-        }
-        for (ServiceReference ref : departures) {
-            onServiceDeparture(ref);
-            // Notify service unbinding to listeners
-            notifyListeners(DependencyEventType.UNBINDING, ref, getService(ref, false));
+        try {
+            acquireReadLockIfNotHeld();
+            for (ServiceReference ref : arrivals) {
+                onServiceArrival(ref);
+                // Notify service binding to listeners
+                notifyListeners(DependencyEventType.BINDING, ref, m_serviceObjects.get(ref));
+            }
+            for (ServiceReference ref : departures) {
+                onServiceDeparture(ref);
+                // Notify service unbinding to listeners
+                notifyListeners(DependencyEventType.UNBINDING, ref, m_serviceObjects.get(ref));
+            }
+        } finally {
+            releaseReadLockIfHeld();
         }
 
 
@@ -974,10 +979,11 @@ public abstract class DependencyModel {
                         m_state = BROKEN;
 
                         // We are going to call callbacks, releasing the lock.
+                        Object svc = m_serviceObjects.get(ref);
                         releaseWriteLockIfHeld();
 
                         // Notify listeners
-                        notifyListeners(DependencyEventType.UNBINDING, ref, getService(ref,
false));
+                        notifyListeners(DependencyEventType.UNBINDING, ref, svc);
                         notifyListeners(DependencyEventType.DEPARTURE, ref, null);
 
                         invalidate();  // This will invalidate the instance.
@@ -1056,25 +1062,31 @@ public abstract class DependencyModel {
                 }
             }
 
-            // Leaving the locked region to invoke callbacks
+            // Leaving the locked region to invoke callbacks, but grab the read lock
             releaseWriteLockIfHeld();
-            for (ServiceReference ref : departures) {
-                onServiceDeparture(ref);
-                // Notify service unbinding to listeners
-                notifyListeners(DependencyEventType.UNBINDING, ref, getService(ref, false));
-            }
-            for (ServiceReference ref : arrivals) {
-                onServiceArrival(ref);
-                // Notify service binding to listeners
-                notifyListeners(DependencyEventType.BINDING, ref, getService(ref, false));
-            }
-            // Do we have a modified service ?
-            if (set.modified != null && m_boundServices.contains(set.modified)) {
-                onServiceModification(set.modified);
-                // TODO call boundServiceModified on listeners???
+            try {
+                acquireReadLockIfNotHeld();
+                for (ServiceReference ref : departures) {
+                    onServiceDeparture(ref);
+                    // Notify service unbinding to listeners
+                    Object svc = m_serviceObjects.get(ref);
+                    notifyListeners(DependencyEventType.UNBINDING, ref, svc);
+                }
+                for (ServiceReference ref : arrivals) {
+                    onServiceArrival(ref);
+                    // Notify service binding to listeners
+                    Object svc = m_serviceObjects.get(ref);
+                    notifyListeners(DependencyEventType.BINDING, ref, svc);
+                }
+                // Do we have a modified service ?
+                if (set.modified != null && m_boundServices.contains(set.modified))
{
+                    onServiceModification(set.modified);
+                    // TODO call boundServiceModified on listeners???
+                }
+            } finally {
+                releaseReadLockIfHeld();
             }
 
-
             // Did our state changed ?
             // this method will manage its own synchronization.
             computeAndSetDependencyState();



Mime
View raw message