felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1467353 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager: AbstractComponentManager.java ComponentContextImpl.java ImmediateComponentManager.java
Date Fri, 12 Apr 2013 16:55:41 GMT
Author: djencks
Date: Fri Apr 12 16:55:41 2013
New Revision: 1467353

URL: http://svn.apache.org/r1467353
Log:
FELIX-4011 getService can wait if another thread is creating the impl object

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/ImmediateComponentManager.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=1467353&r1=1467352&r2=1467353&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
Fri Apr 12 16:55:41 2013
@@ -191,7 +191,7 @@ public abstract class AbstractComponentM
         }
     }
 
-    private long getLockTimeout()
+    long getLockTimeout()
     {
         BundleComponentActivator activator = getActivator();
         if ( activator != null )

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=1467353&r1=1467352&r2=1467353&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
Fri Apr 12 16:55:41 2013
@@ -21,6 +21,8 @@ package org.apache.felix.scr.impl.manage
 
 import java.util.Arrays;
 import java.util.Dictionary;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.felix.scr.component.ExtComponentContext;
 import org.apache.felix.scr.impl.BundleComponentActivator;
@@ -48,6 +50,8 @@ public class ComponentContextImpl<S> imp
     private final S m_implementationObject;
     
     private volatile boolean m_implementationAccessible;
+    
+    private final CountDownLatch accessibleLatch = new CountDownLatch(1);
 
     ComponentContextImpl( AbstractComponentManager<S> componentManager, Bundle usingBundle,
S implementationObject )
     {
@@ -60,6 +64,10 @@ public class ComponentContextImpl<S> imp
     void setImplementationAccessible(boolean implementationAccessible)
     {
         this.m_implementationAccessible = implementationAccessible;
+        if (implementationAccessible)
+        {
+            accessibleLatch.countDown();
+        }
     }
     
     EdgeInfo getEdgeInfo(DependencyManager<S, ?> dm)
@@ -170,6 +178,17 @@ public class ComponentContextImpl<S> imp
         {
             return m_implementationObject;
         }
+        try
+        {
+            if (accessibleLatch.await( m_componentManager.getLockTimeout(), TimeUnit.MILLISECONDS
) && m_implementationAccessible)
+            {
+                return m_implementationObject;
+            }
+        }
+        catch ( InterruptedException e )
+        {
+            return null;
+        }
         return null;
     }
     

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=1467353&r1=1467352&r2=1467353&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
Fri Apr 12 16:55:41 2013
@@ -700,8 +700,7 @@ public class ImmediateComponentManager<S
 
     public S getService( Bundle bundle, ServiceRegistration<S> serviceRegistration
)
     {
-            ComponentContextImpl<S> componentContext = m_componentContext;
-            if ( componentContext == null )
+            if ( m_componentContext == null )
             {
                 try
                 {



Mime
View raw message