geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r615057 - in /geronimo/server/trunk/framework/modules: geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/
Date Thu, 24 Jan 2008 22:22:30 GMT
Author: djencks
Date: Thu Jan 24 14:22:29 2008
New Revision: 615057

URL: http://svn.apache.org/viewvc?rev=615057&view=rev
Log:
GERONIMO-3784 Make list-plugins and assemble-server commands scriptable.

Modified:
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy?rev=615057&r1=615056&r2=615057&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/AssembleServerCommand.groovy
Thu Jan 24 14:22:29 2008
@@ -19,45 +19,44 @@
 
 package org.apache.geronimo.commands
 
-
 import jline.ConsoleReader
-
+import org.apache.geronimo.deployment.cli.CommandListConfigurations
+import org.apache.geronimo.gshell.clp.Argument
 import org.apache.geronimo.gshell.clp.Option
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
-import org.apache.geronimo.gshell.command.CommandSupport
-import org.apache.geronimo.deployment.cli.ServerConnection
-import org.apache.geronimo.cli.deployer.BaseCommandArgs
-import org.apache.geronimo.deployment.cli.CommandListConfigurations
 import org.apache.geronimo.kernel.repository.Artifact
 
 /**
- * install plugins.
+ * Extract a bunch of plugins into a server.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:assemble-server', description="Extract a geronimo
server from the current one")
+@CommandComponent (id = 'geronimo-commands:assemble-server', description = "Extract a geronimo
server from the current one")
 class AssembleServerCommand
-    extends ConnectCommand
+extends ConnectCommand
 {
 
-    @Option(name='-l', aliases=['--list'], description='refresh plugin list')
+    @Option (name = '-l', aliases = ['--list'], description = 'refresh plugin list')
     boolean refreshList = false
 
-    @Option(name='-t', aliases=['--path'], description='assembly location')
+    @Option (name = '-t', aliases = ['--path'], description = 'assembly location')
     String relativeServerPath = "var/temp/assembly"
 
-    @Option(name='-g', aliases=['--groupId'], description='server groupId')
+    @Option (name = '-g', aliases = ['--groupId'], description = 'server groupId')
     String group
 
-    @Option(name='-a', aliases=['--artifact'], description='server artifact name')
+    @Option (name = '-a', aliases = ['--artifact'], description = 'server artifact name')
     String artifact
 
-    @Option(name='-v', aliases=['--version'], description='server version')
+    @Option (name = '-v', aliases = ['--version'], description = 'server version')
     String version
 
-    @Option(name='-f', aliases=['--format'], description='zip or tar.gz')
+    @Option (name = '-f', aliases = ['--format'], description = 'zip or tar.gz')
     String format = "tar.gz"
 
+    @Argument (multiValued = true)
+    List<String> pluginArtifacts
+
     protected Object doExecute() throws Exception {
         io.out.println("Listing configurations from Geronimo server")
 
@@ -74,10 +73,15 @@
             plugins = command.getLocalPluginCategories(connection.getDeploymentManager(),
consoleReader)
             variables.parent.set("LocalPlugins", plugins)
         }
-        def pluginsToInstall = command.getInstallList(plugins, consoleReader, null)
-        if (pluginsToInstall) {
-            command.assembleServer(connection.getDeploymentManager(), pluginsToInstall, 'repository',
relativeServerPath, consoleReader)
+        if (pluginArtifacts) {
+            command.assembleServer(connection.getDeploymentManager(), pluginArtifacts, plugins,
'repository', relativeServerPath, consoleReader)
             connection.getDeploymentManager().archive(relativeServerPath, "var/temp", new
Artifact(group, artifact, version, format));
+        } else {
+            def pluginsToInstall = command.getInstallList(plugins, consoleReader, null)
+            if (pluginsToInstall) {
+                command.assembleServer(connection.getDeploymentManager(), pluginsToInstall,
'repository', relativeServerPath, consoleReader)
+                connection.getDeploymentManager().archive(relativeServerPath, "var/temp",
new Artifact(group, artifact, version, format));
+            }
         }
         io.out.println("list ended")
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy?rev=615057&r1=615056&r2=615057&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
Thu Jan 24 14:22:29 2008
@@ -20,33 +20,32 @@
 package org.apache.geronimo.commands
 
 import jline.ConsoleReader
-
+import org.apache.geronimo.deployment.cli.CommandListConfigurations
 import org.apache.geronimo.gshell.clp.Argument
 import org.apache.geronimo.gshell.clp.Option
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
-import org.apache.geronimo.gshell.command.CommandSupport
-import org.apache.geronimo.deployment.cli.ServerConnection
-import org.apache.geronimo.cli.deployer.BaseCommandArgs
-import org.apache.geronimo.deployment.cli.CommandListConfigurations
 
 /**
  * install plugins.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:list-plugins', description="Install plugins into
a geronimo server")
+@CommandComponent (id = 'geronimo-commands:list-plugins', description = "Install plugins
into a geronimo server")
 class ListConfigurationsCommand
-    extends ConnectCommand
+extends ConnectCommand
 {
-    @Option(name='-r', aliases=['--repository'], description='refresh repository')
+    @Option (name = '-rr', aliases = ['--refresh-repository'], description = 'refresh repository')
     boolean refreshRepo = false
 
-    @Option(name='-l', aliases=['--list'], description='refresh plugin list')
+    @Option (name = '-rl', aliases = ['--refresh-list'], description = 'refresh plugin list')
     boolean refreshList = false
-    
-    @Argument(metaVar="MAVEN-REPO-URL", description="Repository URL")
+
+    @Option (name = '-r', aliases = ['--respository'], description = "Repository URL")
     String mavenRepoURL
 
+    @Argument (multiValued = true)
+    List<String> pluginArtifacts
+
     protected Object doExecute() throws Exception {
         def connection = variables.get("ServerConnection")
         if (!connection) {
@@ -56,29 +55,33 @@
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
         def repo = null
         def plugins = null
-        
+
         if (mavenRepoURL) {
-        	plugins = command.getPluginCategories(mavenRepoURL, connection.getDeploymentManager(),
consoleReader)
+            plugins = command.getPluginCategories(mavenRepoURL, connection.getDeploymentManager(),
consoleReader)
         } else {
             io.out.println("Listing configurations from Geronimo server")
-            
-        	repo = variables.get("PluginRepository")
-        	if (refreshRepo || !repo) {
-            	repo = command.getRepository(consoleReader, connection.getDeploymentManager())
-            	variables.parent.set("PluginRepository", repo)
-        	}
-              
-       	 	plugins = variables.get("AvailablePlugins")
-        	if (refreshList || !plugins) {
-            	plugins = command.getPluginCategories(repo, connection.getDeploymentManager(),
consoleReader)
-            	variables.parent.set("AvailablePlugins", plugins)
-        	}
+
+            repo = variables.get("PluginRepository")
+            if (refreshRepo || !repo) {
+                repo = command.getRepository(consoleReader, connection.getDeploymentManager())
+                variables.parent.set("PluginRepository", repo)
+            }
+
+            plugins = variables.get("AvailablePlugins")
+            if (refreshList || !plugins) {
+                plugins = command.getPluginCategories(repo, connection.getDeploymentManager(),
consoleReader)
+                variables.parent.set("AvailablePlugins", plugins)
+            }
         }
-        
+
         if (plugins) {
-            def pluginsToInstall = command.getInstallList(plugins, consoleReader, repo)
-            if (pluginsToInstall) {
-                command.installPlugins(connection.getDeploymentManager(), pluginsToInstall,
repo, consoleReader, connection)
+            if (pluginArtifacts) {
+                command.installPlugins(connection.getDeploymentManager(), pluginArtifacts,
plugins, repo, consoleReader, connection)
+            } else {
+                def pluginsToInstall = command.getInstallList(plugins, consoleReader, repo)
+                if (pluginsToInstall) {
+                    command.installPlugins(connection.getDeploymentManager(), pluginsToInstall,
repo, consoleReader, connection)
+                }
             }
         }
         io.out.println("list ended")

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?rev=615057&r1=615056&r2=615057&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
Thu Jan 24 14:22:29 2008
@@ -60,12 +60,12 @@
                 } else {
                     repo = getRepository(consoleReader, mgr);
                 }
-                Map<String, Collection<PluginType>> categories = getPluginCategories(repo,
mgr, consoleReader);
-                if (categories == null) {
+                PluginListType plugins = getPluginCategories(repo, mgr, consoleReader);
+                if (plugins == null) {
                     return;
                 }
 
-                PluginListType list = getInstallList(categories, consoleReader, repo);
+                PluginListType list = getInstallList(plugins, consoleReader, repo);
                 if (list == null) {
                     return;
                 }
@@ -96,7 +96,7 @@
             consoleReader.printNewline();
             return repo;
         }
-        
+
         consoleReader.printNewline();
         consoleReader.printString("Select repository:");
         consoleReader.printNewline();
@@ -119,7 +119,7 @@
         }
     }
 
-    public Map<String, Collection<PluginType>> getPluginCategories(String repo,
GeronimoDeploymentManager mgr, ConsoleReader consoleReader) throws DeploymentException, IOException
{
+    public PluginListType getPluginCategories(String repo, GeronimoDeploymentManager mgr,
ConsoleReader consoleReader) throws DeploymentException, IOException {
         if (repo == null) {
             return null;
         }
@@ -133,17 +133,23 @@
         } catch (FailedLoginException e) {
             throw new DeploymentException("Invalid login for Maven repository '" + repo +
"'", e);
         }
-        return writePluginList(data, consoleReader);
+        if (data == null || data.getPlugin().size() == 0) {
+            return null;
+        }
+        return data;
     }
 
-    public Map<String, Collection<PluginType>> getLocalPluginCategories(GeronimoDeploymentManager
mgr, ConsoleReader consoleReader) throws DeploymentException, IOException {
+    public PluginListType getLocalPluginCategories(GeronimoDeploymentManager mgr, ConsoleReader
consoleReader) throws DeploymentException, IOException {
         PluginListType data;
         try {
             data = mgr.createPluginListForRepositories(null);
         } catch (NoSuchStoreException e) {
             throw new DeploymentException("Unable to list configurations", e);
         }
-        return writePluginList(data, consoleReader);
+        if (data == null || data.getPlugin().size() == 0) {
+            return null;
+        }
+        return data;
     }
 
     private Map<String, Collection<PluginType>> writePluginList(PluginListType
data, ConsoleReader consoleReader) throws IOException {
@@ -176,7 +182,11 @@
         return categories;
     }
 
-    public PluginListType getInstallList(Map<String, Collection<PluginType>>
categories, ConsoleReader consoleReader, String repo) throws IOException {
+    public PluginListType getInstallList(PluginListType plugins, ConsoleReader consoleReader,
String repo) throws IOException {
+        Map<String, Collection<PluginType>> categories = writePluginList(plugins,
consoleReader);
+        if (categories == null) {
+            return null;
+        }
         List<PluginType> available = new ArrayList<PluginType>();
         for (Map.Entry<String, Collection<PluginType>> entry : categories.entrySet())
{
             String category = entry.getKey();
@@ -223,12 +233,42 @@
         int time = (int) (System.currentTimeMillis() - start) / 1000;
         CommandInstallCAR.printResults(consoleReader, results, time);
     }
-    
+
+    public void installPlugins(GeronimoDeploymentManager mgr, List<String> list, PluginListType
all, String defaultRepository, ConsoleReader consoleReader, ServerConnection connection) throws
IOException, DeploymentException {
+        PluginListType selected = getPluginsFromIds(list, all);
+        installPlugins(mgr, selected, defaultRepository, consoleReader, connection);
+    }
+
+    private static PluginListType getPluginsFromIds(List<String> configIds, PluginListType
list) throws IllegalStateException {
+        PluginListType installList = new PluginListType();
+        for (String configId : configIds) {
+            PluginType plugin = null;
+            for (PluginType metadata : list.getPlugin()) {
+                for (PluginArtifactType testInstance : metadata.getPluginArtifact()) {
+                    if (PluginInstallerGBean.toArtifact(testInstance.getModuleId()).toString().equals(configId))
{
+                        plugin = PluginInstallerGBean.copy(metadata, testInstance);
+                        installList.getPlugin().add(plugin);
+                        break;
+                    }
+                }
+            }
+            if (plugin == null) {
+                throw new IllegalStateException("No configuration found for '" + configId
+ "'");
+            }
+        }
+        return installList;
+    }
+
+
     public void assembleServer(GeronimoDeploymentManager mgr, PluginListType list, String
repositoryPath, String relativeServerPath, ConsoleReader consoleReader) throws Exception {
         long start = System.currentTimeMillis();
         DownloadResults results = mgr.installPluginList(repositoryPath, relativeServerPath,
list);
         int time = (int) (System.currentTimeMillis() - start) / 1000;
         CommandInstallCAR.printResults(consoleReader, results, time);
+    }
+    public void assembleServer(GeronimoDeploymentManager mgr, List<String> list, PluginListType
all, String repositoryPath, String relativeServerPath, ConsoleReader consoleReader) throws
Exception {
+        PluginListType selected = getPluginsFromIds(list, all);
+        assembleServer(mgr, selected, repositoryPath, relativeServerPath, consoleReader);
     }
 
 }



Mime
View raw message