geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r941887 - in /geronimo/server/trunk/framework/modules: geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ geronimo-system/src/main/java/org/apache/geronimo/system/main/ geronimo-system/src/main/java/org/apache/geronimo/s...
Date Thu, 06 May 2010 20:04:39 GMT
Author: gawor
Date: Thu May  6 20:04:39 2010
New Revision: 941887

URL: http://svn.apache.org/viewvc?rev=941887&view=rev
Log:
register Main service after the boot configuration is fully initialized

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedDaemon.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/osgi/BootActivator.java

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java?rev=941887&r1=941886&r2=941887&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
Thu May  6 20:04:39 2010
@@ -20,7 +20,6 @@ package org.apache.geronimo.deployment.c
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -38,14 +37,13 @@ import org.apache.geronimo.crypto.Encryp
 import org.apache.geronimo.deployment.cli.DeployUtils.SavedAuthentication;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.main.Main;
+import org.apache.geronimo.kernel.util.Main;
 import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
  */
-public class StopServer implements Main, GBeanLifecycle {
+public class StopServer implements Main {
 
 	public static final String DEFAULT_PORT = "1099"; // 1099 is used by java.rmi.registry.Registry
 
@@ -217,15 +215,4 @@ public class StopServer implements Main,
         return GBEAN_INFO;
     }
 
-    public void doFail() {
-    }
-
-    public void doStart() throws Exception {
-        bundle.getBundleContext().registerService(Main.class.getName(), this, new Hashtable());
-    }
-
-    public void doStop() throws Exception {
-        // TODO: unregister Main service?
-    }
-
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java?rev=941887&r1=941886&r2=941887&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedClientCommandLine.java
Thu May  6 20:04:39 2010
@@ -16,20 +16,17 @@
  */
 package org.apache.geronimo.system.main;
 
-import java.util.Hashtable;
-
 import org.apache.geronimo.cli.client.ClientCLParser;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.main.Main;
+import org.apache.geronimo.kernel.util.Main;
 import org.osgi.framework.Bundle;
 
 /**
  * @version $Revision: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
  */
-public class EmbeddedClientCommandLine extends ClientCommandLine implements Main, GBeanLifecycle
{
+public class EmbeddedClientCommandLine extends ClientCommandLine implements Main {
     
     private final Kernel kernel;
     private final Bundle bundle;
@@ -74,13 +71,5 @@ public class EmbeddedClientCommandLine e
 
     public void doFail() {
     }
-
-    public void doStart() throws Exception {
-        bundle.getBundleContext().registerService(Main.class.getName(), this, new Hashtable());
-    }
-
-    public void doStop() throws Exception {
-        // TODO: unregister Main service?
-    }
     
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedDaemon.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedDaemon.java?rev=941887&r1=941886&r2=941887&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedDaemon.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/main/EmbeddedDaemon.java
Thu May  6 20:04:39 2010
@@ -19,7 +19,6 @@ package org.apache.geronimo.system.main;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Hashtable;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -29,7 +28,6 @@ import org.apache.geronimo.gbean.Abstrac
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
@@ -38,7 +36,7 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.LifecycleMonitor;
 import org.apache.geronimo.kernel.config.PersistentConfigurationList;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.main.Main;
+import org.apache.geronimo.kernel.util.Main;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,7 +44,7 @@ import org.slf4j.LoggerFactory;
 /**
  * @version $Rev:385659 $ $Date: 2007-03-07 14:40:07 +1100 (Wed, 07 Mar 2007) $
  */
-public class EmbeddedDaemon implements Main, GBeanLifecycle {
+public class EmbeddedDaemon implements Main {
     private static final Logger log = LoggerFactory.getLogger(EmbeddedDaemon.class);
 
     protected final Kernel kernel;
@@ -231,15 +229,4 @@ public class EmbeddedDaemon implements M
         return GBEAN_INFO;
     }
 
-    public void doFail() {
-    }
-
-    public void doStart() throws Exception {
-        bundle.getBundleContext().registerService(Main.class.getName(), this, new Hashtable());
-    }
-    
-    public void doStop() throws Exception {
-        // TODO: unregister Main service?
-    }
-
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/osgi/BootActivator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/osgi/BootActivator.java?rev=941887&r1=941886&r2=941887&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/osgi/BootActivator.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/osgi/BootActivator.java
Thu May  6 20:04:39 2010
@@ -17,39 +17,26 @@
  * under the License.
  */
 
-
 package org.apache.geronimo.system.osgi;
 
-import java.util.Dictionary;
-import java.util.Set;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.net.URL;
 import java.io.InputStream;
-import java.io.IOException;
+import java.net.URL;
+import java.util.Dictionary;
 
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
-import org.apache.geronimo.kernel.osgi.ConfigurationActivator;
-import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.PersistentConfigurationList;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.DebugLoggingLifecycleMonitor;
-import org.apache.geronimo.kernel.config.LifecycleMonitor;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.system.main.StartupMonitor;
+import org.apache.geronimo.kernel.osgi.ConfigurationActivator;
+import org.apache.geronimo.kernel.util.Main;
 import org.apache.geronimo.system.main.LongStartupMonitor;
-import org.apache.geronimo.system.main.ServerStatus;
+import org.apache.geronimo.system.main.StartupMonitor;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -87,78 +74,13 @@ public class BootActivator implements Bu
                 in.close();
             }
 
-            /*
-            List<Artifact> configs = new ArrayList<Artifact>();
-            AbstractNameQuery query = new AbstractNameQuery(PersistentConfigurationList.class.getName());
-
-//        if (configs.isEmpty()) {
-            // --override wasn't used (nothing explicit), see what was running before
-            Set<AbstractName> configLists = kernel.listGBeans(query);
-            for (AbstractName configListName : configLists) {
-                try {
-                    configs.addAll((List<Artifact>) kernel.invoke(configListName, "restore"));
-                } catch (IOException e) {
-                    System.err.println("Unable to restore last known configurations");
-                    e.printStackTrace();
-//                    shutdownKernel();
-                    return;
-                }
-            }
-//        }
-            LifecycleMonitor lifecycleMonitor = new DebugLoggingLifecycleMonitor(log);
-
-            monitor.foundModules(configs.toArray(new Artifact[configs.size()]));
-
-            // load the rest of the configurations
-            try {
-                ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
-                try {
-                    List<Artifact> unloadedConfigs = new ArrayList<Artifact>(configs);
-                    int unloadedConfigsCount;
-                    do {
-                        unloadedConfigsCount = unloadedConfigs.size();
-                        LinkedHashSet<Artifact> sorted = configurationManager.sort(unloadedConfigs,
lifecycleMonitor);
-                        for (Artifact configID : sorted) {
-                            monitor.moduleLoading(configID);
-                            configurationManager.loadConfiguration(configID, lifecycleMonitor);
-                            unloadedConfigs.remove(configID);
-                            monitor.moduleLoaded(configID);
-                            monitor.moduleStarting(configID);
-                            configurationManager.startConfiguration(configID, lifecycleMonitor);
-                            monitor.moduleStarted(configID);
-                        }
-                    } while (unloadedConfigsCount > unloadedConfigs.size());
-                    if (!unloadedConfigs.isEmpty()) {
-                        throw new InvalidConfigException("Could not locate configs to start:
" + unloadedConfigs);
-                    }
-                    // the server has finished loading the persistent configuration so inform
the gbean
-                    AbstractNameQuery startedQuery = new AbstractNameQuery(ServerStatus.class.getName());
-                    Set<AbstractName> statusBeans = kernel.listGBeans(startedQuery);
-                    for (AbstractName statusName : statusBeans) {
-                        ServerStatus status = (ServerStatus) kernel.getGBean(statusName);
-                        if (status != null) {
-                            status.setServerStarted(true);
-                        }
-                    }
-                } finally {
-                    ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
-                }
-            } catch (Exception e) {
-                //Exception caught when starting configurations, starting kernel shutdown
-                monitor.serverStartFailed(e);
-//            shutdownKernel();
-                return;
-            }
-
-            // Tell every persistent configuration list that the kernel is now fully started
-            configLists = kernel.listGBeans(query);
-            for (AbstractName configListName : configLists) {
-                kernel.setAttribute(configListName, "kernelFullyStarted", Boolean.TRUE);
+            // register Main service if Main GBean present
+            if (bundleContext.getServiceReference(org.apache.geronimo.main.Main.class.getName())
== null) { 
+                registerMainService(bundleContext, kernel);
+            } else {
+                System.out.println("Main service already registered");
             }
 
-            // Startup sequence is finished
-            monitor.startupFinished();
-            */
         } else {
             configurationActivator = new ConfigurationActivator();
             configurationActivator.start(bundleContext);
@@ -176,4 +98,21 @@ public class BootActivator implements Bu
             configurationActivator.stop(bundleContext);
         }
     }
-}
\ No newline at end of file
+    
+    private void registerMainService(BundleContext bundleContext, Kernel kernel) {
+        try {
+            final Main main = kernel.getGBean(Main.class);
+            bundleContext.registerService(
+                    org.apache.geronimo.main.Main.class.getName(), 
+                    new org.apache.geronimo.main.Main() {
+                        public int execute(Object opaque) {
+                            return main.execute(opaque);
+                        }                    
+                    }, 
+                    null);
+            System.out.println("Main service registered");
+        } catch (GBeanNotFoundException e) {
+            // ignore
+        }
+    }
+}



Mime
View raw message