geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1390068 - in /geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main: Bootstrapper.java FrameworkLauncher.java
Date Tue, 25 Sep 2012 19:17:37 GMT
Author: gawor
Date: Tue Sep 25 19:17:37 2012
New Revision: 1390068

URL: http://svn.apache.org/viewvc?rev=1390068&view=rev
Log:
GERONIMO-5764: Move logic in revision 1146683 to FrameworkLauncher and only apply it to the
bundles listed in etc/startup.properties

Modified:
    geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
    geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java?rev=1390068&r1=1390067&r2=1390068&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/Bootstrapper.java
Tue Sep 25 19:17:37 2012
@@ -65,6 +65,11 @@ public class Bootstrapper extends Framew
             Thread.currentThread().setContextClassLoader(newTCCL);
             int exitCode = geronimoMain.execute(opaque);
             if (exitCode == 0) {
+                if (waitForStop) {
+                    // executing main could have installed some additional bundles 
+                    // so check and try to start any unstarted bundles.
+                    checkStartBundles();
+                }
                 destroy(waitForStop);
             } else {
                 destroy(false);

Modified: geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java?rev=1390068&r1=1390067&r2=1390068&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-main/src/main/java/org/apache/geronimo/main/FrameworkLauncher.java
Tue Sep 25 19:17:37 2012
@@ -33,6 +33,7 @@ import java.util.List;
 import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.ServiceLoader;
+import java.util.logging.Logger;
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -96,6 +97,7 @@ public class FrameworkLauncher {
     private Properties configProps = null;
 
     private Framework framework = null;
+    private List<BundleInfo> startList = null;
 
     public void setLog4jConfigFile(String log4jFile) {
         this.log4jFile = log4jFile;
@@ -186,8 +188,9 @@ public class FrameworkLauncher {
         serverInfo = new ServerInfo(geronimoHome, geronimoBase);
         bundleContext.registerService(ServerInfo.class.getName(), serverInfo, null);
 
-        List<BundleInfo> startList = loadStartupProperties();
-        startBundles(bundleContext, startList);
+        startList = loadStartupProperties();
+        
+        startBundles(bundleContext);
 
         framework.start();
     }
@@ -381,7 +384,7 @@ public class FrameworkLauncher {
         mth.invoke(classLoader, bundleFile.toURI().toURL());
     }
 
-    private void startBundles(BundleContext context, List<BundleInfo> startList) throws
Exception {
+    private void startBundles(BundleContext context) throws Exception {
 
         // Retrieve the Start Level service, since it will be needed
         // to set the start level of the installed bundles.
@@ -407,6 +410,23 @@ public class FrameworkLauncher {
 
     }
     
+    protected void checkStartBundles() {
+        for (BundleInfo info : startList) {
+            int state = info.bundle.getState();
+            if (state == Bundle.ACTIVE) {
+                // bundle already is active - nothing to do
+                continue; 
+            } else if ((state == Bundle.RESOLVED || state == Bundle.INSTALLED) &&
!isFragment(info.bundle)) {
+                // try to start the bundle again
+                try {
+                    info.bundle.start();
+                } catch (Exception e) {
+                    Logger.getLogger(FrameworkLauncher.class.getName()).warning("Error starting
bundle " + info.bundle);
+                }
+            }
+        }
+    }
+    
     private static boolean isFragment(Bundle bundle) {
         Dictionary<String, String> headers = bundle.getHeaders();
         return (headers != null && headers.get(Constants.FRAGMENT_HOST) != null);



Mime
View raw message