felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1543739 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: Activator.java config/ScrConfiguration.java
Date Wed, 20 Nov 2013 09:17:47 GMT
Author: gnodet
Date: Wed Nov 20 09:17:46 2013
New Revision: 1543739

URL: http://svn.apache.org/r1543739
Log:
[FELIX-4309] Make timeout configurable

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

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=1543739&r1=1543738&r2=1543739&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 Wed Nov 20 09:17:46
2013
@@ -24,7 +24,6 @@ import java.text.MessageFormat;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.felix.scr.impl.config.ScrConfiguration;
@@ -187,7 +186,7 @@ public class Activator extends AbstractE
 
         public void destroy() {
             try {
-                this.started.await(60, TimeUnit.SECONDS);
+                this.started.await(m_configuration.stopTimeout(), TimeUnit.MILLISECONDS);
             } catch (InterruptedException e) {
                 log( LogService.LOG_WARNING, m_context.getBundle(), "The wait for bundle
{0}/{1} being started before destruction has been interrupted.",
                         new Object[] {bundle.getSymbolicName(), bundle.getBundleId()}, e
);

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=1543739&r1=1543738&r2=1543739&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 Wed
Nov 20 09:17:46 2013
@@ -63,10 +63,14 @@ public class ScrConfiguration
     public static final String PROP_DELAYED_KEEP_INSTANCES = "ds.delayed.keepInstances";
 
     public static final String PROP_INFO_SERVICE = "ds.info.service";
-    
+
     public static final String PROP_LOCK_TIMEOUT = "ds.lock.timeout.milliseconds";
-    
+
+    public static final String PROP_STOP_TIMEOUT = "ds.stop.timeout.milliseconds";
+
     public static final long DEFAULT_LOCK_TIMEOUT_MILLISECONDS = 5000;
+
+    public static final long DEFAULT_STOP_TIMEOUT_MILLISECONDS = 60000;
     
     public static final String PROP_LOGLEVEL = "ds.loglevel";
 
@@ -92,6 +96,8 @@ public class ScrConfiguration
     
     private long lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
 
+    private long stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
+
     private BundleContext bundleContext;
 
     private ServiceRegistration managedService;
@@ -146,6 +152,7 @@ public class ScrConfiguration
                 keepInstances = false;
                 infoAsService = false;
                 lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
+                stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
             }
             else
             {
@@ -154,6 +161,7 @@ public class ScrConfiguration
                 keepInstances = getDefaultKeepInstances();
                 infoAsService = getDefaultInfoAsService();
                 lockTimeout = getDefaultLockTimeout();
+                stopTimeout = getDefaultStopTimeout();
             }
         }
         else
@@ -164,6 +172,8 @@ public class ScrConfiguration
             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;
         }
         if ( scrCommand != null )
         {
@@ -202,6 +212,11 @@ public class ScrConfiguration
         return lockTimeout;
     }
 
+    public long stopTimeout()
+    {
+        return stopTimeout;
+    }
+
     private boolean getDefaultFactoryEnabled()
     {
         return VALUE_TRUE.equals( bundleContext.getProperty( PROP_FACTORY_ENABLED ) );
@@ -234,6 +249,16 @@ public class ScrConfiguration
         return Long.parseLong( val );
     }
 
+    private long getDefaultStopTimeout()
+    {
+        String val = bundleContext.getProperty( PROP_STOP_TIMEOUT);
+        if ( val == null)
+        {
+            return DEFAULT_STOP_TIMEOUT_MILLISECONDS;
+        }
+        return Long.parseLong( val );
+    }
+
 
     private int getLogLevel( final Object levelObject )
     {



Mime
View raw message