felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1486750 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager: AbstractComponentManager.java ComponentContextImpl.java ComponentFactoryImpl.java ImmediateComponentManager.java ServiceFactoryComponentManager.java
Date Tue, 28 May 2013 05:57:29 GMT
Author: djencks
Date: Tue May 28 05:57:29 2013
New Revision: 1486750

URL: http://svn.apache.org/r1486750
Log:
FELIX-4070 remove getService state method

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/ComponentContextImpl.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.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=1486750&r1=1486749&r2=1486750&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:29 2013
@@ -496,13 +496,6 @@ public abstract class AbstractComponentM
         }
     }
 
-    /**
-     * Get the object that is implementing this descriptor
-     *
-     * @return the object that implements the services
-     */
-    abstract Object getInstance();
-
     // supports the ComponentInstance.dispose() method
     void dispose()
     {
@@ -1263,7 +1256,12 @@ public abstract class AbstractComponentM
         }
     }
 
-    //--------- State classes
+    boolean isEnabled()
+    {
+        return m_internalEnabled;
+    }
+    
+   //--------- State classes
 
     /**
      * There are 12 states in all. They are: Disabled, Unsatisfied,
@@ -1309,13 +1307,6 @@ public abstract class AbstractComponentM
             return m_state;
         }
 
-
-        Object getService( ImmediateComponentManager dcm )
-        {
-            throw new IllegalStateException("getService" + this);
-        }
-
-
         void ungetService( ImmediateComponentManager dcm )
         {
             throw new IllegalStateException("ungetService" + this);
@@ -1438,11 +1429,6 @@ public abstract class AbstractComponentM
             doDeactivate( acm, reason, disable );
         }
 
-        Object getService( ImmediateComponentManager dcm )
-        {
-            return null;
-        }
-
         void ungetService( ImmediateComponentManager dcm )
         {
             //do nothing, deactivate will unget all the services.
@@ -1576,12 +1562,6 @@ public abstract class AbstractComponentM
             acm.changeState( Disposed.getInstance() );
         }
 
-        Object getService( ImmediateComponentManager dcm )
-        {
-            //concurrent attempt to get service and remove dependency
-            return null;
-        }
-
         void ungetService( ImmediateComponentManager dcm )
         {
             //do nothing.  This can arise if component is deactivated concurrently with ungetService
on a delayed component.
@@ -1656,12 +1636,6 @@ public abstract class AbstractComponentM
         }
 
 
-        Object getService( ImmediateComponentManager dcm )
-        {
-            return dcm.getInstance();
-        }
-
-
         void ungetService( ImmediateComponentManager dcm )
         {
             dcm.deleteComponent( ComponentConstants.DEACTIVATION_REASON_UNSPECIFIED );
@@ -1694,35 +1668,6 @@ public abstract class AbstractComponentM
             return m_inst;
         }
 
-
-        Object getService( ImmediateComponentManager dcm )
-        {
-            if ( dcm.createComponent() )
-            {
-                dcm.changeState( dcm.getActiveState() );
-                return dcm.getInstance();
-            }
-
-            // log that the delayed component cannot be created (we don't
-            // know why at this moment; this should already have been logged)
-            dcm.log( LogService.LOG_ERROR, "Failed creating the component instance; see log
for reason", null );
-
-            // component could not really be created. This may be temporary
-            // so we stay in the registered state but ensure the component
-            // instance is deleted
-            try
-            {
-                dcm.deleteComponent( ComponentConstants.DEACTIVATION_REASON_UNSPECIFIED );
-            }
-            catch ( Throwable t )
-            {
-                dcm.log( LogService.LOG_DEBUG, "Cannot delete incomplete component instance.
Ignoring.", t );
-            }
-
-            // no service can be returned (be prepared for more logging !!)
-            return null;
-        }
-
         void ungetService( ImmediateComponentManager dcm )
         {
             //do nothing.  This can arise if component is deactivated concurrently with ungetService
on a delayed component.
@@ -1777,12 +1722,6 @@ public abstract class AbstractComponentM
             return m_inst;
         }
 
-        Object getService( ImmediateComponentManager dcm )
-        {
-            return dcm.getInstance();
-        }
-
-
         void ungetService( ImmediateComponentManager dcm )
         {
             dcm.deleteComponent( ComponentConstants.DEACTIVATION_REASON_UNSPECIFIED );

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java?rev=1486750&r1=1486749&r2=1486750&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
Tue May 28 05:57:29 2013
@@ -40,7 +40,7 @@ import org.osgi.service.log.LogService;
  */
 public class ComponentContextImpl<S> implements ExtComponentContext {
 
-    private final AbstractComponentManager<S> m_componentManager;
+    private final ImmediateComponentManager<S> m_componentManager;
     
     private final EdgeInfo[] edgeInfos;
     
@@ -54,7 +54,7 @@ public class ComponentContextImpl<S> imp
     
     private final CountDownLatch accessibleLatch = new CountDownLatch(1);
 
-    ComponentContextImpl( AbstractComponentManager<S> componentManager, Bundle usingBundle,
S implementationObject )
+    ComponentContextImpl( ImmediateComponentManager<S> componentManager, Bundle usingBundle,
S implementationObject )
     {
         m_componentManager = componentManager;
         m_usingBundle = usingBundle;
@@ -86,7 +86,7 @@ public class ComponentContextImpl<S> imp
         Arrays.fill( edgeInfos, null );
     }
 
-    protected AbstractComponentManager<S> getComponentManager()
+    protected ImmediateComponentManager<S> getComponentManager()
     {
         return m_componentManager;
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java?rev=1486750&r1=1486749&r2=1486750&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
Tue May 28 05:57:29 2013
@@ -202,13 +202,6 @@ public class ComponentFactoryImpl<S> ext
     }
 
 
-    public Object getInstance()
-    {
-        // this does not return the component instance actually
-        return null;
-    }
-
-
     public boolean hasConfiguration()
     {
         return m_hasConfiguration;

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java?rev=1486750&r1=1486749&r2=1486750&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
Tue May 28 05:57:29 2013
@@ -180,7 +180,7 @@ public class ImmediateComponentManager<S
      *
      * @return the object that implements the services
      */
-    Object getInstance()
+    S getInstance()
     {
         return m_componentContext == null? null: m_componentContext.getImplementationObject(
true );
     }
@@ -763,7 +763,7 @@ public class ImmediateComponentManager<S
                     if ( m_componentContext == null )
                     {
                         //state should be "Registered"
-                        S result = (S) Registered.getInstance().getService( this );
+                        S result = getService( );
                         if ( result == null )
                         {
                             success = false;;
@@ -784,6 +784,41 @@ public class ImmediateComponentManager<S
         }
     }
 
+    private S getService()
+    {
+        //should be write locked
+        if (!isEnabled())
+        {
+            return null;
+        }
+
+        if ( createComponent() )
+        {
+            changeState( getActiveState() );
+            return getInstance();
+        }
+
+        // log that the delayed component cannot be created (we don't
+        // know why at this moment; this should already have been logged)
+        log( LogService.LOG_ERROR, "Failed creating the component instance; see log for reason",
null );
+
+        // component could not really be created. This may be temporary
+        // so we stay in the registered state but ensure the component
+        // instance is deleted
+        try
+        {
+            deleteComponent( ComponentConstants.DEACTIVATION_REASON_UNSPECIFIED );
+        }
+        catch ( Throwable t )
+        {
+            log( LogService.LOG_DEBUG, "Cannot delete incomplete component instance. Ignoring.",
t );
+        }
+
+        // no service can be returned (be prepared for more logging !!)
+        return null;
+
+    }
+
     public void ungetService( Bundle bundle, ServiceRegistration<S> serviceRegistration,
S o )
     {
         // the framework should not call ungetService more than it calls

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java?rev=1486750&r1=1486749&r2=1486750&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
Tue May 28 05:57:29 2013
@@ -94,7 +94,7 @@ public class ServiceFactoryComponentMana
     /* (non-Javadoc)
      * @see org.apache.felix.scr.AbstractComponentManager#getInstance()
      */
-    Object getInstance()
+    S getInstance()
     {
         // this method is not expected to be called as the base call is
         // overwritten in the ComponentContextImpl class



Mime
View raw message