felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1615440 [1/3] - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/helper/ main/java/org/apache/felix/scr/impl/manager/ test/java/org/apache/felix/scr/impl/helper/
Date Sun, 03 Aug 2014 19:27:55 GMT
Author: djencks
Date: Sun Aug  3 19:27:54 2014
New Revision: 1615440

URL: http://svn.apache.org/r1615440
Log:
FELIX-4505 Implement prototype scope for references, using ComponentContextImpl as object
key in RefPairs. LocateService now uses appropriate strategy. New event method signatures
not yet implemented.

Added:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
  (with props)
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java   (with
props)
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/MultiplePrototypeRefPair.java
  (with props)
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SinglePrototypeRefPair.java
  (with props)
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleRefPair.java
      - copied, changed from r1615284, felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
    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/DependencyManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/helper/ActivateMethodTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/helper/BindMethodTest.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java?rev=1615440&r1=1615439&r2=1615440&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java Sun
Aug  3 19:27:54 2014
@@ -22,11 +22,10 @@ package org.apache.felix.scr.impl.helper
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
-import org.osgi.service.component.ComponentContext;
 import org.osgi.service.log.LogService;
 
 
-public class ActivateMethod extends BaseMethod
+public class ActivateMethod extends BaseMethod<ActivatorParameter>
 {
 
     private static final Class[] ACTIVATE_TYPES_DS11 =
@@ -107,7 +106,7 @@ public class ActivateMethod extends Base
     }
 
 
-    protected Object[] getParameters( Method method, Object rawParameter )
+    protected Object[] getParameters( Method method, ActivatorParameter rawParameter )
     {
         final Class[] parameterTypes = method.getParameterTypes();
         final ActivatorParameter ap = ( ActivatorParameter ) rawParameter;
@@ -142,7 +141,7 @@ public class ActivateMethod extends Base
         return "activate";
     }
 
-    public MethodResult invoke( Object componentInstance, Object rawParameter, final MethodResult
methodCallFailureResult, SimpleLogger logger )
+    public MethodResult invoke( Object componentInstance, ActivatorParameter rawParameter,
final MethodResult methodCallFailureResult, SimpleLogger logger )
     {
         if (methodExists( logger ))
         {
@@ -246,29 +245,4 @@ public class ActivateMethod extends Base
         return isDS11();
     }
 
-    //---------- Helper class for method call parameters
-
-    public static final class ActivatorParameter
-    {
-        private final ComponentContext m_componentContext;
-        private final int m_reason;
-
-        public ActivatorParameter( ComponentContext componentContext, int reason )
-        {
-            this.m_componentContext = componentContext;
-            this.m_reason = reason;
-        }
-
-
-        public ComponentContext getComponentContext()
-        {
-            return m_componentContext;
-        }
-
-
-        public int getReason()
-        {
-            return m_reason;
-        }
-    }
 }

Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java?rev=1615440&view=auto
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
(added)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
Sun Aug  3 19:27:54 2014
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.impl.helper;
+
+import org.osgi.service.component.ComponentContext;
+
+public final class ActivatorParameter
+{
+    private final ComponentContext m_componentContext;
+    private final int m_reason;
+
+    public ActivatorParameter( ComponentContext componentContext, int reason )
+    {
+        this.m_componentContext = componentContext;
+        this.m_reason = reason;
+    }
+
+
+    public ComponentContext getComponentContext()
+    {
+        return m_componentContext;
+    }
+
+
+    public int getReason()
+    {
+        return m_reason;
+    }
+}
\ No newline at end of file

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivatorParameter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java?rev=1615440&r1=1615439&r2=1615440&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java Sun Aug
 3 19:27:54 2014
@@ -36,7 +36,7 @@ import org.osgi.service.log.LogService;
 /**
  * Component method to be invoked on service (un)binding.
  */
-abstract class BaseMethod
+abstract class BaseMethod<P>
 {
 
     // class references to simplify parameter checking
@@ -218,7 +218,7 @@ abstract class BaseMethod
             final boolean acceptPackage, SimpleLogger logger ) throws SuitableMethodNotAccessibleException,
InvocationTargetException;
 
 
-    private MethodResult invokeMethod( final Object componentInstance, final Object rawParameter,
SimpleLogger logger )
+    private MethodResult invokeMethod( final Object componentInstance, final P rawParameter,
SimpleLogger logger )
         throws InvocationTargetException
     {
         try
@@ -281,7 +281,7 @@ abstract class BaseMethod
      * @throws IllegalStateException If the required parameters cannot be
      *      extracted from the <code>rawParameter</code>
      */
-    protected abstract Object[] getParameters( Method method, Object rawParameter );
+    protected abstract Object[] getParameters( Method method, P rawParameter );
 
 
     protected String getMethodNamePrefix()
@@ -500,7 +500,7 @@ abstract class BaseMethod
      *      <code>methodCallFailureResult</code> is returned if the method was
      *      found and called, but the method threw an exception.
      */
-    public MethodResult invoke( final Object componentInstance, final Object rawParameter,
+    public MethodResult invoke( final Object componentInstance, final P rawParameter,
             final MethodResult methodCallFailureResult, SimpleLogger logger )
     {
         try
@@ -525,11 +525,11 @@ abstract class BaseMethod
     private static interface State
     {
 
-        MethodResult invoke( final BaseMethod baseMethod, final Object componentInstance,
final Object rawParameter, SimpleLogger logger )
+        <P> MethodResult invoke( final BaseMethod<P> baseMethod, final Object
componentInstance, final P rawParameter, SimpleLogger logger )
             throws InvocationTargetException;
 
 
-        boolean methodExists( final BaseMethod baseMethod, SimpleLogger logger );
+        <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger
logger );
     }
 
     private static class NotApplicable implements State
@@ -538,13 +538,13 @@ abstract class BaseMethod
         private static final State INSTANCE = new NotApplicable();
 
 
-        public MethodResult invoke( final BaseMethod baseMethod, final Object componentInstance,
final Object rawParameter, SimpleLogger logger )
+        public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final
Object componentInstance, final P rawParameter, SimpleLogger logger )
         {
             return MethodResult.VOID;
         }
 
 
-        public boolean methodExists( final BaseMethod baseMethod, SimpleLogger logger )
+        public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger
logger )
         {
             return true;
         }
@@ -555,7 +555,7 @@ abstract class BaseMethod
         private static final State INSTANCE = new NotResolved();
 
 
-        private synchronized void resolve( final BaseMethod baseMethod, SimpleLogger logger
)
+        private synchronized <P> void resolve( final BaseMethod<P> baseMethod,
SimpleLogger logger )
         {
             logger.log( LogService.LOG_DEBUG, "getting {0}: {1}", new Object[]
                     {baseMethod.getMethodNamePrefix(), baseMethod.getMethodName()}, null
);
@@ -576,7 +576,7 @@ abstract class BaseMethod
         }
 
 
-        public MethodResult invoke( final BaseMethod baseMethod, final Object componentInstance,
final Object rawParameter, SimpleLogger logger )
+        public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final
Object componentInstance, final P rawParameter, SimpleLogger logger )
             throws InvocationTargetException
         {
             resolve( baseMethod, logger );
@@ -584,7 +584,7 @@ abstract class BaseMethod
         }
 
 
-        public boolean methodExists( final BaseMethod baseMethod, SimpleLogger logger )
+        public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger
logger )
         {
             resolve( baseMethod, logger );
             return baseMethod.getState().methodExists( baseMethod, logger );
@@ -596,7 +596,7 @@ abstract class BaseMethod
         private static final State INSTANCE = new NotFound();
 
 
-        public MethodResult invoke( final BaseMethod baseMethod, final Object componentInstance,
final Object rawParameter, SimpleLogger logger )
+        public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final
Object componentInstance, final P rawParameter, SimpleLogger logger )
         {
             // 112.3.1 If the method is not found , SCR must log an error
             // message with the log service, if present, and ignore the
@@ -607,7 +607,7 @@ abstract class BaseMethod
         }
 
 
-        public boolean methodExists( final BaseMethod baseMethod, SimpleLogger logger )
+        public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger
logger )
         {
             return false;
         }
@@ -618,14 +618,14 @@ abstract class BaseMethod
         private static final State INSTANCE = new Resolved();
 
 
-        public MethodResult invoke( final BaseMethod baseMethod, final Object componentInstance,
final Object rawParameter, SimpleLogger logger )
+        public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final
Object componentInstance, final P rawParameter, SimpleLogger logger )
             throws InvocationTargetException
         {
             return baseMethod.invokeMethod( componentInstance, rawParameter, logger );
         }
 
 
-        public boolean methodExists( final BaseMethod baseMethod, SimpleLogger logger )
+        public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger
logger )
         {
             return true;
         }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java?rev=1615440&r1=1615439&r2=1615440&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java Sun Aug
 3 19:27:54 2014
@@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTarge
 import java.lang.reflect.Method;
 
 import org.apache.felix.scr.impl.Activator;
+import org.apache.felix.scr.impl.manager.ComponentContextImpl;
 import org.apache.felix.scr.impl.manager.RefPair;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -34,7 +35,7 @@ import org.osgi.service.packageadmin.Pac
 /**
  * Component method to be invoked on service (un)binding.
  */
-public class BindMethod extends BaseMethod
+public class BindMethod extends BaseMethod<BindParameters>
 {
 
     private static final Class<?> OBJECT_CLASS = Object.class;
@@ -563,46 +564,33 @@ public class BindMethod extends BaseMeth
         return null;
     }
 
-    public <T> boolean getServiceObject( RefPair<T> refPair, BundleContext context,
SimpleLogger logger )
+    public <S, T> boolean getServiceObject( ComponentContextImpl<S> key, RefPair<S,
T> refPair, BundleContext context, SimpleLogger logger )
     {
         //??? this resolves which we need.... better way?
-        if ( refPair.getServiceObject() == null && methodExists( logger ) )
+        if ( refPair.getServiceObject(key) == null && methodExists( logger ) )
         {
             if (m_paramStyle == SERVICE_OBJECT || m_paramStyle == SERVICE_OBJECT_AND_MAP)
{
-                T service = context.getService( refPair.getRef() );
-                if ( service == null )
-                {
-                    refPair.setFailed();
-                    logger.log(
-                         LogService.LOG_WARNING,
-                         "Could not get service from ref {0}", new Object[] {refPair.getRef()},
null );
-                    return false;
-                }
-                if (!refPair.setServiceObject(service))
-                {
-                    // Another thread got the service before, so unget our
-                    context.ungetService( refPair.getRef() );
-                }
-                return true;
+                return refPair.getServiceObject(key, context, logger);
             }
         }
         return true;
     }
 
-    protected Object[] getParameters( Method method, Object rawParameter )
+    protected Object[] getParameters( Method method, BindParameters bp )
     {
-        RefPair<?> refPair = ( RefPair<?> ) rawParameter;
+        ComponentContextImpl key = bp.getComponentContext();
+        RefPair<?, ?> refPair = bp.getRefPair();
         if (m_paramStyle == SERVICE_REFERENCE )
         {
             return new Object[] {refPair.getRef()};
         }
         if (m_paramStyle == SERVICE_OBJECT)
         {
-            return new Object[] {refPair.getServiceObject()};
+            return new Object[] {refPair.getServiceObject(key)};
         }
         if (m_paramStyle == SERVICE_OBJECT_AND_MAP  )
         {
-            return new Object[] {refPair.getServiceObject(), new ReadOnlyDictionary<String,
Object>( refPair.getRef() )};
+            return new Object[] {refPair.getServiceObject(key), new ReadOnlyDictionary<String,
Object>( refPair.getRef() )};
         }
         throw new IllegalStateException( "Unexpected m_paramStyle of " + m_paramStyle );
     }

Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java?rev=1615440&view=auto
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java (added)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java Sun
Aug  3 19:27:54 2014
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.impl.helper;
+
+import org.apache.felix.scr.impl.manager.ComponentContextImpl;
+import org.apache.felix.scr.impl.manager.RefPair;
+
+public class BindParameters
+{
+    
+    private final ComponentContextImpl<?> componentContext;
+    private final RefPair<?, ?> refPair;
+    public BindParameters(ComponentContextImpl<?> componentContext, RefPair<?, ?>
refPair)
+    {
+        this.componentContext = componentContext;
+        this.refPair = refPair;
+    }
+    
+    public ComponentContextImpl<?> getComponentContext()
+    {
+        return componentContext;
+    }
+    
+    public RefPair<?, ?> getRefPair()
+    {
+        return refPair;
+    }
+    
+}

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BindParameters.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1615440&r1=1615439&r2=1615440&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
Sun Aug  3 19:27:54 2014
@@ -96,8 +96,6 @@ public abstract class AbstractComponentM
 
     private volatile boolean m_dependencyManagersInitialized;
 
-    private volatile boolean m_dependenciesCollected;
-
     private final AtomicInteger m_trackingCount = new AtomicInteger( );
 
     // The ServiceRegistration is now tracked in the RegistrationManager
@@ -783,7 +781,6 @@ public abstract class AbstractComponentM
                 {
                     disableDependencyManagers();
                 }
-                unsetDependenciesCollected();
             }
             finally
             {
@@ -968,47 +965,34 @@ public abstract class AbstractComponentM
 
     /**
      * Collect and store in m_dependencies_map all the services for dependencies, outside
of any locks.
-     * Throwing IllegalStateException on failure to collect all the dependencies is needed
so getService can
-     * know to return null.
+     * @param componentContext possible instance key for prototype scope references
      *
-     * @return true if this thread collected the dependencies;
-     *   false if some other thread successfully collected the dependencies;
-     * @throws IllegalStateException if some dependency is no longer available.
+     * @return true if all references can be collected,
+     *   false if some dependency is no longer available.
      */
-    protected boolean collectDependencies() throws IllegalStateException
+    protected boolean collectDependencies(ComponentContextImpl<S> componentContext)
     {
-        if ( m_dependenciesCollected)
-        {
-            log( LogService.LOG_DEBUG, "dependencies already collected, do not collect dependencies",
null );
-            return false;
-        }
         initDependencyManagers();
         for ( DependencyManager<S, ?> dependencyManager : m_dependencyManagers )
         {
-            if ( !dependencyManager.prebind() )
+            if ( !dependencyManager.prebind(componentContext) )
             {
                 //not actually satisfied any longer
                 deactivateDependencyManagers();
                 log( LogService.LOG_DEBUG, "Could not get required dependency for dependency
manager: {0}",
                         new Object[] {dependencyManager.getName()}, null );
-                throw new IllegalStateException( "Missing dependencies, not satisfied" );
+                return false;
             }
         }
-        m_dependenciesCollected = true;
         log( LogService.LOG_DEBUG, "This thread collected dependencies", null );
         return true;
     }
 
-    protected void unsetDependenciesCollected()
-    {
-        m_dependenciesCollected = false;
-    }
-
-    abstract <T> void invokeUpdatedMethod( DependencyManager<S, T> dependencyManager,
RefPair<T> refPair, int trackingCount );
+    abstract <T> void invokeUpdatedMethod( DependencyManager<S, T> dependencyManager,
RefPair<S, T> refPair, int trackingCount );
 
-    abstract <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager,
RefPair<T> refPair, int trackingCount );
+    abstract <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager,
RefPair<S, T> refPair, int trackingCount );
 
-    abstract <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager,
RefPair<T> oldRefPair, int trackingCount );
+    abstract <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager,
RefPair<S, T> oldRefPair, int trackingCount );
 
     //**********************************************************************************************************
     public BundleComponentActivator getActivator()

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=1615440&r1=1615439&r2=1615440&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
Sun Aug  3 19:27:54 2014
@@ -47,17 +47,16 @@ public class ComponentContextImpl<S> imp
     
     private final Bundle m_usingBundle;
     
-    private final S m_implementationObject;
+    private S m_implementationObject;
     
     private volatile boolean m_implementationAccessible;
     
     private final CountDownLatch accessibleLatch = new CountDownLatch(1);
 
-    ComponentContextImpl( SingleComponentManager<S> componentManager, Bundle usingBundle,
S implementationObject )
+    public ComponentContextImpl( SingleComponentManager<S> componentManager, Bundle
usingBundle )
     {
         m_componentManager = componentManager;
         m_usingBundle = usingBundle;
-        m_implementationObject = implementationObject;
         edgeInfos = new EdgeInfo[componentManager.getComponentMetadata().getDependencies().size()];
         for (int i = 0; i< edgeInfos.length; i++)
         {
@@ -65,6 +64,13 @@ public class ComponentContextImpl<S> imp
         }
     }
     
+    
+    public void setImplementationObject(S implementationObject)
+    {
+        this.m_implementationObject = implementationObject;
+    }
+
+
     void setImplementationAccessible(boolean implementationAccessible)
     {
         this.m_implementationAccessible = implementationAccessible;
@@ -98,7 +104,7 @@ public class ComponentContextImpl<S> imp
         try
         {
             DependencyManager<S, ?> dm = m_componentManager.getDependencyManager( name
);
-            return ( dm != null ) ? dm.getService() : null;
+            return ( dm != null ) ? dm.getService(this) : null;
         }
         finally
         {
@@ -113,7 +119,7 @@ public class ComponentContextImpl<S> imp
         try
         {
             DependencyManager<S, ?> dm = m_componentManager.getDependencyManager( name
);
-            return ( dm != null ) ? dm.getService( ref ) : null;
+            return ( dm != null ) ? dm.getService( this, ref ) : null;
         }
         finally
         {
@@ -128,7 +134,7 @@ public class ComponentContextImpl<S> imp
         try
         {
             DependencyManager<S, ?> dm = m_componentManager.getDependencyManager( name
);
-            return ( dm != null ) ? dm.getServices() : null;
+            return ( dm != null ) ? dm.getServices(this) : null;
         }
         finally
         {

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=1615440&r1=1615439&r2=1615440&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
Sun Aug  3 19:27:54 2014
@@ -295,20 +295,20 @@ public class ComponentFactoryImpl<S> ext
         return false;
     }
 
-    protected boolean collectDependencies()
+    protected boolean collectDependencies(ComponentContextImpl<S> componentContext)
     {
         return true;
     }
 
-    <T> void invokeUpdatedMethod( DependencyManager<S, T> dependencyManager,
RefPair<T> ref, int trackingCount )
+    <T> void invokeUpdatedMethod( DependencyManager<S, T> dependencyManager,
RefPair<S, T> ref, int trackingCount )
     {
     }
 
-    <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, RefPair<T>
reference, int trackingCount )
+    <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, RefPair<S,
T> reference, int trackingCount )
     {
     }
 
-    <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, RefPair<T>
oldRef, int trackingCount )
+    <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, RefPair<S,
T> oldRef, int trackingCount )
     {
     }
 



Mime
View raw message