felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1550015 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager: AbstractComponentManager.java DependencyManager.java SingleComponentManager.java
Date Wed, 11 Dec 2013 01:29:25 GMT
Author: djencks
Date: Wed Dec 11 01:29:24 2013
New Revision: 1550015

URL: http://svn.apache.org/r1550015
Log:
FELIX-4350 Close stuff more definitely on failed activation

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java?rev=1550015&r1=1550014&r2=1550015&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
Wed Dec 11 01:29:24 2013
@@ -928,17 +928,14 @@ public abstract class AbstractComponentM
             obtainStateLock( "AbstractComponentManager.State.doDeactivate.1" );
             try
             {
-                if ( m_activated )
+                m_activated = false;
+                deleteComponent( reason );
+                deactivateDependencyManagers();
+                if ( disable )
                 {
-                    m_activated = false;
-                    deleteComponent( reason );
-                    deactivateDependencyManagers();
-                    if ( disable )
-                    {
-                        disableDependencyManagers();
-                    }
-                    unsetDependenciesCollected();
+                    disableDependencyManagers();
                 }
+                unsetDependenciesCollected();
             }
             finally
             {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1550015&r1=1550014&r2=1550015&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
Wed Dec 11 01:29:24 2013
@@ -202,6 +202,15 @@ public class DependencyManager<S, T> imp
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracker opened", new Object[]
{getName()}, null );
         }
 
+        protected void deactivateTracker()
+        {
+            ServiceTracker<T, RefPair<T>> tracker = getTracker();
+            if ( tracker != null )
+            {
+                tracker.deactivate();
+            }
+        }
+
         protected Map<ServiceReference<T>, RefPair<T>> getPreviousRefMap()
         {
             return previousRefMap;
@@ -283,7 +292,7 @@ public class DependencyManager<S, T> imp
 
         public void close()
         {
-            getTracker().deactivate();
+            deactivateTracker();
         }
 
         public Collection<RefPair<T>> getRefs( AtomicInteger trackingCount )
@@ -315,6 +324,7 @@ public class DependencyManager<S, T> imp
             {
                 if (isActive())
                 {
+                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic
already active, binding {2}", new Object[] {getName(), trackingCount, serviceReference}, null
);
                     getServiceObject( m_bindMethods.getBind(), refPair );
                     if ( !refPair.isFailed() )
                     {
@@ -326,10 +336,15 @@ public class DependencyManager<S, T> imp
                 }
                 else if ( isTrackerOpened() && !isOptional() )
                 {
+                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic,
activating", new Object[] {getName(), trackingCount}, null );
                     tracked( trackingCount );
                     tracked = true;
                     m_componentManager.activateInternal( trackingCount );
                 }
+                else 
+                {
+                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic,
inactive, doing nothing: tracker opened: {2}, optional: {3}", new Object[] {getName(), trackingCount,
isTrackerOpened(), isOptional()}, null );                    
+                }
             }
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic
added {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
             if ( !tracked )
@@ -401,7 +416,7 @@ public class DependencyManager<S, T> imp
             {
                 ungetService( ref );
             }
-            getTracker().deactivate();
+            deactivateTracker();
         }
 
 
@@ -519,7 +534,7 @@ public class DependencyManager<S, T> imp
             {
                 ungetService( ref );
             }
-            getTracker().deactivate();
+            deactivateTracker();
         }
 
         public Collection<RefPair<T>> getRefs( AtomicInteger trackingCount )
@@ -645,7 +660,7 @@ public class DependencyManager<S, T> imp
                     ungetService( ref );
                 }
             }
-            getTracker().deactivate();
+            deactivateTracker();
         }
 
         public Collection<RefPair<T>> getRefs( AtomicInteger trackingCount )
@@ -847,7 +862,7 @@ public class DependencyManager<S, T> imp
         public void close()
         {
             closeRefPair();
-            getTracker().deactivate();
+            deactivateTracker();
         }
 
         private void closeRefPair()
@@ -949,10 +964,20 @@ public class DependencyManager<S, T> imp
             synchronized (getTracker().tracked())
             {
                 reactivate = ( isActive() && refPair == this.refPair) || ( !isOptional()
&& getTracker().isEmpty());
+                if (!reactivate && refPair == this.refPair) {
+                    this.refPair = null;
+                }
             }
             if ( reactivate )
             {
                 m_componentManager.deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE,
false, false );
+                synchronized ( getTracker().tracked() )
+                {
+                    if (refPair == this.refPair)
+                    {
+                        this.refPair = null;
+                    }
+                }
                 m_componentManager.activateInternal( trackingCount );
             }
             m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic
removed {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
@@ -989,17 +1014,21 @@ public class DependencyManager<S, T> imp
 
         public void close()
         {
-            RefPair<T> ref;
-            synchronized ( getTracker().tracked() )
-            {
-                ref = refPair;
-                refPair = null;
-            }
-            if ( ref != null )
+            ServiceTracker<T, RefPair<T>> tracker = getTracker();
+            if ( tracker != null )
             {
-                ungetService( ref );
+                RefPair<T> ref;
+                synchronized ( tracker.tracked() )
+                {
+                    ref = refPair;
+                    refPair = null;
+                }
+                if ( ref != null )
+                {
+                    ungetService( ref );
+                }
+                tracker.deactivate();
             }
-            getTracker().deactivate();
         }
 
         public Collection<RefPair<T>> getRefs( AtomicInteger trackingCount )

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java?rev=1550015&r1=1550014&r2=1550015&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
Wed Dec 11 01:29:24 2013
@@ -303,8 +303,10 @@ public class SingleComponentManager<S> e
                 {
                     md.close( implementationObject, componentContext.getEdgeInfo( md ) );
                 }
+                md.deactivate();
             }
             setter.resetImplementationObject( implementationObject );
+            unsetDependenciesCollected();
             return null;
 
         }
@@ -344,21 +346,23 @@ public class SingleComponentManager<S> e
         componentContext.setImplementationAccessible( false );
         S implementationObject = componentContext.getImplementationObject( false );
 
-        // 1. Call the deactivate method, if present
-        // don't care for the result, the error (acccording to 112.5.12 If the deactivate
-        // method throws an exception, SCR must log an error message containing the
-        // exception with the Log Service and continue) has already been logged
-        final MethodResult result = getComponentMethods().getDeactivateMethod().invoke( implementationObject,
new ActivatorParameter( componentContext,
-                reason ), null, this );
-        if ( result != null )
+        if ( implementationObject != null )
         {
-            setServiceProperties( result );
-        }
-
-        // 2. Unbind any bound services
-        for ( DependencyManager md: getReversedDependencyManagers() )
-        {
-            md.close( implementationObject, componentContext.getEdgeInfo( md ) );
+            // 1. Call the deactivate method, if present
+            // don't care for the result, the error (acccording to 112.5.12 If the deactivate
+            // method throws an exception, SCR must log an error message containing the
+            // exception with the Log Service and continue) has already been logged
+            final MethodResult result = getComponentMethods().getDeactivateMethod().invoke(
implementationObject,
+                    new ActivatorParameter( componentContext, reason ), null, this );
+            if ( result != null )
+            {
+                setServiceProperties( result );
+            }
+            // 2. Unbind any bound services
+            for ( DependencyManager md: getReversedDependencyManagers() )
+            {
+                md.close( implementationObject, componentContext.getEdgeInfo( md ) );
+            }
         }
 
     }



Mime
View raw message