geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r405229 - in /geronimo/branches/1.1: applications/console-core/src/java/org/apache/geronimo/console/util/ applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ modules/deploy-jsr88/src/java/org/apache/geronimo/de...
Date Mon, 08 May 2006 23:44:06 GMT
Author: dain
Date: Mon May  8 16:44:03 2006
New Revision: 405229

URL: http://svn.apache.org/viewcvs?rev=405229&view=rev
Log:
GERONIMO-1974 Can't "redeploy" a copy of an application using a different version in the module
ID
Applied Aaron's patch
Added call to load(artifact) in redeploy to mark the new configuration as loaded
Added an overridable method hook to configuration migrate settings when redeploying

Modified:
    geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
    geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
    geronimo/branches/1.1/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java

Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
(original)
+++ geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
Mon May  8 16:44:03 2006
@@ -509,7 +509,7 @@
     public J2EEDeployedObject getModuleForConfiguration(Artifact configuration) {
         ConfigurationManager manager = ConfigurationUtil.getConfigurationManager(kernel);
         Configuration config = manager.getConfiguration(configuration);
-        if (config == null) {
+        if (config == null || !manager.isRunning(configuration)) {
             return null; // The configuration is not running, so we can't get its contents
         }
         ConfigurationModuleType type = config.getModuleType();

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
Mon May  8 16:44:03 2006
@@ -75,13 +75,21 @@
             Artifact configId = Artifact.create(config);
 
             if (START_ACTION.equals(action)) {
-                configurationManager.loadConfiguration(configId);
-                configurationManager.startConfiguration(configId);
-                messageStatus = "Started application<br /><br />";
+                if(!configurationManager.isLoaded(configId)) {
+                    configurationManager.loadConfiguration(configId);
+                }
+                if(!configurationManager.isRunning(configId)) {
+                    configurationManager.startConfiguration(configId);
+                    messageStatus = "Started application<br /><br />";
+                }
             } else if (STOP_ACTION.equals(action)) {
-                configurationManager.stopConfiguration(configId);
-                configurationManager.unloadConfiguration(configId);
-                messageStatus = "Stopped application<br /><br />";
+                if(configurationManager.isRunning(configId)) {
+                    configurationManager.stopConfiguration(configId);
+                }
+                if(configurationManager.isLoaded(configId)) {
+                    configurationManager.unloadConfiguration(configId);
+                    messageStatus = "Stopped application<br /><br />";
+                }
             } else if (UNINSTALL_ACTION.equals(action)) {
                 configurationManager.uninstallConfiguration(configId);
                 messageStatus = "Uninstalled application<br /><br />";

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
Mon May  8 16:44:03 2006
@@ -42,6 +42,7 @@
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 import org.apache.geronimo.deployment.plugin.ConfigIDExtractor;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.kernel.repository.Artifact;
 
 public class DeploymentPortlet extends BasePortlet {
     private PortletRequestDispatcher deployView;
@@ -117,6 +118,9 @@
                 ProgressObject progress;
                 if(isRedeploy) {
                     TargetModuleID[] targets = identifyTargets(moduleFile, planFile, mgr.getAvailableModules(null,
all));
+                    if(targets.length == 0) {
+                        throw new PortletException("Unable to identify modules to replace.
 Please include a Geronimo deployment plan or use the command-line deployment tool.");
+                    }
                     progress = mgr.redeploy(targets, moduleFile, planFile);
                 } else {
                     progress = mgr.distribute(all, moduleFile, planFile);
@@ -161,9 +165,14 @@
                 }
             }
             if(moduleId != null) {
-                modules.addAll(ConfigIDExtractor.identifyTargetModuleIDs(allModules, moduleId));
+                modules.addAll(ConfigIDExtractor.identifyTargetModuleIDs(allModules, moduleId,
true));
             } else {
-                throw new PortletException("Unable to calculate a ModuleID from supplied
module and/or plan.");
+                String name = module != null ? module.getName() : plan.getName();
+                int pos = name.lastIndexOf('.');
+                if(pos > -1) {
+                    name = name.substring(0, pos);
+                }
+                modules.addAll(ConfigIDExtractor.identifyTargetModuleIDs(allModules, Artifact.DEFAULT_GROUP_ID+"/"+name+"//",
true));
             }
         } catch (IOException e) {
             throw new PortletException("Unable to read input files: "+e.getMessage());

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
Mon May  8 16:44:03 2006
@@ -37,6 +37,7 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Version;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.Attributes;
@@ -140,20 +141,25 @@
     /**
      * Given a list of all available TargetModuleIDs and the name of a module,
      * find the TargetModuleIDs that represent that module.
+     *
+     * @param allModules  The list of all available modules
+     * @param name        The module name to search for
+     * @param fromPlan    Should be true if the module name was loaded from a
+     *                    deployment plan (thus no group means the default
+     *                    group) or false if the module name was provided by
+     *                    the user (thus no group means any group).
+     *
      * @throws DeploymentException If no TargetModuleIDs have that module.
      */
-    public static Collection identifyTargetModuleIDs(TargetModuleID[] allModules, String
name) throws DeploymentException {
+    public static Collection identifyTargetModuleIDs(TargetModuleID[] allModules, String
name, boolean fromPlan) throws DeploymentException {
         List list = new LinkedList();
         int pos;
         if((pos = name.indexOf('|')) > -1) {
             String target = name.substring(0, pos);
             String module = name.substring(pos+1);
             Artifact artifact = Artifact.create(module);
-            if(artifact.getGroupId() == null || artifact.getType() == null) {
-                artifact = new Artifact(artifact.getGroupId() == null ? Artifact.DEFAULT_GROUP_ID
: artifact.getGroupId(),
-                        artifact.getArtifactId(), artifact.getVersion(),
-                        artifact.getType() == null ? "car" : artifact.getType());
-            }
+            artifact = new Artifact(artifact.getGroupId() == null && fromPlan ? Artifact.DEFAULT_GROUP_ID
: artifact.getGroupId(),
+                    artifact.getArtifactId(), fromPlan ? (Version)null : artifact.getVersion(),
artifact.getType());
             // First pass: exact match
             for(int i=0; i<allModules.length; i++) {
                 if(allModules[i].getTarget().getName().equals(target) && artifact.matches(Artifact.create(allModules[i].getModuleID())))
{
@@ -165,11 +171,13 @@
             return list;
         }
         // second pass: module matches
-        Artifact artifact = Artifact.create(name);
-        if(artifact.getGroupId() == null || artifact.getType() == null) {
-            artifact = new Artifact(artifact.getGroupId() == null ? Artifact.DEFAULT_GROUP_ID
: artifact.getGroupId(),
-                    artifact.getArtifactId(), artifact.getVersion(),
-                    artifact.getType() == null ? "car" : artifact.getType());
+        Artifact artifact;
+        if (name.indexOf("/") > -1) {
+            artifact = Artifact.create(name);
+            artifact = new Artifact(artifact.getGroupId() == null && fromPlan ? Artifact.DEFAULT_GROUP_ID
: artifact.getGroupId(),
+                    artifact.getArtifactId(), fromPlan ? (Version)null : artifact.getVersion(),
artifact.getType());
+        } else {
+            artifact = new Artifact(fromPlan ? Artifact.DEFAULT_GROUP_ID : null, name, (Version)null,
null);
         }
         for(int i = 0; i < allModules.length; i++) {
             if(artifact.matches(Artifact.create(allModules[i].getModuleID()))) {
@@ -194,6 +202,9 @@
             SAXParser parser = factory.newSAXParser();
             ConfigIdHandler handler = new ConfigIdHandler();
             parser.parse(new InputSource(plan), handler);
+            if(handler.formatIs10) {
+                System.out.println("WARNING: Geronimo deployment plan uses Geronimo 1.0 syntax.
 Please update to Geronimo 1.1 syntax when possible.");
+            }
             return handler.configId;
         } catch (ParserConfigurationException e) {
             throw new IOException("Unable to read plan: "+e.getMessage());
@@ -233,6 +244,7 @@
         private String groupId = "", artifactId = "", version = "", type = "";
         private String inElement = null;
         private Stack parent = new Stack();
+        private boolean formatIs10 = false;
 
         public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
             if(inConfigId) {
@@ -242,6 +254,11 @@
             } else {
                 if(parent.size() == 2 && localName.equals("configId")) {
                     inConfigId = true; // only document/environment/configId, not e.g. configId
in nested plan in EAR
+                } else {
+                    if(parent.size() == 0 && attributes.getIndex("configId") >
-1) {
+                        configId = attributes.getValue("configId");
+                        formatIs10 = true;
+                    }
                 }
             }
             parent.push(localName);
@@ -249,6 +266,7 @@
 
         public void characters(char ch[], int start, int length) throws SAXException {
             if(inElement != null) {
+                formatIs10 = false;
                 if(inElement.equals("groupId")) groupId += new String(ch, start, length);
                 else if(inElement.equals("artifactId")) artifactId += new String(ch, start,
length);
                 else if(inElement.equals("version")) version += new String(ch, start, length);
@@ -269,10 +287,9 @@
         }
 
         public void endDocument() throws SAXException {
-            if(type.equals("")) {
-                type = "car";
+            if(!formatIs10) {
+                configId = groupId+"/"+artifactId+"/"+version+"/"+type;
             }
-            configId = groupId+"/"+artifactId+"/"+version+"/"+type;
         }
     }
 }

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java
Mon May  8 16:44:03 2006
@@ -70,16 +70,22 @@
                     copyTo(deploymentPlan, deploymentStream);
                 }
             }
-            Artifact configID;
+            Artifact configID = null;
             if(deploymentPlan != null) {
-                configID = Artifact.create(ConfigIDExtractor.extractModuleIdFromPlan(deploymentPlan));
+                String extracted = ConfigIDExtractor.extractModuleIdFromPlan(deploymentPlan);
+                if(extracted == null) {
+                    throw new IllegalStateException("Unable to find a module ID in the deployment
plan -- is it valid??");
+                }
+                configID = Artifact.create(extracted);
             } else {
-                configID = Artifact.create(ConfigIDExtractor.extractModuleIdFromArchive(moduleArchive));
+                String extracted = ConfigIDExtractor.extractModuleIdFromArchive(moduleArchive);
+                if(extracted != null) {
+                    configID = Artifact.create(extracted);
+                }
             }
-            if(configID.getGroupId() == null || configID.getType() == null) {
-                configID = new Artifact(configID.getGroupId() == null ? Artifact.DEFAULT_GROUP_ID
: configID.getGroupId(),
-                        configID.getArtifactId(), configID.getVersion(),
-                        configID.getType() == null ? "car" : configID.getType());
+            if(configID != null && configID.getGroupId() == null) {
+                configID = new Artifact(Artifact.DEFAULT_GROUP_ID, configID.getArtifactId(),
+                                        configID.getVersion(), configID.getType());
             }
 
             ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
@@ -87,8 +93,10 @@
                 for (int i = 0; i < modules.length; i++) {
                     TargetModuleIDImpl module = (TargetModuleIDImpl) modules[i];
                     Artifact artifact = Artifact.create(module.getModuleID());
-                    if(configID.isResolved()) {
-                        if(configID.equals(artifact)) {
+                    if(configID != null && configID.isResolved()) {
+                        if(configID.getGroupId().equals(artifact.getGroupId()) &&
+                                configID.getArtifactId().equals(artifact.getArtifactId())
&&
+                                configID.getVersion().equals(artifact.getVersion())) {
                             redeploySameConfiguration(configurationManager, artifact, module.getTarget());
                         } else {
                             redeployUpdatedConfiguration(configurationManager, artifact,
module.getTarget());
@@ -131,6 +139,7 @@
 
         // Activate it
         //todo: make this asynchronous
+        boolean newStarted = false;
         for (Iterator it = results.getStopped().iterator(); it.hasNext();) {
             Artifact name = (Artifact) it.next();
             updateStatus("Stopped "+name);
@@ -146,11 +155,17 @@
         for (Iterator it = results.getStarted().iterator(); it.hasNext();) {
             Artifact name = (Artifact) it.next();
             updateStatus("Started "+name);
+            if(configID.matches(name)) {
+                newStarted = true;
+            }
         }
         for (Iterator it = results.getFailed().keySet().iterator(); it.hasNext();) {
             Artifact name = (Artifact) it.next();
             updateStatus("Failed on "+name+": "+results.getFailedCause(name).getMessage());
             doFail((Exception)results.getFailedCause(name));
+        }
+        if(results.getFailed().size() == 0 && !newStarted) {
+            updateStatus("Note: new module was not started (probably because old module was
not running).");
         }
     }
 

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
Mon May  8 16:44:03 2006
@@ -52,28 +52,28 @@
 
                     // Check to see whether the module is already started
                     Artifact moduleID = Artifact.create(module.getModuleID());
-                    AbstractName abstractName = Configuration.getConfigurationAbstractName(moduleID);
-                    if (kernel.isRunning(abstractName)) {
+                    if (configurationManager.isRunning(moduleID)) {
                         updateStatus("Module " + moduleID + " is already running");
                         Thread.sleep(100);
                         continue;
                     }
 
                     // Load
-                    configurationManager.loadConfiguration(moduleID);
+                    if(!configurationManager.isLoaded(moduleID)) {
+                        configurationManager.loadConfiguration(moduleID);
+                    }
 
                     // Start
                     configurationManager.startConfiguration(moduleID);
 
                     // Determine the child modules of the configuration
                     //TODO might be a hack
-                    String configName = abstractName.getArtifact().toString();
-                    List kids = loadChildren(kernel, configName);
+                    List kids = loadChildren(kernel, moduleID.toString());
 
                     // Build a response obect containg the started configuration and a list
of it's contained modules
                     TargetModuleIDImpl id = new TargetModuleIDImpl(modules[i].getTarget(),
module.getModuleID(),
                             (String[]) kids.toArray(new String[kids.size()]));
-                    if (isWebApp(kernel, configName)) {
+                    if (isWebApp(kernel, moduleID.toString())) {
                         id.setType(ModuleType.WAR);
                     }
                     if (id.getChildTargetModuleID() != null) {

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
Mon May  8 16:44:03 2006
@@ -45,11 +45,13 @@
                 for (int i = 0; i < modules.length; i++) {
                     TargetModuleID module = modules[i];
                     Artifact moduleID = Artifact.create(module.getModuleID());
-                    configurationManager.stopConfiguration(moduleID);
-
-
-                    configurationManager.unloadConfiguration(moduleID);
-                    addModule(module);
+                    if(configurationManager.isRunning(moduleID)) {
+                        configurationManager.stopConfiguration(moduleID);
+                    }
+                    if(configurationManager.isLoaded(moduleID)) {
+                        configurationManager.unloadConfiguration(moduleID);
+                        addModule(module);
+                    }
                 }
             } finally {
                 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
Mon May  8 16:44:03 2006
@@ -59,7 +59,7 @@
                     } catch (InternalKernelException e) {
                         // this is cause by the kernel being already shutdown
                     } catch (NoSuchConfigException e) {
-                        // module was already undeployed - just continue
+                        // module was already unloaded - just continue
                     }
 
                     try {

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
Mon May  8 16:44:03 2006
@@ -143,9 +143,4 @@
         }
         return tlist;
     }
-
-    //todo: remove this method
-    protected static Collection identifyTargetModuleIDs(TargetModuleID[] allModules, String
name) throws DeploymentException {
-        return DeployUtils.identifyTargetModuleIDs(allModules, name);
-    }
 }

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
Mon May  8 16:44:03 2006
@@ -18,6 +18,7 @@
 package org.apache.geronimo.deployment.cli;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.kernel.repository.Artifact;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
@@ -99,11 +100,11 @@
                     plan = test;
                 }
             } else {
-                modules.addAll(identifyTargetModuleIDs(allModules, args[1]));
+                modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[1], false));
             }
         }
         for(int i=2; i<args.length; i++) { // Any arguments beyond 2 must be a ModuleID
or TargetModuleID
-            modules.addAll(identifyTargetModuleIDs(allModules, args[i]));
+            modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
         }
         // If we don't have any moduleIDs, try to guess one.
         if(modules.size() == 0 && connection.isGeronimo()) {
@@ -116,7 +117,8 @@
                     moduleId = DeployUtils.extractModuleIdFromArchive(module);
                     if(moduleId == null) {
                         int pos = module.getName().lastIndexOf('.');
-                        moduleId = pos > -1 ? module.getName().substring(0, pos) : module.getName();
+                        String artifactId = pos > -1 ? module.getName().substring(0, pos)
: module.getName();
+                        moduleId = Artifact.DEFAULT_GROUP_ID+"/"+artifactId+"//";
                         emit("Unable to locate Geronimo deployment plan in archive.  Calculating
default ModuleID from archive name.");
                     }
                 }
@@ -125,7 +127,7 @@
             }
             if(moduleId != null) {
                 emit("Attempting to use ModuleID '"+moduleId+"'");
-                modules.addAll(identifyTargetModuleIDs(allModules, moduleId));
+                modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId,
true));
             } else {
                 emit("Unable to calculate a ModuleID from supplied module and/or plan.");
             }

Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
(original)
+++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
Mon May  8 16:44:03 2006
@@ -63,7 +63,7 @@
         }
         List modules = new ArrayList();
         for(int i=0; i<args.length; i++) {
-            modules.addAll(identifyTargetModuleIDs(allModules, args[i]));
+            modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
         }
         TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
         boolean multiple = isMultipleTargets(ids);

Modified: geronimo/branches/1.1/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
(original)
+++ geronimo/branches/1.1/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
Mon May  8 16:44:03 2006
@@ -163,7 +163,7 @@
 
     public boolean isFileDeployed(File file, String configId) {
         try {
-            DeployUtils.identifyTargetModuleIDs(startupModules, configId).toArray(new TargetModuleID[0]);
+            DeployUtils.identifyTargetModuleIDs(startupModules, configId, true).toArray(new
TargetModuleID[0]);
             return true;
         } catch (DeploymentException e) {
             log.debug("Found new file in deploy directory on startup with ID "+configId);
@@ -279,7 +279,7 @@
             mgr = getDeploymentManager();
             Target[] targets = mgr.getTargets();
             TargetModuleID[] ids = mgr.getAvailableModules(null, targets);
-            ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId).toArray(new
TargetModuleID[0]);
+            ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId, true).toArray(new
TargetModuleID[0]);
             ProgressObject po = mgr.undeploy(ids);
             waitForProgress(po);
             if(po.getDeploymentStatus().isCompleted()) {
@@ -311,7 +311,7 @@
             mgr = getDeploymentManager();
             Target[] targets = mgr.getTargets();
             TargetModuleID[] ids = mgr.getAvailableModules(null, targets);
-            ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId).toArray(new
TargetModuleID[0]);
+            ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId, true).toArray(new
TargetModuleID[0]);
             ProgressObject po = mgr.redeploy(ids, file, null);
             waitForProgress(po);
             if(po.getDeploymentStatus().isCompleted()) {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
Mon May  8 16:44:03 2006
@@ -175,10 +175,10 @@
         return configurationStatus.unload(gc);
     }
 
-    public LinkedHashSet reload(Artifact exitingConfigurationId) throws NoSuchConfigException
{
-        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(exitingConfigurationId);
+    public LinkedHashSet reload(Artifact existingConfigurationId) throws NoSuchConfigException
{
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(existingConfigurationId);
         if (configurationStatus == null) {
-            throw new NoSuchConfigException(exitingConfigurationId);
+            return new LinkedHashSet();
         }
         return configurationStatus.reload();
     }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
Mon May  8 16:44:03 2006
@@ -117,6 +117,13 @@
         }
     }
 
+    protected void migrateConfiguration(Artifact oldName, Artifact newName, Configuration
configuration) throws NoSuchConfigException {
+        super.migrateConfiguration(oldName, newName, configuration);
+        if (configurationList != null) {
+            configurationList.migrateConfiguration(oldName, newName, configuration);
+        }
+    }
+
     protected Configuration load(ConfigurationData configurationData, LinkedHashSet resolvedParentIds,
Map loadedConfigurations) throws InvalidConfigException {
         Artifact configurationId = configurationData.getId();
         AbstractName configurationName = Configuration.getConfigurationAbstractName(configurationId);

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/LifecycleResults.java
Mon May  8 16:44:03 2006
@@ -21,6 +21,7 @@
 import java.util.Set;
 import java.util.Map;
 import java.util.Collections;
+import java.util.Iterator;
 import java.io.Serializable;
 
 import org.apache.geronimo.kernel.repository.Artifact;
@@ -38,8 +39,11 @@
     private final Map failed = new LinkedHashMap();
 
     /**
-     * Was the specified configuration loaded.
-     * @param configurationId the configuration identifier
+     * Checks whether the specified configuration was loaded.
+     *
+     * @param configurationId the configuration identifier, which must be fully
+     *                        resolved (isResolved() == true)
+     *
      * @return true if the specified configuration was loaded during the lifecycle operation
      */
     public boolean wasLoaded(Artifact configurationId) {
@@ -72,8 +76,11 @@
     }
 
     /**
-     * Was the specified configuration unloaded.
-     * @param configurationId the configuration identifier
+     * Checks whether the specified configuration was unloaded.
+     *
+     * @param configurationId the configuration identifier, which must be fully
+     *                        resolved (isResolved() == true)
+     *
      * @return true if the specified configuration was unloaded during the lifecycle operation
      */
     public boolean wasUnloaded(Artifact configurationId) {
@@ -106,8 +113,11 @@
     }
 
     /**
-     * Was the specified configuration started.
-     * @param configurationId the configuration identifier
+     * Checks whether the specified configuration was started.
+     *
+     * @param configurationId the configuration identifier, which must be fully
+     *                        resolved (isResolved() == true)
+     *
      * @return true if the specified configuration was started during the lifecycle operation
      */
     public boolean wasStarted(Artifact configurationId) {
@@ -140,8 +150,11 @@
     }
 
     /**
-     * Was the specified configuration stopped.
-     * @param configurationId the configuration identifier
+     * Checks whether the specified configuration was stopped.
+     *
+     * @param configurationId the configuration identifier, which must be fully
+     *                        resolved (isResolved() == true)
+     *
      * @return true if the specified configuration was stopped during the lifecycle operation
      */
     public boolean wasStopped(Artifact configurationId) {
@@ -174,12 +187,25 @@
     }
 
     /**
-     * Was the specified configuration failed the operation and threw an exception.
-     * @param configurationId the configuration identifier
-     * @return true if the specified configuration failed the operation and threw an exception
during the lifecycle operation
+     * Was the specified configuration failed the operation and threw an
+     * exception.
+     *
+     * @param configurationId the configuration identifier.  May be a partial
+     *                        ID, in which case will check whether any
+     *                        matching conifguration failed.
+     *
+     * @return true if the specified (or any matching) configuration failed
+     *              the operation and threw an exception during the lifecycle
+     *              operation
      */
     public boolean wasFailed(Artifact configurationId) {
-        return failed.containsKey(configurationId);
+        for (Iterator it = failed.keySet().iterator(); it.hasNext();) {
+            Artifact failID = (Artifact) it.next();
+            if(configurationId.matches(failID)) {
+                return true;
+            }
+        }
+        return false;
     }
 
     /**

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
Mon May  8 16:44:03 2006
@@ -685,7 +685,9 @@
     }
 
     protected void removeConfigurationFromModel(Artifact configurationId) throws NoSuchConfigException
{
-        configurationModel.removeConfiguration(configurationId);
+        if(configurationModel.containsConfiguration(configurationId)) {
+            configurationModel.removeConfiguration(configurationId);
+        }
         configurations.remove(configurationId);
     }
 
@@ -714,24 +716,50 @@
             throw new IllegalArgumentException("Artifact "+id+" is not fully resolved");
         }
         Configuration configuration = getConfiguration(id);
-        if (configuration == null) {
-            throw new NoSuchConfigException(id);
-        }
-        ConfigurationData existingConfigurationData = configuration.getConfigurationData();
-        UnloadedConfiguration existingUnloadedConfiguration = new UnloadedConfiguration(existingConfigurationData,
getResolvedParentIds(configuration));
+        if (configuration == null) { // The configuration to reload is not currently loaded
+            ConfigurationData data = null;
+            List storeSnapshot = getStoreList();
+            for (int i = 0; i < storeSnapshot.size(); i++) {
+                ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+                if (store.containsConfiguration(id)) {
+                    try {
+                        data = store.loadConfiguration(id);
+                    } catch (Exception e) {
+                        log.warn("Unable to load existing configuration "+id+" from config
store", e);
+                    }
+                }
+            }
+            if(data == null) {
+                throw new NoSuchConfigException(id);
+            }
+            UnloadedConfiguration existingUnloadedConfiguration = new UnloadedConfiguration(data,
new LinkedHashSet());
+            Artifact newId = new Artifact(id.getGroupId(), id.getArtifactId(), version, id.getType());
+            ConfigurationData newData = null;
+            try {
+                newData = loadConfigurationData(newId, monitor);
+            } catch (Exception e) {
+                monitor.finished();
+                throw new LifecycleException("reload", id, e);
+            }
 
-        Artifact newId = new Artifact(id.getGroupId(), id.getArtifactId(), version, id.getType());
+            return reloadConfiguration(existingUnloadedConfiguration, newData, monitor);
+        } else { // The configuration to reload is loaded
+            ConfigurationData existingConfigurationData = configuration.getConfigurationData();
+            UnloadedConfiguration existingUnloadedConfiguration = new UnloadedConfiguration(existingConfigurationData,
getResolvedParentIds(configuration));
 
-        // reload the ConfigurationData from a store
-        ConfigurationData configurationData = null;
-        try {
-            configurationData = loadConfigurationData(newId, monitor);
-        } catch (Exception e) {
-            monitor.finished();
-            throw new LifecycleException("reload", id, e);
-        }
+            Artifact newId = new Artifact(id.getGroupId(), id.getArtifactId(), version, id.getType());
 
-        return reloadConfiguration(existingUnloadedConfiguration, configurationData, monitor);
+            // reload the ConfigurationData from a store
+            ConfigurationData configurationData = null;
+            try {
+                configurationData = loadConfigurationData(newId, monitor);
+            } catch (Exception e) {
+                monitor.finished();
+                throw new LifecycleException("reload", id, e);
+            }
+
+            return reloadConfiguration(existingUnloadedConfiguration, configurationData,
monitor);
+        }
     }
 
     public LifecycleResults reloadConfiguration(ConfigurationData configurationData) throws
LifecycleException, NoSuchConfigException {
@@ -872,14 +900,16 @@
             stop(existingConfiguration);
             monitor.succeeded(existingConfigurationId);
             results.addStopped(existingConfigurationId);
-        } else {
+        } else if(existingConfiguration != null) {
             // call stop just to be sure the beans aren't running
             stop(existingConfiguration);
         }
-        monitor.unloading(existingConfigurationId);
-        unload(existingConfiguration);
-        monitor.succeeded(existingConfigurationId);
-        results.addUnloaded(existingConfigurationId);
+        if(existingConfiguration != null) {
+            monitor.unloading(existingConfigurationId);
+            unload(existingConfiguration);
+            monitor.succeeded(existingConfigurationId);
+            results.addUnloaded(existingConfigurationId);
+        }
 
         //
         // load the new configurations
@@ -964,14 +994,24 @@
                 addNewConfigurationsToModel(loadedParents);
 
                 // now ugrade the existing node in the model
-                configurationModel.upgradeConfiguration(existingConfigurationId,
-                        newConfigurationId,
-                        getConfigurationIds(getLoadParents(newConfiguration)),
-                        getConfigurationIds(getStartParents(newConfiguration)));
+                if(configurationModel.containsConfiguration(existingConfigurationId)) {
+                    configurationModel.upgradeConfiguration(existingConfigurationId,
+                            newConfigurationId,
+                            getConfigurationIds(getLoadParents(newConfiguration)),
+                            getConfigurationIds(getStartParents(newConfiguration)));
+                } else {
+                    configurationModel.addConfiguation(newConfigurationId,
+                            getConfigurationIds(getLoadParents(newConfiguration)),
+                            getConfigurationIds(getStartParents(newConfiguration)));
+                    load(newConfigurationId);
+                }
 
                 // replace the configuraiton in he configurations map
                 configurations.remove(existingConfiguration);
                 configurations.put(newConfigurationId, newConfiguration);
+
+                // migrate the configuration settings
+                migrateConfiguration(existingConfigurationId, newConfigurationId, newConfiguration);
             } catch (Exception e) {
                 monitor.failed(configurationId, e);
                 results.addFailed(configurationId, e);
@@ -1119,6 +1159,17 @@
             }
         }
 
+        //
+        // If nothing failed, delete all the unloaded modules that weren't reloaded
+        //
+        if(!results.wasLoaded(existingConfigurationId) && !results.wasFailed(existingConfigurationId))
{
+            try {
+                uninstallConfiguration(existingConfigurationId);
+            } catch (IOException e) {
+                log.error("Unable to uninstall configuration "+existingConfigurationId, e);
+            }
+        }
+
         monitor.finished();
         if (results.wasFailed(newConfigurationId) || !results.wasLoaded(newConfigurationId))
{
             throw new LifecycleException("restart", newConfigurationId, results);
@@ -1126,6 +1177,9 @@
         return results;
     }
 
+    protected void migrateConfiguration(Artifact oldName, Artifact newName, Configuration
configuration) throws NoSuchConfigException {
+    }
+
     private static LinkedHashSet getResolvedParentIds(Configuration configuration) {
         LinkedHashSet resolvedParentIds = new LinkedHashSet();
         for (Iterator iterator = configuration.getClassParents().iterator(); iterator.hasNext();)
{
@@ -1149,8 +1203,12 @@
             throw new IllegalArgumentException("Artifact "+configurationId+" is not fully
resolved");
         }
         if (configurations.containsKey(configurationId)) {
-            stopConfiguration(configurationId);
-            unloadConfiguration(configurationId);
+            if(isRunning(configurationId)) {
+                stopConfiguration(configurationId);
+            }
+            if(isLoaded((configurationId))) {
+                unloadConfiguration(configurationId);
+            }
         }
 
         List storeSnapshot = getStoreList();
@@ -1161,6 +1219,7 @@
             }
         }
 
+        removeConfigurationFromModel(configurationId);
     }
 
     public ArtifactResolver getArtifactResolver() {

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=405229&r1=405228&r2=405229&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Mon May  8 16:44:03 2006
@@ -334,6 +334,7 @@
         }
         File location = repository.getLocation(configId);
         IOUtil.recursiveDelete(location);
+        //todo: for Maven 2 repo, delete the version directory if there's nothing left in
it (probably the case)
 
         if (configurationInfo != null) {
             IOException ioException = null;



Mime
View raw message