geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r650911 - /geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/
Date Wed, 23 Apr 2008 15:37:49 GMT
Author: jdillon
Date: Wed Apr 23 08:37:46 2008
New Revision: 650911

URL: http://svn.apache.org/viewvc?rev=650911&view=rev
Log:
Slight refactoring of ConnectCommand, introducing openConnection() and connect(), sub-class
use connect() to get a ServerConnection
Some other updates to make this code Groovier

Removed:
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeCommandArgsImpl.java
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommandArgsImpl.java
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommandArgsImpl.java
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/ConnectCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartClientCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy

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=650911&r1=650910&r2=650911&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
Wed Apr 23 08:37:46 2008
@@ -33,9 +33,8 @@
  */
 @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')
     boolean refreshList = false
 
@@ -58,38 +57,39 @@
     List<String> pluginArtifacts
 
     protected Object doExecute() throws Exception {
-        io.out.println("Listing configurations from Geronimo server")
+        io.out.println('Listing configurations from Geronimo server')
 
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
               
         if (!artifact) {
-            artifact = prompter.readLine("Server artifact name: ")
+            artifact = prompter.readLine('Server artifact name: ')
             if (!artifact) {
-                throw new IllegalArgumentException("Server artifact name is required")
+                throw new IllegalArgumentException('Server artifact name is required')
             }
         }
         
         def command = new CommandListConfigurations()
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def plugins = variables.get("LocalPlugins")
+        def plugins = variables.get('LocalPlugins')
+        
         if (refreshList || !plugins) {
             plugins = command.getLocalPluginCategories(connection.getDeploymentManager(),
consoleReader)
-            variables.parent.set("LocalPlugins", plugins)
+            variables.parent.set('LocalPlugins', plugins)
         }
 
         if (pluginArtifacts) {
             command.assembleServer(connection.getDeploymentManager(), pluginArtifacts, plugins,
'repository', relativeServerPath, consoleReader)
-            connection.getDeploymentManager().archive(relativeServerPath, "var/temp", new
Artifact(group, artifact, (String)version, format));
-        } else {
+            connection.getDeploymentManager().archive(relativeServerPath, 'var/temp', new
Artifact(group, artifact, (String)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, (String)version, format));
+                connection.getDeploymentManager().archive(relativeServerPath, 'var/temp',
new Artifact(group, artifact, (String)version, format));
             }
         }
-        io.out.println("list ended")
+        
+        io.out.println('list ended')
     }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -32,13 +32,16 @@
 import java.util.Collections
 
 /**
- * Stops a running Geronimo server instance.
+ * Connect the current shell to a running Geronimo server instance.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
 @CommandComponent(id='geronimo-commands:connect', description="Connect to a Geronimo server")
-class ConnectCommand extends CommandSupport {
-
+class ConnectCommand
+    extends CommandSupport
+{
+    public static final String SERVER_CONNECTION = 'geronimo.ServerConnection'
+    
     @Option(name='-s', aliases=['--hostname', '--server'], description='Hostname, default
localhost')
     String hostname = 'localhost'
 
@@ -55,16 +58,20 @@
     PromptReader prompter
 
     protected Object doExecute() throws Exception {               
+        return openConnection()
+    }
+    
+    private ServerConnection openConnection() throws Exception {
         io.out.println("Connecting to Geronimo server: ${hostname}:${port}")
         
         // If the username/password was not configured via cli, then prompt the user for
the values
         if (username == null || password == null) {
             if (username == null) {
-                username = prompter.readLine("Username: ");
+                username = prompter.readLine('Username: ')
             }
 
             if (password == null) {
-                password = prompter.readPassword("Password: ");
+                password = prompter.readPassword('Password: ')
             }
 
             //
@@ -72,28 +79,48 @@
             //
         }
         
-        def kernel = new BasicKernel("gshell deployer")
-        def deploymentManager = new RemoteDeploymentManager(Collections.emptySet());
+        def kernel = new BasicKernel('gshell deployer')
+        def deploymentManager = new RemoteDeploymentManager(Collections.emptySet())
         def deploymentFactory = new DeploymentFactoryWithKernel(kernel, deploymentManager)
         def connectionParams = new ConnectionParamsImpl(host: hostname, port: port, user:
username, password: password, offline: false)
         def connection = new ServerConnection(connectionParams, io.out, io.inputStream, kernel,
deploymentFactory)
 
-        disconnect();
+        // Disconnect previous connection if any
+        disconnect()
         
-        variables.parent.set("ServerConnection", connection)
+        variables.parent.set(SERVER_CONNECTION, connection)
 
-        io.out.println("Connection established")
+        io.out.println('Connection established')
+        
+        return connection
+    }
+    
+    protected ServerConnection connect() {
+        def connection = variables.get(SERVER_CONNECTION)
+        
+        if (!connection) {
+            connection = openConnection()
+        }
+        
         return connection
     }
     
-    private void disconnect() {
-        def connection = variables.get("ServerConnection")
+    protected boolean isConnected() {
+        return variables.contains(SERVER_CONNECTION)
+    }
+    
+    protected void disconnect() {
+        def connection = variables.get(SERVER_CONNECTION)
+        
         if (connection) {
             try {
             	connection.close()
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 // ignore
             }
         }
+        
+        variables.parent.unset(SERVER_CONNECTION)
     }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DeployModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,39 +31,40 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:deploy-module', description="Deploy a module")
-class DeployModuleCommand extends ConnectCommand {
-     
-    @Option(name='-i', aliases=['--inPlace'], description='In-place deployment')   
+@CommandComponent(id='geronimo-commands:deploy-module', description='Deploy a module')
+class DeployModuleCommand
+    extends ConnectCommand
+{
+    @Option(name='-i', aliases=['--inPlace'], description='In-place deployment')
     boolean inPlace
     
-    @Option(name='-t', aliases=['--targets'], metaVar="TARGET;TARGET;...", description='Targets')
  
+    @Option(name='-t', aliases=['--targets'], metaVar='TARGET;TARGET;...', description='Targets')
     String targets
          
-    @Argument(metaVar="MODULE-FILE", required=true, index=0, description="Module file")
+    @Argument(metaVar='MODULE-FILE', required=true, index=0, description='Module file')
     String module
     
-    @Argument(metaVar="MODULE-PLAN", index=1, description="Module plan")
+    @Argument(metaVar='MODULE-PLAN', index=1, description='Module plan')
     String modulePlan
     
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandDeploy()
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
         
         def commandArgs = []
-                commandArgs.add(module)        
+        commandArgs << module
+        
         if (modulePlan) {
-            commandArgs.add(modulePlan)
+            commandArgs << modulePlan
         }
         
-        def args = new DistributeCommandArgsImpl((String[])commandArgs, targets, inPlace)
+        def args = new DistributeCommandArgsImpl(
+            args: (String[])commandArgs,
+            targets: (targets == null ? [] : targets.split(';')),
+            inPlace: inPlace)
         
         command.execute(consoleReader, connection, args)
     }
-           
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -24,28 +24,33 @@
 import org.apache.geronimo.deployment.cli.ServerConnection
 
 /**
- * Stops a running Geronimo server instance.
+ * Disconnect the current shell from a Geronimo instance.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:disconnect', description="Disconnect from a Geronimo
server")
+@CommandComponent(id='geronimo-commands:disconnect', description='Disconnect from a Geronimo
server')
 class DisconnectCommand
     extends CommandSupport
 {
-
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
+        def connection = variables.get(ConnectCommand.SERVER_CONNECTION)
+        
         if (connection) {
-            io.out.println("Disconnecting from Geronimo server")
+            io.out.println('Disconnecting from Geronimo server')
+            
             try {
             	connection.close()
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 // ignore
-            }           
-            variables.parent.unset("ServerConnection")            
-            io.out.println("Connection ended")
-        } else {
-            io.out.println("Not connected")
+            }
+            
+            variables.parent.unset(ConnectCommand.SERVER_CONNECTION)
+            
+            io.out.println('Connection ended')
+        }
+        else {
+            io.out.println('Not connected')
         }
     }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DistributeModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -25,45 +25,57 @@
 import org.apache.geronimo.gshell.clp.Option
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
 import org.apache.geronimo.deployment.cli.CommandDistribute
+import org.apache.geronimo.cli.deployer.DistributeCommandArgs
 
 /**
  * Distribute module.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:distribute-module', description="Distribute a module")
-class DistributeModuleCommand extends ConnectCommand {
-     
-    @Option(name='-i', aliases=['--inPlace'], description='In-place deployment')   
+@CommandComponent(id='geronimo-commands:distribute-module', description='Distribute a module')
+class DistributeModuleCommand
+    extends ConnectCommand
+{
+    @Option(name='-i', aliases=['--inPlace'], description='In-place deployment')
     boolean inPlace
     
-    @Option(name='-t', aliases=['--targets'], metaVar="TARGET;TARGET;...", description='Targets')
  
+    @Option(name='-t', aliases=['--targets'], metaVar='TARGET;TARGET;...', description='Targets')
     String targets
          
-    @Argument(metaVar="MODULE-FILE", required=true, index=0, description="Module file")
+    @Argument(metaVar='MODULE-FILE', required=true, index=0, description='Module file')
     String module
     
-    @Argument(metaVar="MODULE-PLAN", index=1, description="Module plan")
+    @Argument(metaVar='MODULE-PLAN', index=1, description='Module plan')
     String modulePlan
     
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandDistribute()
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
         
         def commandArgs = []
-        commandArgs.add(module)        
+        commandArgs << module
+        
         if (modulePlan) {
-            commandArgs.add(modulePlan)
+            commandArgs << modulePlan
         }
         
-        def args = new DistributeCommandArgsImpl((String[])commandArgs, targets, inPlace)
+        def args = new DistributeCommandArgsImpl(
+            args: (String[])commandArgs,
+            targets: (targets == null ? [] : targets.split(';')),
+            inPlace: inPlace)
         
         command.execute(consoleReader, connection, args)
     }
-           
+}
+
+class DistributeCommandArgsImpl
+    implements DistributeCommandArgs
+{
+    String[] args
+    
+    String[] targets
+    
+    boolean inPlace
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallLibraryCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -25,32 +25,40 @@
 import org.apache.geronimo.gshell.clp.Option
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
 import org.apache.geronimo.deployment.cli.CommandInstallLibrary
+import org.apache.geronimo.cli.deployer.InstallLibraryCommandArgs
 
 /**
  * Installs a library file into repository.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:install-library', description="Install library")
-class InstallLibraryCommand extends ConnectCommand {
-     
-    @Option(name='-g', aliases=['--groupId'], description='Group id')   
+@CommandComponent(id='geronimo-commands:install-library', description='Install library')
+class InstallLibraryCommand
+    extends ConnectCommand
+{
+    @Option(name='-g', aliases=['--groupId'], description='Group id')
     String groupId
-         
-    @Argument(metaVar="LIBRARY-FILE", required=true, description="Library file")
+
+    @Argument(metaVar='LIBRARY-FILE', required=true, description='Library file')
     String libraryFile
     
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandInstallLibrary()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new InstallLibraryCommandArgsImpl(libraryFile, groupId)
+        
+        def args = new InstallLibraryCommandArgsImpl(args: [ libraryFile], groupId: groupId)
         
         command.execute(consoleReader, connection, args)
     }
-           
+}
+
+class InstallLibraryCommandArgsImpl
+    implements InstallLibraryCommandArgs
+{
+    String[] args
+    
+    String groupId
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/InstallPluginCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,21 +31,21 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:install-plugin', description="Install a plugin")
-class InstallPluginCommand extends ConnectCommand {
-     
-    @Argument(metaVar="PLUGIN_FILE", required=true, description="Plugin file")
+@CommandComponent(id='geronimo-commands:install-plugin', description='Install a plugin')
+class InstallPluginCommand
+    extends ConnectCommand
+{
+    @Argument(metaVar='PLUGIN_FILE', required=true, description='Plugin file')
     String pluginFile
     
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandInstallCAR()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new BaseCommandArgs( (String[]) [ pluginFile ] )
+        
+        def args = new BaseCommandArgs((String[]) [ pluginFile ])
         
         command.execute(consoleReader, connection, args)
     }

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=650911&r1=650910&r2=650911&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
Wed Apr 23 08:37:46 2008
@@ -26,13 +26,13 @@
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
 
 /**
- * install plugins.
+ * List 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 = 'List plugins installed
on a server')
 class ListConfigurationsCommand
-extends ConnectCommand
+    extends ConnectCommand
 {
     @Option (name = '-rr', aliases = ['--refresh-repository'], description = 'refresh repository')
     boolean refreshRepo = false
@@ -40,17 +40,15 @@
     @Option (name = '-rl', aliases = ['--refresh-list'], description = 'refresh plugin list')
     boolean refreshList = false
 
-    @Option (name = '-r', aliases = ['--respository'], 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) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
+        
         def command = new CommandListConfigurations()
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
         def repo = null
@@ -59,32 +57,36 @@
         if (mavenRepoURL) {
             plugins = command.getPluginCategories(mavenRepoURL, connection.getDeploymentManager(),
consoleReader)
             repo = mavenRepoURL
-        } else {
-            io.out.println("Listing configurations from Geronimo server")
+        }
+        else {
+            io.out.println('Listing configurations from Geronimo server')
 
-            repo = variables.get("PluginRepository")
+            repo = variables.get('PluginRepository')
             if (refreshRepo || !repo) {
                 repo = command.getRepository(consoleReader, connection.getDeploymentManager())
-                variables.parent.set("PluginRepository", repo)
+                variables.parent.set('PluginRepository', repo)
             }
 
-            plugins = variables.get("AvailablePlugins")
+            plugins = variables.get('AvailablePlugins')
             if (refreshList || !plugins) {
                 plugins = command.getPluginCategories(repo, connection.getDeploymentManager(),
consoleReader)
-                variables.parent.set("AvailablePlugins", plugins)
+                variables.parent.set('AvailablePlugins', plugins)
             }
         }
 
         if (plugins) {
             if (pluginArtifacts) {
                 command.installPlugins(connection.getDeploymentManager(), pluginArtifacts,
plugins, repo, consoleReader, connection)
-            } else {
+            }
+            else {
                 def pluginsToInstall = command.getInstallList(plugins, consoleReader, repo)
+                
                 if (pluginsToInstall) {
                     command.installPlugins(connection.getDeploymentManager(), pluginsToInstall,
repo, consoleReader, connection)
                 }
             }
         }
-        io.out.println("list ended")
+        
+        io.out.println('list ended')
     }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListModulesCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -25,16 +25,18 @@
 import org.apache.geronimo.gshell.clp.Option
 import org.apache.geronimo.gshell.command.annotation.CommandComponent
 import org.apache.geronimo.deployment.cli.CommandListModules
+import org.apache.geronimo.cli.deployer.ListModulesCommandArgs
 
 /**
  * List modules.
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:list-modules', description="List modules")
-class ListModulesCommand extends ConnectCommand {
-     
-    @Option(name='-a', aliases=['--all'], description='Show started or stopped modules')
  
+@CommandComponent(id='geronimo-commands:list-modules', description='List modules')
+class ListModulesCommand
+    extends ConnectCommand
+{
+    @Option(name='-a', aliases=['--all'], description='Show started or stopped modules')
     boolean all = true
     
     @Option(name='-t', aliases=['--stopped'], description='Show stopped modules only')
@@ -43,20 +45,34 @@
     @Option(name='-r', aliases=['--started'], description='Show started modules only')
     boolean started = false
      
-    @Argument(metaVar="TARGET", description="Target name")
+    @Argument(metaVar='TARGET', description='Target name')
     List<String> targets = []
     
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandListModules()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new ListModulesCommandArgsImpl((String[])targets, all, started, stopped)
+        
+        def args = new ListModulesCommandArgsImpl(
+            args: (String[])targets,
+            all: all,
+            started: started,
+            stopped: stopped)
         
         command.execute(consoleReader, connection, args)
     }
-           
+}
+
+class ListModulesCommandArgsImpl
+    implements ListModulesCommandArgs
+{
+    String[] args
+    
+    boolean all
+    
+    boolean started
+    
+    boolean stopped
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListTargetsCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,18 +31,18 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:list-targets', description="List targets")
-class ListTargetsCommand extends ConnectCommand {
-     
+@CommandComponent(id='geronimo-commands:list-targets', description='List targets')
+class ListTargetsCommand
+    extends ConnectCommand
+{
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandListTargets()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new BaseCommandArgs( (String[])[] )
+        
+        def args = new BaseCommandArgs((String[])[])
         
         command.execute(consoleReader, connection, args)
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RedeployModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,39 +31,41 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:redeploy-module', description="Redeploy a module")
-class RedeployModuleCommand extends ConnectCommand {
-     
-    @Argument(metaVar="MODULE", index=0, description="Module file")
+@CommandComponent(id='geronimo-commands:redeploy-module', description='Redeploy a module')
+class RedeployModuleCommand
+    extends ConnectCommand
+{     
+    @Argument(metaVar='MODULE', index=0, description='Module file')
     String moduleName
     
-    @Argument(metaVar="PLAN", index=1, description="Module plan")
+    @Argument(metaVar='PLAN', index=1, description='Module plan')
     String modulePlan
     
-    @Argument(metaVar="MODULE_ID", index=2, description="Module id")
+    @Argument(metaVar='MODULE_ID', index=2, description='Module id')
     List<String> moduleIds
 
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandRedeploy()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
         
         def commandArgs = []
+        
         if (moduleName) {
-            commandArgs.add(moduleName)
+            commandArgs << moduleName
         }
+        
         if (modulePlan) {
-            commandArgs.add(modulePlan)
+            commandArgs << modulePlan
         }
+        
         if (moduleIds) {
             commandArgs.addAll(moduleIds)
         }
                 
-        def args = new BaseCommandArgs( (String[])commandArgs )
+        def args = new BaseCommandArgs((String[])commandArgs)
         
         command.execute(consoleReader, connection, args)
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/RestartModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,21 +31,21 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:restart-module', description="Restart a module")
-class RestartModuleCommand extends ConnectCommand {
-     
-    @Argument(metaVar="MODULE_ID", required=true, description="Module name")
+@CommandComponent(id='geronimo-commands:restart-module', description='Restart a module')
+class RestartModuleCommand
+    extends ConnectCommand
+{
+    @Argument(metaVar='MODULE_ID', required=true, description='Module name')
     List<String> moduleNames = []
 
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandRestart()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new BaseCommandArgs( (String[])moduleNames )
+        
+        def args = new BaseCommandArgs((String[])moduleNames)
         
         command.execute(consoleReader, connection, args)
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartClientCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartClientCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartClientCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartClientCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -38,8 +38,9 @@
  * @version $Rev: 601585 $ $Date: 2007-12-05 19:14:26 -0500 (Wed, 05 Dec 2007) $
  */
 @CommandComponent(id='geronimo-commands:start-client', description="Start a Geronimo application
client")
-class StartClientCommand extends BaseJavaCommand {
-           
+class StartClientCommand
+    extends BaseJavaCommand
+{
     int verbose = 0
     
     @Option(name='-v', aliases=['--verbose'], description='Enable verbose output; specify
multipule times to increase verbosity')

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,21 +31,21 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:start-module', description="Start a module")
-class StartModuleCommand extends ConnectCommand {
-     
-    @Argument(metaVar="MODULE_ID", required=true, description="Module name")
+@CommandComponent(id='geronimo-commands:start-module', description='Start a module')
+class StartModuleCommand
+    extends ConnectCommand
+{
+    @Argument(metaVar='MODULE_ID', required=true, description='Module name')
     List<String> moduleNames = []
 
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandStart()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new BaseCommandArgs( (String[])moduleNames )
+        
+        def args = new BaseCommandArgs((String[])moduleNames)
         
         command.execute(consoleReader, connection, args)
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StartServerCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -38,8 +38,9 @@
  * @version $Rev$ $Date$
  */
 @CommandComponent(id='geronimo-commands:start-server', description="Start a Geronimo server")
-class StartServerCommand extends BaseJavaCommand {
-        
+class StartServerCommand
+    extends BaseJavaCommand
+{
     @Option(name='-q', aliases=['--quiet'], description='Suppress informative and warning
messages')
     boolean quiet = false
     

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,21 +31,21 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:stop-module', description="Stop a module")
-class StopModuleCommand extends ConnectCommand {
-     
-    @Argument(metaVar="MODULE_ID", required=true, description="Module name")
+@CommandComponent(id='geronimo-commands:stop-module', description='Stop a module')
+class StopModuleCommand
+    extends ConnectCommand
+{
+    @Argument(metaVar='MODULE_ID', required=true, description='Module name')
     List<String> moduleNames = []
 
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandStop()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new BaseCommandArgs( (String[])moduleNames )
+        
+        def args = new BaseCommandArgs((String[])moduleNames)
         
         command.execute(consoleReader, connection, args)
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/StopServerCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,26 +31,26 @@
  *
  * @version $Rev$ $Date$
  */
-@CommandComponent(id='geronimo-commands:stop-server', description="Stop a Geronimo server")
-class StopServerCommand extends ConnectCommand {
-    
+@CommandComponent(id='geronimo-commands:stop-server', description='Stop a Geronimo server')
+class StopServerCommand
+    extends ConnectCommand
+{
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
-                                 
-        RemoteDeploymentManager deploymentManager = 
-            (RemoteDeploymentManager)connection.getDeploymentManager();
+        def connection = connect()
         
-        def server = new ServerProxy(deploymentManager.getJMXConnector())
+        def server = new ServerProxy(connection.deploymentManager.getJMXConnector())
 
-        io.out.println("Stopping Geronimo server...");  
+        io.out.println('Stopping Geronimo server...')
+        
         try {
-                server.shutdown();
-                io.out.println("Shutdown request has been issued");
-        } catch (Exception e) {
-                io.out.println("Unable to shutdown the server: " + e.getMessage());
-        }                
+            server.shutdown()
+            
+            io.out.println('Shutdown request has been issued')
+        }
+        catch (Exception e) {
+            log.debug("Failed to request shutdown: $e", e)
+            
+            io.err.println("Unable to shutdown the server: ${e.message}")
+        }
     }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy?rev=650911&r1=650910&r2=650911&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/UndeployModuleCommand.groovy
Wed Apr 23 08:37:46 2008
@@ -31,21 +31,21 @@
  *
  * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
  */
-@CommandComponent(id='geronimo-commands:undeploy-module', description="Undeploy a module")
-class UndeployModuleCommand extends ConnectCommand {
-     
-    @Argument(metaVar="MODULE_ID", required=true, description="Module name")
+@CommandComponent(id='geronimo-commands:undeploy-module', description='Undeploy a module')
+class UndeployModuleCommand
+    extends ConnectCommand
+{
+    @Argument(metaVar='MODULE_ID', required=true, description='Module name')
     List<String> moduleNames = []
 
     protected Object doExecute() throws Exception {
-        def connection = variables.get("ServerConnection")
-        if (!connection) {
-            connection = super.doExecute()
-        }
+        def connection = connect()
         
         def command = new CommandUndeploy()
+        
         def consoleReader = new ConsoleReader(io.inputStream, io.out)
-        def args = new BaseCommandArgs( (String[])moduleNames )
+        
+        def args = new BaseCommandArgs((String[])moduleNames)
         
         command.execute(consoleReader, connection, args)
     }



Mime
View raw message