felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1744736 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: BundleComponentActivator.java ComponentRegistry.java config/ConfigurableComponentHolder.java config/RegionConfigurationSupport.java manager/AbstractComponentManager.java
Date Fri, 20 May 2016 13:43:59 GMT
Author: gnodet
Date: Fri May 20 13:43:54 2016
New Revision: 1744736

URL: http://svn.apache.org/viewvc?rev=1744736&view=rev
Log:
[FELIX-5243] Break dependency to ComponentRegistry

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/RegionConfigurationSupport.java
    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/BundleComponentActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java?rev=1744736&r1=1744735&r2=1744736&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
Fri May 20 13:43:54 2016
@@ -849,8 +849,7 @@ public class BundleComponentActivator im
     }
 
     public RegionConfigurationSupport setRegionConfigurationSupport(ServiceReference<ConfigurationAdmin>
reference) {
-        RegionConfigurationSupport trialRcs = new RegionConfigurationSupport(reference, m_componentRegistry);
-        RegionConfigurationSupport rcs = m_componentRegistry.registerRegionConfigurationSupport(trialRcs);
+        RegionConfigurationSupport rcs = m_componentRegistry.registerRegionConfigurationSupport(reference);
         for (ComponentHolder<?> holder: m_holders)
         {
             rcs.configureComponentHolder(holder);

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=1744736&r1=1744735&r2=1744736&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Fri May
20 13:43:54 2016
@@ -40,6 +40,7 @@ import org.apache.felix.scr.impl.metadat
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.component.ComponentConstants;
 import org.osgi.service.component.ComponentException;
 import org.osgi.service.log.LogService;
@@ -52,9 +53,6 @@ import org.osgi.service.log.LogService;
 public class ComponentRegistry
 {
 
-    // the name of the ConfigurationAdmin service
-    public static final String CONFIGURATION_ADMIN = "org.osgi.service.cm.ConfigurationAdmin";
-
     /**
      * The map of known components indexed by component name. The values are
      * either null (for name reservations) or implementations
@@ -526,7 +524,18 @@ public class ComponentRegistry
     
     private final ConcurrentMap<Long, RegionConfigurationSupport> bundleToRcsMap =
new ConcurrentHashMap<Long, RegionConfigurationSupport>();
 
-	public RegionConfigurationSupport registerRegionConfigurationSupport(
+    public RegionConfigurationSupport registerRegionConfigurationSupport(
+            ServiceReference<ConfigurationAdmin> reference) {
+        RegionConfigurationSupport trialRcs = new RegionConfigurationSupport(reference) {
+            protected Collection<ComponentHolder<?>> getComponentHolders(TargetedPID
pid)
+            {
+                return ComponentRegistry.this.getComponentHoldersByPid(pid);
+            }
+        };
+        return registerRegionConfigurationSupport(trialRcs);
+    }
+
+    public RegionConfigurationSupport registerRegionConfigurationSupport(
 			RegionConfigurationSupport trialRcs) {
 		Long bundleId = trialRcs.getBundleId();
 		RegionConfigurationSupport existing = null;

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java?rev=1744736&r1=1744735&r2=1744736&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
Fri May 20 13:43:54 2016
@@ -29,7 +29,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.felix.scr.impl.Activator;
 import org.apache.felix.scr.impl.helper.ComponentMethods;
 import org.apache.felix.scr.impl.helper.SimpleLogger;
 import org.apache.felix.scr.impl.manager.AbstractComponentManager;
@@ -819,7 +818,12 @@ public class ConfigurableComponentHolder
 
     public boolean isLogEnabled( int level )
     {
-        return Activator.isLogEnabled( level );
+        ComponentActivator activator = getActivator();
+        if ( activator != null )
+        {
+            return activator.isLogEnabled( level );
+        }
+        return false;
     }
 
     public void log( int level, String message, Throwable ex )

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/RegionConfigurationSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/RegionConfigurationSupport.java?rev=1744736&r1=1744735&r2=1744736&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/RegionConfigurationSupport.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/RegionConfigurationSupport.java
Fri May 20 13:43:54 2016
@@ -29,7 +29,6 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.felix.scr.impl.Activator;
-import org.apache.felix.scr.impl.ComponentRegistry;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -43,15 +42,15 @@ import org.osgi.service.cm.Configuration
 import org.osgi.service.cm.ConfigurationPermission;
 import org.osgi.service.log.LogService;
 
-public class RegionConfigurationSupport implements ConfigurationListener
+public abstract class RegionConfigurationSupport implements ConfigurationListener
 {
 
+    // the name of the ConfigurationAdmin service
+    public static final String CONFIGURATION_ADMIN = "org.osgi.service.cm.ConfigurationAdmin";
+
     private final BundleContext caBundleContext;
     private final Long bundleId;
     
-    // the registry of components to be configured
-    private final ComponentRegistry m_registry;
-    
     private final AtomicInteger reference = new AtomicInteger(1);
 
     // the service m_registration of the ConfigurationListener service
@@ -63,9 +62,8 @@ public class RegionConfigurationSupport
      * @param bundleContext of the ConfigurationAdmin we are tracking
      * @param registry
      */
-    public RegionConfigurationSupport(ServiceReference<ConfigurationAdmin> reference,
final ComponentRegistry registry)
+    public RegionConfigurationSupport(ServiceReference<ConfigurationAdmin> reference)
     {
-        this.m_registry = registry;
         Bundle bundle = reference.getBundle();
         this.bundleId = bundle.getBundleId();
         this.caBundleContext = bundle.getBundleContext();
@@ -124,7 +122,7 @@ public class RegionConfigurationSupport
             }
             final List<String> confPids = holder.getComponentMetadata().getConfigurationPid();
 
-            final ServiceReference<?> caRef = bundleContext.getServiceReference(ComponentRegistry.CONFIGURATION_ADMIN);
+            final ServiceReference<?> caRef = bundleContext.getServiceReference(CONFIGURATION_ADMIN);
             if (caRef != null)
             {
                 final Object cao = bundleContext.getService(caRef);
@@ -246,16 +244,7 @@ public class RegionConfigurationSupport
 
         // iterate over all components which must be configured with this pid
         // (since DS 1.2, components may specify a specific configuration PID (112.4.4 configuration-pid)
-        Collection<ComponentHolder<?>> holders;
-
-        if (factoryPid == null)
-        {
-            holders = this.m_registry.getComponentHoldersByPid(pid);
-        }
-        else
-        {
-            holders = this.m_registry.getComponentHoldersByPid(factoryPid);
-        }
+        Collection<ComponentHolder<?>> holders = getComponentHolders(factoryPid
!= null ? factoryPid : pid);
 
         Activator.log(LogService.LOG_DEBUG, null, "configurationEvent: Handling {0}  of Configuration
PID={1} for component holders {2}",
                 new Object[] {getEventType(event), pid, holders},
@@ -402,6 +391,8 @@ public class RegionConfigurationSupport
         }
     }
 
+    protected abstract Collection<ComponentHolder<?>> getComponentHolders(TargetedPID
pid);
+
 
     private String getEventType(ConfigurationEvent event)
     {
@@ -463,8 +454,7 @@ public class RegionConfigurationSupport
     private ConfigurationInfo getConfigurationInfo(final TargetedPID pid, TargetedPID targetedPid,
             ComponentHolder<?> componentHolder, final BundleContext bundleContext)
     {
-        final ServiceReference caRef = bundleContext
-            .getServiceReference(ComponentRegistry.CONFIGURATION_ADMIN);
+        final ServiceReference caRef = bundleContext.getServiceReference(CONFIGURATION_ADMIN);
         if (caRef != null)
         {
             try

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=1744736&r1=1744735&r2=1744736&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 May 20 13:43:54 2016
@@ -40,7 +40,6 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
-import org.apache.felix.scr.impl.Activator;
 import org.apache.felix.scr.impl.config.ComponentActivator;
 import org.apache.felix.scr.impl.config.ComponentContainer;
 import org.apache.felix.scr.impl.config.ComponentManager;
@@ -1028,7 +1027,12 @@ public abstract class AbstractComponentM
      */
     public boolean isLogEnabled( int level )
     {
-        return Activator.isLogEnabled( level );
+        ComponentActivator activator = getActivator();
+        if ( activator != null )
+        {
+            return activator.isLogEnabled( level );
+        }
+        return false;
     }
 
 



Mime
View raw message