geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r240391 - in /geronimo/trunk/modules: deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/ deployment/src/java/org/apache/geronimo/deployment/ j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ service-builder/src/java...
Date Sat, 27 Aug 2005 05:06:59 GMT
Author: ammulder
Date: Fri Aug 26 22:06:47 2005
New Revision: 240391

URL: http://svn.apache.org/viewcvs?rev=240391&view=rev
Log:
When starting a module, give a message if it's already started
When distributing (or deploying) a module, throw an error if it's
  already available in the server environment
GERONIMO-480

Modified:
    geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
    geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java
    geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
    geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
    geronimo/trunk/modules/servicemix-builder/src/java/org/apache/geronimo/servicemix/deployment/ServiceMixConfigBuilder.java
    geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java

Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
(original)
+++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
Fri Aug 26 22:06:47 2005
@@ -22,10 +22,14 @@
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
 
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 
 /**
@@ -50,7 +54,20 @@
                 for (int i = 0; i < modules.length; i++) {
                     TargetModuleID module = modules[i];
 
+                    // Check to see whether the module is already started
                     URI moduleID = URI.create(module.getModuleID());
+                    try {
+                        if(kernel.getGBeanState(Configuration.getConfigurationObjectName(moduleID))
== State.RUNNING_INDEX) {
+                            updateStatus("Module "+moduleID+" is already running");
+                            Thread.sleep(100);
+                            continue;
+                        }
+                    } catch (GBeanNotFoundException e) {
+                        // That means that the configuration may have been distributed but
has not yet been loaded.
+                        // That's fine, we'll load it next.
+                    }
+                    
+                    // Load and start the module
                     List list = configurationManager.loadRecursive(moduleID);
                     for (int j = 0; j < list.size(); j++) {
                         ObjectName name = (ObjectName) list.get(j);

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java
Fri Aug 26 22:06:47 2005
@@ -20,6 +20,8 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.jar.JarFile;
+import java.net.URI;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.kernel.config.ConfigurationData;
 
@@ -36,6 +38,16 @@
      * @throws org.apache.geronimo.common.DeploymentException if there was a problem with
the configuration
      */
     Object getDeploymentPlan(File planFile, JarFile module) throws DeploymentException;
+
+    /**
+     * Checks what configuration URL will be used for the provided module.
+     * @param plan the deployment plan
+     * @param module the module to build
+     * @return the ID that will be used for the Configuration
+     * @throws IOException if there was a problem reading or writing the files
+     * @throws org.apache.geronimo.common.DeploymentException if there was a problem with
the configuration
+     */
+    URI getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException;
 
     /**
      * Build a configuration from a local file

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
Fri Aug 26 22:06:47 2005
@@ -27,6 +27,7 @@
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
+import java.net.URI;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -37,9 +38,14 @@
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.system.main.CommandLineManifest;
 import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
 
+import javax.management.MalformedObjectNameException;
+
 /**
  * GBean that knows how to deploy modules (by consulting available module builders)
  *
@@ -49,10 +55,12 @@
     private static final Log log = LogFactory.getLog(Deployer.class);
     private final Collection builders;
     private final ConfigurationStore store;
+    private final Kernel kernel;
 
-    public Deployer(Collection builders, ConfigurationStore store) {
+    public Deployer(Collection builders, ConfigurationStore store, Kernel kernel) {
         this.builders = builders;
         this.store = store;
+        this.kernel = kernel;
     }
 
     public List deploy(File moduleFile, File planFile) throws DeploymentException {
@@ -141,6 +149,15 @@
                         (moduleFile == null ? "" : ", moduleFile" + moduleFile.getAbsolutePath()));
             }
 
+            // Make sure this configuration doesn't already exist
+            URI configID = builder.getConfigurationID(plan, module);
+            try {
+                kernel.getGBeanState(Configuration.getConfigurationObjectName(configID));
+                throw new DeploymentException("Module "+configID+" already exists in the
server.  Try to undeploy it first or use the redeploy command.");
+            } catch (GBeanNotFoundException e) {
+                // this is good
+            }
+
             // create a configuration dir to write the configuration during the building
proces
             configurationDir = store.createNewConfigurationDir();
 
@@ -214,13 +231,14 @@
     static {
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(Deployer.class, DEPLOYER);
 
+        infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addOperation("deploy", new Class[]{File.class, File.class});
         infoFactory.addOperation("deploy", new Class[]{File.class, File.class, File.class,
boolean.class, String.class, String.class, String.class});
 
         infoFactory.addReference("Builders", ConfigurationBuilder.class, "ConfigBuilder");
         infoFactory.addReference("Store", ConfigurationStore.class, "ConfigurationStore");
 
-        infoFactory.setConstructor(new String[]{"Builders", "Store"});
+        infoFactory.setConstructor(new String[]{"Builders", "Store", "kernel"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Fri Aug 26 22:06:47 2005
@@ -291,6 +291,11 @@
         return gerApplication;
     }
 
+    public URI getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException
{
+        ApplicationInfo applicationInfo = (ApplicationInfo) plan;
+        return applicationInfo.getConfigId();
+    }
+
     public ConfigurationData buildConfiguration(Object plan, JarFile earFile, File outfile)
throws IOException, DeploymentException {
         assert plan != null;
         ApplicationInfo applicationInfo = (ApplicationInfo) plan;

Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
(original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Fri Aug 26 22:06:47 2005
@@ -144,6 +144,15 @@
         }
     }
 
+    public URI getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException
{
+        ConfigurationType configType = (ConfigurationType) plan;
+        try {
+            return new URI(configType.getConfigId());
+        } catch (URISyntaxException e) {
+            throw new DeploymentException("Invalid configId " + configType.getConfigId(),
e);
+        }
+    }
+
     public ConfigurationData buildConfiguration(Object plan, JarFile unused, File outfile)
throws IOException, DeploymentException {
         ConfigurationType configType = (ConfigurationType) plan;
         String domain = null;

Modified: geronimo/trunk/modules/servicemix-builder/src/java/org/apache/geronimo/servicemix/deployment/ServiceMixConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/servicemix-builder/src/java/org/apache/geronimo/servicemix/deployment/ServiceMixConfigBuilder.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/servicemix-builder/src/java/org/apache/geronimo/servicemix/deployment/ServiceMixConfigBuilder.java
(original)
+++ geronimo/trunk/modules/servicemix-builder/src/java/org/apache/geronimo/servicemix/deployment/ServiceMixConfigBuilder.java
Fri Aug 26 22:06:47 2005
@@ -110,6 +110,15 @@
         }   
     }
 
+    public URI getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException
{
+        Properties properties = (Properties)plan;
+        try {
+            return new URI(properties.getProperty("configID"));
+        } catch (URISyntaxException e1) {
+            throw new DeploymentException("Invalid configuration URI", e1);
+        }
+    }
+
     public ConfigurationData buildConfiguration(Object plan, JarFile module, File outfile)
throws IOException, DeploymentException {
         log.debug("Installing ServiceMix deployment.");
         Properties properties = (Properties)plan;        

Modified: geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java?rev=240391&r1=240390&r2=240391&view=diff
==============================================================================
--- geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java
(original)
+++ geronimo/trunk/modules/spring-builder/src/java/org/apache/geronimo/spring/deployment/SPRConfigBuilder.java
Fri Aug 26 22:06:47 2005
@@ -19,6 +19,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -99,6 +100,15 @@
 
     return this;		// token passed to buildConfiguration()...
   }
+
+    public URI getConfigurationID(Object plan, JarFile sprFile) throws IOException, DeploymentException
{
+        String uid=sprFile.getName();
+        try {
+            return new URI(uid);
+        } catch (URISyntaxException e) {
+            throw new DeploymentException("Unable to construct configuration ID "+sprFile.getName());
+        }
+    }
 
   public ConfigurationData
     buildConfiguration(Object plan, JarFile sprFile, File outfile)



Mime
View raw message