felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1486753 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
Date Tue, 28 May 2013 05:57:38 GMT
Author: djencks
Date: Tue May 28 05:57:37 2013
New Revision: 1486753

URL: http://svn.apache.org/r1486753
Log:
FELIX-4070 remove dispose state method

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.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=1486753&r1=1486752&r2=1486753&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
Tue May 28 05:57:37 2013
@@ -720,10 +720,46 @@ public abstract class AbstractComponentM
      */
     public final void disposeInternal( int reason )
     {
-        m_state.dispose( this, reason );
+        log( LogService.LOG_DEBUG, "Disposing component (reason: " + reason + ")", null );
+        doDeactivate( reason, true );
+        //may call this multiple times.
+//        disableDependencyManagers();
+        clear();
+        changeState( Disposed.getInstance() );
+             }
+         
+    void doDeactivate( int reason, boolean disable )
+    {
+        try
+        {
+            if ( !unregisterService() )
+            {
+                log( LogService.LOG_DEBUG, "Component deactivation occuring on another thread",
null );
+                //another thread is deactivating.
+                return;
+            }
+            obtainWriteLock( "AbstractComponentManager.State.doDeactivate.1" );
+            try
+            {
+                deleteComponent( reason );
+                deactivateDependencyManagers();
+                if ( disable )
+                {
+                    disableDependencyManagers();
+                }
+                unsetDependenciesCollected();
+            }
+            finally
+            {
+                releaseWriteLock( "AbstractComponentManager.State.doDeactivate.1" );
+            }
+        }
+        catch ( Throwable t )
+        {
+            log( LogService.LOG_WARNING, "Component deactivation threw an exception", t );
+        }
     }
 
-
     final ServiceReference<S> getServiceReference()
     {
         ServiceRegistration<S> reg = getServiceRegistration();
@@ -1341,12 +1377,6 @@ public abstract class AbstractComponentM
         }
 
 
-        void dispose( AbstractComponentManager acm, int reason )
-        {
-            throw new IllegalStateException("dispose" + this);
-        }
-
-
         private void log( AbstractComponentManager acm, String event )
         {
             acm.log( LogService.LOG_DEBUG, "Current state: {0}, Event: {1}, Service registration:
{2}", new Object[]
@@ -1385,12 +1415,6 @@ public abstract class AbstractComponentM
             }
         }
 
-        void doDisable( AbstractComponentManager acm )
-        {
-            // reset the component id now (a disabled component has none)
-            acm.unregisterComponentId();
-        }
-
         public boolean isSatisfied()
         {
             return false;
@@ -1419,14 +1443,6 @@ public abstract class AbstractComponentM
             doDeactivate( acm, reason, disable );
         }
 
-        void dispose( AbstractComponentManager acm, int reason )
-        {
-            acm.log( LogService.LOG_DEBUG, "Disposing component (reason: {0})", new Object[]
{ REASONS[ reason ] }, null );
-            acm.clear();
-            acm.changeState( Disposed.getInstance() );
-
-            acm.log( LogService.LOG_DEBUG, "Component disposed", null );
-        }
     }
 
     protected static final class Unsatisfied extends State
@@ -1530,7 +1546,7 @@ public abstract class AbstractComponentM
         void disable( AbstractComponentManager acm )
         {
             acm.log( LogService.LOG_DEBUG, "Disabling component", null );
-            doDisable( acm );
+            acm.unregisterComponentId();
 
             // we are now disabled, ready for re-enablement or complete destroyal
             acm.changeState( Disabled.getInstance() );
@@ -1538,15 +1554,6 @@ public abstract class AbstractComponentM
             acm.log( LogService.LOG_DEBUG, "Component disabled", null );
         }
 
-        void dispose( AbstractComponentManager acm, int reason )
-        {
-            acm.log( LogService.LOG_DEBUG, "Disposing component for reason {0}", new Object[]
{ REASONS[ reason] }, null );
-            acm.disableDependencyManagers();
-            doDisable( acm );
-            acm.clear();   //content of Disabled.dispose
-            acm.changeState( Disposed.getInstance() );
-        }
-
     }
 
     protected static abstract class Satisfied extends State
@@ -1573,19 +1580,11 @@ public abstract class AbstractComponentM
 
         void disable( AbstractComponentManager acm )
         {
-            doDisable( acm );
+            acm.unregisterComponentId();
             acm.changeState( Disabled.getInstance() );
             acm.log( LogService.LOG_DEBUG, "Component disabled", null );
         }
 
-        void dispose( AbstractComponentManager acm, int reason )
-        {
-            doDeactivate( acm, reason, true );
-            doDisable(acm);
-            acm.clear();   //content of Disabled.dispose
-            acm.changeState( Disposed.getInstance() );
-        }
-
         @Override
         public boolean isSatisfied()
         {
@@ -1729,10 +1728,5 @@ public abstract class AbstractComponentM
             throw new IllegalStateException( "disable: " + this );
         }
 
-        void dispose( AbstractComponentManager acm, int reason )
-        {
-            //factory instance can have dispose called with no effect. 112.5.5
-        }
-
     }
 }



Mime
View raw message