felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1634911 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: Activator.java config/ScrConfiguration.java config/ScrManagedService.java
Date Tue, 28 Oct 2014 16:49:59 GMT
Author: djencks
Date: Tue Oct 28 16:49:58 2014
New Revision: 1634911

URL: http://svn.apache.org/r1634911
Log:
[FELIX-4467] Reduce churn when a configuration for DS is supplied and the global extender
property is not changed

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedService.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=1634911&r1=1634910&r2=1634911&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Tue Oct 28 16:49:58
2014
@@ -117,6 +117,7 @@ public class Activator extends AbstractE
         }
         if ( m_packageAdmin != null )
         {
+            log( LogService.LOG_INFO, m_bundle, "Stopping to restart with new globalExtender
setting: " + globalExtender, null );
             //this really is a restart, not the initial start
             try
             {
@@ -129,6 +130,7 @@ public class Activator extends AbstractE
         }
         try
         {
+            log( LogService.LOG_INFO, m_bundle, "Starting with globalExtender setting: "
+ globalExtender, null );
             super.start( context );
         }
         catch ( Exception e )
@@ -381,12 +383,14 @@ public class Activator extends AbstractE
 
     @Override
     protected void debug(Bundle bundle, String msg) {
-        log( LogService.LOG_DEBUG, bundle, msg, null );
+        final String message = MessageFormat.format( msg + " bundle: {0}/{1}", bundle.getSymbolicName(),
bundle.getBundleId() );
+        log( LogService.LOG_DEBUG, bundle, message, null );
     }
 
     @Override
     protected void warn(Bundle bundle, String msg, Throwable t) {
-        log( LogService.LOG_WARNING, bundle, msg, t );
+        final String message = MessageFormat.format( msg + " bundle: {0}/{1}", bundle.getSymbolicName(),
bundle.getBundleId() );
+        log( LogService.LOG_WARNING, bundle, message, t );
     }
 
     @Override

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java?rev=1634911&r1=1634910&r2=1634911&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java Tue
Oct 28 16:49:58 2014
@@ -130,11 +130,8 @@ public class ScrConfiguration
         managedService = ( ServiceRegistration<ManagedService> ) bundleContext.registerService("org.osgi.service.cm.ManagedService",
new ScrManagedServiceServiceFactory(this),
             props);
         
-        if ( globalExtender == null)  //no config admin or no configuration
-        {
-            // configure from bundle context properties
-            configure( null );            
-        }
+        // configure from bundle context properties
+        configure( null, false );            
     }
 
     public void stop() {
@@ -153,51 +150,64 @@ public class ScrConfiguration
     }
 
     // Called from the ScrManagedService.updated method to reconfigure
-    void configure( Dictionary<String, ?> config )
+    void configure( Dictionary<String, ?> config, boolean fromConfig )
     {
-        Boolean oldGlobalExtender = globalExtender;
-        if ( config == null )
-        {
-            if ( this.bundleContext == null )
-            {
-                logLevel = LogService.LOG_ERROR;
-                factoryEnabled = false;
-                keepInstances = false;
-                infoAsService = false;
-                lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
-                stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
-                globalExtender = false;
+        Boolean newGlobalExtender;
+        Boolean oldGlobalExtender;
+        synchronized (this)
+        {
+            if ( config == null )
+            {
+                if (!fromConfig)
+                {
+                    if (this.bundleContext == null)
+                    {
+                        logLevel = LogService.LOG_ERROR;
+                        factoryEnabled = false;
+                        keepInstances = false;
+                        infoAsService = false;
+                        lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
+                        stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
+                        newGlobalExtender = false;
+                    }
+                    else
+                    {
+                        logLevel = getDefaultLogLevel();
+                        factoryEnabled = getDefaultFactoryEnabled();
+                        keepInstances = getDefaultKeepInstances();
+                        infoAsService = getDefaultInfoAsService();
+                        lockTimeout = getDefaultLockTimeout();
+                        stopTimeout = getDefaultStopTimeout();
+                        newGlobalExtender = getDefaultGlobalExtender();
+                    }
+                }
+                else
+                {
+                    newGlobalExtender = this.globalExtender;
+                }
             }
             else
             {
-                logLevel = getDefaultLogLevel();
-                factoryEnabled = getDefaultFactoryEnabled();
-                keepInstances = getDefaultKeepInstances();
-                infoAsService = getDefaultInfoAsService();
-                lockTimeout = getDefaultLockTimeout();
-                stopTimeout = getDefaultStopTimeout();
-                globalExtender = getDefaultGlobalExtender();
-            }
-        }
-        else
-        {
-            logLevel = getLogLevel( config.get( PROP_LOGLEVEL ) );
-            factoryEnabled = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_FACTORY_ENABLED
) ) );
-            keepInstances = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_DELAYED_KEEP_INSTANCES
) ) );
-            infoAsService = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_INFO_SERVICE)
) );
-            Long timeout = ( Long ) config.get( PROP_LOCK_TIMEOUT );
-            lockTimeout = timeout == null? DEFAULT_LOCK_TIMEOUT_MILLISECONDS: timeout;
-            timeout = ( Long ) config.get( PROP_STOP_TIMEOUT );
-            stopTimeout = timeout == null? DEFAULT_STOP_TIMEOUT_MILLISECONDS: timeout;
-            globalExtender = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_GLOBAL_EXTENDER)
) );
-        }
-        if ( scrCommand != null )
-        {
-            scrCommand.update( infoAsService() );
+                logLevel = getLogLevel( config.get( PROP_LOGLEVEL ) );
+                factoryEnabled = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_FACTORY_ENABLED ) ) );
+                keepInstances = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_DELAYED_KEEP_INSTANCES ) ) );
+                infoAsService = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_INFO_SERVICE) ) );
+                Long timeout = ( Long ) config.get( PROP_LOCK_TIMEOUT );
+                lockTimeout = timeout == null? DEFAULT_LOCK_TIMEOUT_MILLISECONDS: timeout;
+                timeout = ( Long ) config.get( PROP_STOP_TIMEOUT );
+                stopTimeout = timeout == null? DEFAULT_STOP_TIMEOUT_MILLISECONDS: timeout;
+                newGlobalExtender = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_GLOBAL_EXTENDER) ) );
+            }
+            if ( scrCommand != null )
+            {
+                scrCommand.update( infoAsService() );
+            }
+            oldGlobalExtender = this.globalExtender;
+            this.globalExtender = newGlobalExtender;
         }
-        if ( globalExtender != oldGlobalExtender )
+        if ( newGlobalExtender != oldGlobalExtender )
         {
-            activator.restart( globalExtender );
+            activator.restart( newGlobalExtender );
         }
     }
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedService.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedService.java?rev=1634911&r1=1634910&r2=1634911&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedService.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedService.java
Tue Oct 28 16:49:58 2014
@@ -52,6 +52,6 @@ public class ScrManagedService implement
 
     public void updated(Dictionary<String, ?> properties) throws ConfigurationException
     {
-        this.scrConfiguration.configure(properties);
+        this.scrConfiguration.configure(properties, true);
     }
 }



Mime
View raw message