geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r595732 [1/2] - in /geronimo/server/trunk: assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/ framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ framework/modules/geronimo-commands/ framework/modules/...
Date Fri, 16 Nov 2007 16:46:17 GMT
Author: djencks
Date: Fri Nov 16 08:46:15 2007
New Revision: 595732

URL: http://svn.apache.org/viewvc?rev=595732&view=rev
Log:
GERONIMO-3605 preliminary work to get deployment gshell commands.  list-plugins works but needs formatting

Added:
    geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java   (with props)
    geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java   (with props)
    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/DisconnectCommand.groovy
    geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy
Modified:
    geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/gsh-classworlds.conf
    geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
    geronimo/server/trunk/framework/modules/geronimo-commands/pom.xml
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java

Modified: geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/gsh-classworlds.conf
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/gsh-classworlds.conf?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/gsh-classworlds.conf (original)
+++ geronimo/server/trunk/assemblies/geronimo-boilerplate-minimal/src/main/underlay/etc/gsh-classworlds.conf Fri Nov 16 08:46:15 2007
@@ -32,3 +32,11 @@
     ##
     load ${gshell.home}/lib/geronimo-kernel-*.jar
     load ${gshell.home}/lib/log4j-*.jar
+    load ${gshell.home}/lib/cglib-nodep-*.jar
+    load ${gshell.home}/repository/org/apache/geronimo/specs/geronimo-javaee-deployment_1.1MR3_spec/1.0/geronimo-javaee-deployment_1.1MR3_spec-1.0.jar
+    load ${gshell.home}/repository/org/apache/geronimo/modules/geronimo-cli/2.1-SNAPSHOT/geronimo-cli-*.jar
+    load ${gshell.home}/repository/org/apache/geronimo/modules/geronimo-deploy-config/2.1-SNAPSHOT/geronimo-deploy-config-*.jar
+    load ${gshell.home}/repository/org/apache/geronimo/modules/geronimo-deploy-jsr88/2.1-SNAPSHOT/geronimo-deploy-jsr88-*.jar
+    load ${gshell.home}/repository/org/apache/geronimo/modules/geronimo-deploy-tool/2.1-SNAPSHOT/geronimo-deploy-tool-*.jar
+    load ${gshell.home}/repository/org/apache/geronimo/modules/geronimo-system/2.1-SNAPSHOT/geronimo-system-*.jar
+    load ${gshell.home}/repository/org/apache/geronimo/modules/geronimo-common/2.1-SNAPSHOT/geronimo-common-*.jar

Added: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java?rev=595732&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java Fri Nov 16 08:46:15 2007
@@ -0,0 +1,42 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.geronimo.cli.deployer;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface ConnectionParams {
+    String getURI();
+
+    String getHost();
+
+    Integer getPort();
+
+    String getDriver();
+
+    String getUser();
+
+    String getPassword();
+
+    boolean isSyserr();
+
+    boolean isVerbose();
+
+    boolean isOffline();
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParams.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java?rev=595732&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java Fri Nov 16 08:46:15 2007
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.cli.deployer;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ConnectionParamsImpl implements ConnectionParams {
+
+    private String uri;
+    private String host;
+    private Integer port;
+    private String driver;
+    private String user;
+    private String password;
+    private boolean syserr;
+    private boolean verbose;
+    private boolean offline;
+
+
+    public ConnectionParamsImpl(String uri, String host, Integer port, String driver, String user, String password, boolean syserr, boolean verbose, boolean offline) {
+        this.uri = uri;
+        this.host = host;
+        this.port = port;
+        this.driver = driver;
+        this.user = user;
+        this.password = password;
+        this.syserr = syserr;
+        this.verbose = verbose;
+        this.offline = offline;
+    }
+
+    public ConnectionParamsImpl() {
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public Integer getPort() {
+        return port;
+    }
+
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    public String getDriver() {
+        return driver;
+    }
+
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public boolean isSyserr() {
+        return syserr;
+    }
+
+    public void setSyserr(boolean syserr) {
+        this.syserr = syserr;
+    }
+
+    public boolean isVerbose() {
+        return verbose;
+    }
+
+    public void setVerbose(boolean verbose) {
+        this.verbose = verbose;
+    }
+
+    public boolean isOffline() {
+        return offline;
+    }
+
+    public void setOffline(boolean offline) {
+        this.offline = offline;
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/ConnectionParamsImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-cli/src/main/java/org/apache/geronimo/cli/deployer/DeployerCLParser.java Fri Nov 16 08:46:15 2007
@@ -36,7 +36,7 @@
 /**
  * @version $Rev: 476049 $ $Date: 2006-11-17 15:35:17 +1100 (Fri, 17 Nov 2006) $
  */
-public class DeployerCLParser extends BaseCLParser {
+public class DeployerCLParser extends BaseCLParser implements ConnectionParams {
     private final static String ARGUMENT_URI_SHORTFORM = "U";
     private final static String ARGUMENT_URI = "uri";
     

Modified: geronimo/server/trunk/framework/modules/geronimo-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-commands/pom.xml?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/pom.xml Fri Nov 16 08:46:15 2007
@@ -65,6 +65,28 @@
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-cli</artifactId>
+            <version>${version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-deploy-tool</artifactId>
+            <version>${version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
     </dependencies>
 
     <build>

Added: 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=595732&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy (added)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ConnectCommand.groovy Fri Nov 16 08:46:15 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.commands
+
+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.deployment.plugin.factories.DeploymentFactoryWithKernel
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager
+import org.apache.geronimo.cli.deployer.ConnectionParamsImpl
+import org.apache.geronimo.kernel.basic.BasicKernel
+import java.util.Collections
+
+/**
+ * Stops a running Geronimo server instance.
+ *
+ * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
+ */
+@CommandComponent(id='connect')
+class ConnectCommand
+    extends CommandSupport
+{
+    //
+    // TODO: Expose as options, maybe expose a single URI-ish thingy?
+    //
+
+    String hostname = 'localhost'
+
+    int port = 1099
+
+    String username = 'system'
+
+    String password = 'manager'
+
+    protected Object doExecute() throws Exception {
+        io.out.println("Connecting to Geronimo server: ${hostname}:${port}")
+
+        def kernel = new BasicKernel("gshell deployer")
+        def deploymentManager = new RemoteDeploymentManager(Collections.emptySet());
+        def deploymentFactory = new DeploymentFactoryWithKernel(kernel, deploymentManager)
+        def uri = null//"service:jmx:rmi://" + hostname + "/jndi/rmi://" + hostname + ":" + port + "/JMXConnector"
+        def connectionParams = new ConnectionParamsImpl(uri: uri, user: username, password: password, offline: false)
+        def connection = new ServerConnection(connectionParams, io.out, io.inputStream, kernel, deploymentFactory)
+
+        variables.parent.set("ServerConnection", connection)
+
+        io.out.println("connection established")
+        return connection
+    }
+}
\ No newline at end of file

Added: 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=595732&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy (added)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/DisconnectCommand.groovy Fri Nov 16 08:46:15 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.commands
+
+import org.apache.geronimo.gshell.command.annotation.CommandComponent
+import org.apache.geronimo.gshell.command.CommandSupport
+import org.apache.geronimo.deployment.cli.ServerConnection
+
+/**
+ * Stops a running Geronimo server instance.
+ *
+ * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
+ */
+@CommandComponent(id='disconnect')
+class DisconnectCommand
+    extends CommandSupport
+{
+
+    protected Object doExecute() throws Exception {
+        io.out.println("Disconnecting from Geronimo server")
+
+        def connection = variables.get("ServerConnection")
+        if (connection) connection.close
+        variables.parent.unset("ServerConnection")
+        
+        io.out.println("connection ended")
+    }
+}
\ No newline at end of file

Added: 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=595732&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy (added)
+++ geronimo/server/trunk/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/ListConfigurationsCommand.groovy Fri Nov 16 08:46:15 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.commands
+
+
+import jline.ConsoleReader
+
+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
+
+/**
+ * Stops a running Geronimo server instance.
+ *
+ * @version $Rev: 580864 $ $Date: 2007-09-30 23:47:39 -0700 (Sun, 30 Sep 2007) $
+ */
+@CommandComponent(id='list-plugins')
+class ListConfigurationsCommand
+    extends CommandSupport
+{
+
+    protected Object doExecute() throws Exception {
+        io.out.println("Listing configurations from Geronimo server")
+
+        def connection = variables.get("ServerConnection")
+        if (!connection) {
+            def connectCommand = new ConnectCommand()
+            connectCommand.init(context)
+            connection = connectCommand.doExecute()
+        }
+        def command = new CommandListConfigurations()
+        def consoleReader = new ConsoleReader(io.inputStream, io.out)
+        def repo = variables.get("PluginRepository")
+        if (!repo) {
+            repo = command.getRepository(consoleReader, connection.getDeploymentManager())
+            variables.parent.set("PluginRepository", repo)
+        }
+        def plugins = variables.get("AvailablePlugins")
+        if (!plugins) {
+            plugins = command.getPluginCategories(repo, connection.getDeploymentManager(), consoleReader)
+            variables.parent.set("AvailablePlugins", plugins)
+        }
+        def pluginsToInstall = command.getInstallList(plugins, consoleReader, repo)
+        command.installPlugins(connection.getDeploymentManager(), pluginsToInstall, consoleReader, connection)
+        io.out.println("list ended")
+    }
+}
\ No newline at end of file

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java Fri Nov 16 08:46:15 2007
@@ -40,12 +40,18 @@
  */
 public class DeploymentFactoryWithKernel extends BaseDeploymentFactory {
     private final Kernel kernel;
+    private final RemoteDeploymentManager remoteDeploymentManager;
     
     public DeploymentFactoryWithKernel(Kernel kernel) {
+        this(kernel, null);
+    }
+
+    public DeploymentFactoryWithKernel(Kernel kernel, RemoteDeploymentManager remoteDeploymentManager) {
         if (null == kernel) {
             throw new IllegalArgumentException("kernel is required");
         }
         this.kernel = kernel;
+        this.remoteDeploymentManager = remoteDeploymentManager;
         DeploymentFactoryManager.getInstance().registerDeploymentFactory(this);
     }
     
@@ -64,6 +70,9 @@
     }
     
     protected RemoteDeploymentManager getRemoteDeploymentManager() throws DeploymentManagerCreationException {
+        if (remoteDeploymentManager != null) {
+            return remoteDeploymentManager;
+        }
         try {
             return (RemoteDeploymentManager) kernel.getGBean(RemoteDeploymentManager.class);
         } catch (Exception e) {

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java Fri Nov 16 08:46:15 2007
@@ -17,8 +17,8 @@
 
 package org.apache.geronimo.deployment.cli;
 
+import java.io.IOException;
 import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -30,6 +30,7 @@
 import javax.enterprise.deploy.spi.status.ProgressListener;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
+import jline.ConsoleReader;
 import org.apache.geronimo.common.DeploymentException;
 
 /**
@@ -39,22 +40,27 @@
  * @version $Rev$ $Date$
  */
 public abstract class AbstractCommand implements DeployCommand {
-    private PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
+    private ConsoleReader out;
 
     public AbstractCommand() {
+        try {
+            out = new ConsoleReader(System.in, new OutputStreamWriter(System.out));
+        } catch (IOException e) {
+            throw new RuntimeException("could not set up console", e);
+        }
     }
 
     public boolean isLocalOnly() {
         return false;
     }
 
-    public void setOut(PrintWriter out) {
+    public void setConsole(ConsoleReader out) {
         this.out = out;
     }
 
-    protected void emit(String message) {
-        out.print(DeployUtils.reformat(message,4,72));
-        out.flush();
+    protected void emit(String message) throws IOException {
+        out.printString(DeployUtils.reformat(message, 4, 72));
+        out.flushConsole();
     }
 
     /**
@@ -62,26 +68,36 @@
      * indicates that it's no longer running.
      *
      * @param out a <code>PrintWriter</code> value, only used in case
-     * of an <code>InterruptedException</code> to output the stack
-     * trace.
-     * @param po a <code>ProgressObject</code> value
+     *            of an <code>InterruptedException</code> to output the stack
+     *            trace.
+     * @param po  a <code>ProgressObject</code> value
      */
-    protected void waitForProgress(PrintWriter out, ProgressObject po) {
+    protected void waitForProgress(ConsoleReader out, ProgressObject po) {
         po.addProgressListener(new ProgressListener() {
             String last = null;
+
             public void handleProgressEvent(ProgressEvent event) {
                 String msg = event.getDeploymentStatus().getMessage();
-                if(last != null && !last.equals(msg)) {
-                    emit(last);
+                if (last != null && !last.equals(msg)) {
+                    try {
+                        emit(last);
+                    } catch (IOException e1) {
+                        //ignore
+                    }
                 }
                 last = msg;
             }
         });
-        while(po.getDeploymentStatus().isRunning()) {
+        while (po.getDeploymentStatus().isRunning()) {
             try {
                 Thread.sleep(100);
             } catch (InterruptedException e) {
-                e.printStackTrace(out);
+                try {
+                    out.printString(e.getMessage());
+                    out.printNewline();
+                } catch (IOException e1) {
+                    //ignore
+                }
             }
         }
         return;
@@ -89,7 +105,7 @@
 
     protected static boolean isMultipleTargets(TargetModuleID[] ids) {
         Set set = new HashSet();
-        for(int i = 0; i < ids.length; i++) {
+        for (int i = 0; i < ids.length; i++) {
             TargetModuleID id = ids[i];
             set.add(id.getTarget().getName());
         }
@@ -105,21 +121,21 @@
             for (int j = 0; j < all.length; j++) {
                 Target server = all[j];
                 // check for exact target name match
-                if(server.getName().equals(targetNames.get(i))
-                   // check for "target-nickname" match (they match if
-                   // the full target name contains the user-provided
-                   // nickname)
-                   || server.getName().indexOf(targetNames.get(i).toString()) > -1) {
+                if (server.getName().equals(targetNames.get(i))
+                        // check for "target-nickname" match (they match if
+                        // the full target name contains the user-provided
+                        // nickname)
+                        || server.getName().indexOf(targetNames.get(i).toString()) > -1) {
                     tlist[i] = server;
-                    if(found.contains(server.getName())) {
-                        throw new DeploymentException("Target list should not contain duplicates or nicknames that match duplicates ("+targetNames.get(i)+")");
+                    if (found.contains(server.getName())) {
+                        throw new DeploymentException("Target list should not contain duplicates or nicknames that match duplicates (" + targetNames.get(i) + ")");
                     }
                     found.add(server.getName());
                     break;
                 }
             }
-            if(tlist[i] == null) {
-                throw new DeploymentException("No target named or matching '"+targetNames.get(i)+"' was found");
+            if (tlist[i] == null) {
+                throw new DeploymentException("No target named or matching '" + targetNames.get(i) + "' was found");
             }
         }
         return tlist;

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDeploy.java Fri Nov 16 08:46:15 2007
@@ -25,6 +25,7 @@
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
 import org.apache.geronimo.common.DeploymentException;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to deploy (distribute plus start).
@@ -37,7 +38,7 @@
         return "Deployed";
     }
 
-    protected ProgressObject runCommand(DeploymentManager mgr, PrintWriter out, boolean inPlace, Target[] tlist, File module, File plan) throws DeploymentException {
+    protected ProgressObject runCommand(DeploymentManager mgr, ConsoleReader out, boolean inPlace, Target[] tlist, File module, File plan) throws DeploymentException {
         ProgressObject po = super.runCommand(mgr, out, inPlace, tlist, module, plan);
         waitForProgress(out, po);
         if(po.getDeploymentStatus().isFailed()) {

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java Fri Nov 16 08:46:15 2007
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.PrintWriter;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -32,6 +33,7 @@
 import org.apache.geronimo.cli.deployer.DistributeCommandArgs;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to distribute.
@@ -40,7 +42,7 @@
  */
 public class CommandDistribute extends AbstractCommand {
 
-    protected ProgressObject runCommand(DeploymentManager mgr, PrintWriter out, boolean inPlace, Target[] tlist, File module, File plan) throws DeploymentException {
+    protected ProgressObject runCommand(DeploymentManager mgr, ConsoleReader out, boolean inPlace, Target[] tlist, File module, File plan) throws DeploymentException {
         if (inPlace) {
             if (!(mgr instanceof JMXDeploymentManager)) {
                 throw new DeploymentSyntaxException(
@@ -63,7 +65,7 @@
         return "Distributed";
     }
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         if (!(commandArgs instanceof DistributeCommandArgs)) {
             throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + DistributeCommandArgs.class + "]");
         }
@@ -111,10 +113,14 @@
         if(plan != null) {
             plan = plan.getAbsoluteFile();
         }
-        executeOnline(connection, inPlaceHolder.inPlace, targets, out, module, plan);
+        try {
+            executeOnline(connection, inPlaceHolder.inPlace, targets, consoleReader, module, plan);
+        } catch (IOException e) {
+            throw new DeploymentException("Could not write to output", e);
+        }
     }
 
-    private void executeOnline(ServerConnection connection, boolean inPlace, List targets, PrintWriter out, File module, File plan) throws DeploymentException {
+    private void executeOnline(ServerConnection connection, boolean inPlace, List targets, ConsoleReader out, File module, File plan) throws DeploymentException, IOException {
         final DeploymentManager mgr = connection.getDeploymentManager();
         TargetModuleID[] results;
         boolean multipleTargets;
@@ -135,11 +141,11 @@
         results = po.getResultTargetModuleIDs();
         for (int i = 0; i < results.length; i++) {
             TargetModuleID result = results[i];
-            out.print(DeployUtils.reformat(getAction()+" "+result.getModuleID()+(multipleTargets ? " to "+result.getTarget().getName() : "")+(result.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "+result.getWebURL()), 4, 72));
+            out.printString(DeployUtils.reformat(getAction()+" "+result.getModuleID()+(multipleTargets ? " to "+result.getTarget().getName() : "")+(result.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "+result.getWebURL()), 4, 72));
             if(result.getChildTargetModuleID() != null) {
                 for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                     TargetModuleID child = result.getChildTargetModuleID()[j];
-                    out.print(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "+child.getWebURL()),4, 72));
+                    out.printString(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "+child.getWebURL()),4, 72));
                 }
             }
         }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java Fri Nov 16 08:46:15 2007
@@ -17,7 +17,7 @@
 package org.apache.geronimo.deployment.cli;
 
 import java.io.File;
-import java.io.PrintWriter;
+import java.io.IOException;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
 
@@ -27,6 +27,7 @@
 import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.system.plugin.DownloadResults;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to start.
@@ -37,40 +38,44 @@
 
     //todo: provide a way to handle a username and password for the remote repo?
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         DeploymentManager dmgr = connection.getDeploymentManager();
         if(dmgr instanceof GeronimoDeploymentManager) {
-            GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
-            File carFile = new File(commandArgs.getArgs()[0]);
-            carFile = carFile.getAbsoluteFile();
-            if(!carFile.exists() || !carFile.canRead()) {
-                throw new DeploymentException("CAR file cannot be read: "+carFile.getAbsolutePath());
-            }
-            Object key = mgr.startInstall(carFile, null, null);
-            long start = System.currentTimeMillis();
-            DownloadResults results = showProgress(mgr, key);
-            int time = (int)(System.currentTimeMillis() - start) / 1000;
-            System.out.println();
-            if(!results.isFailed()) {
-                System.out.print(DeployUtils.reformat("**** Installation Complete!", 4, 72));
-                for (int i = 0; i < results.getDependenciesPresent().length; i++) {
-                    Artifact uri = results.getDependenciesPresent()[i];
-                    System.out.print(DeployUtils.reformat("Used existing: "+uri, 4, 72));
+            try {
+                GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
+                File carFile = new File(commandArgs.getArgs()[0]);
+                carFile = carFile.getAbsoluteFile();
+                if(!carFile.exists() || !carFile.canRead()) {
+                    throw new DeploymentException("CAR file cannot be read: "+carFile.getAbsolutePath());
                 }
-                for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
-                    Artifact uri = results.getDependenciesInstalled()[i];
-                    System.out.print(DeployUtils.reformat("Installed new: "+uri, 4, 72));
+                Object key = mgr.startInstall(carFile, null, null);
+                long start = System.currentTimeMillis();
+                DownloadResults results = showProgress(mgr, key);
+                int time = (int)(System.currentTimeMillis() - start) / 1000;
+                consoleReader.printNewline();
+                if(!results.isFailed()) {
+                    consoleReader.printString(DeployUtils.reformat("**** Installation Complete!", 4, 72));
+                    for (int i = 0; i < results.getDependenciesPresent().length; i++) {
+                        Artifact uri = results.getDependenciesPresent()[i];
+                        consoleReader.printString(DeployUtils.reformat("Used existing: "+uri, 4, 72));
+                    }
+                    for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
+                        Artifact uri = results.getDependenciesInstalled()[i];
+                        consoleReader.printString(DeployUtils.reformat("Installed new: "+uri, 4, 72));
+                    }
+                    if(results.getTotalDownloadBytes() > 0 && time > 0) {
+                        System.out.println();
+                        consoleReader.printString(DeployUtils.reformat("Downloaded "+(results.getTotalDownloadBytes()/1024)+" kB in "+time+"s ("+results.getTotalDownloadBytes()/(1024*time)+" kB/s)", 4, 72));
+                    }
                 }
-                if(results.getTotalDownloadBytes() > 0 && time > 0) {
-                    System.out.println();
-                    System.out.print(DeployUtils.reformat("Downloaded "+(results.getTotalDownloadBytes()/1024)+" kB in "+time+"s ("+results.getTotalDownloadBytes()/(1024*time)+" kB/s)", 4, 72));
+                if(results.isFinished() && !results.isFailed() && results.getInstalledConfigIDs().length == 1) {
+                    Artifact target = results.getInstalledConfigIDs()[0];
+                    consoleReader.printString(DeployUtils.reformat("Now starting "+target+"...", 4, 72));
+                    consoleReader.flushConsole();
+                    new CommandStart().execute(consoleReader, connection, new BaseCommandArgs(new String[]{target.toString()}));
                 }
-            }
-            if(results.isFinished() && !results.isFailed() && results.getInstalledConfigIDs().length == 1) {
-                Artifact target = results.getInstalledConfigIDs()[0];
-                System.out.print(DeployUtils.reformat("Now starting "+target+"...", 4, 72));
-                System.out.flush();
-                new CommandStart().execute(out, connection, new BaseCommandArgs(new String[]{target.toString()}));
+            } catch (IOException e) {
+                throw new DeploymentException("Cannot install plugin", e);
             }
         } else {
             throw new DeploymentException("Cannot install plugins when connected to "+connection.getServerURI());

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=595732&r1=595731&r2=595732&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 Fri Nov 16 08:46:15 2007
@@ -16,10 +16,7 @@
  */
 package org.apache.geronimo.deployment.cli;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -29,6 +26,7 @@
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.security.auth.login.FailedLoginException;
 
+import jline.ConsoleReader;
 import org.apache.geronimo.cli.deployer.BaseCommandArgs;
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
@@ -49,7 +47,7 @@
 
     //todo: provide a way to handle a username and password for the remote repo?
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         DeploymentManager dmgr = connection.getDeploymentManager();
         if (dmgr instanceof GeronimoDeploymentManager) {
             GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
@@ -58,105 +56,19 @@
                 if (commandArgs.getArgs().length == 1) {
                     repo = commandArgs.getArgs()[0];
                 } else {
-                    repo = getRepository(out, new BufferedReader(new InputStreamReader(System.in)), mgr);
+                    repo = getRepository(consoleReader, mgr);
                 }
-                PluginListType data;
-                URL repository;
-                try {
-                    repository = new URL(repo);
-                    data = mgr.listPlugins(repository, null, null);
-                } catch (IOException e) {
-                    throw new DeploymentException("Unable to list configurations", e);
-                } catch (FailedLoginException e) {
-                    throw new DeploymentException("Invalid login for Maven repository '" + repo + "'", e);
-                }
-                if (data == null) {
-                    out.println();
-                    out.println("No plugins were returned from this site.");
-                    return;
-                }
-                Map<String, List<PluginType>> categories = new HashMap<String, List<PluginType>>();
-                for (PluginType metadata : data.getPlugin()) {
-                    List<PluginType> list = categories.get(metadata.getCategory());
-                    if (list == null) {
-                        list = new ArrayList<PluginType>();
-                        categories.put(metadata.getCategory(), list);
-                    }
-                    list.add(metadata);
-                }
-                List<PluginType> available = new ArrayList<PluginType>();
-                for (Map.Entry<String, List<PluginType>> entry : categories.entrySet()) {
-                    String category = entry.getKey();
-                    if (category == null) {
-                        category = "<no category>";
-                    }
-                    List<PluginType> items = entry.getValue();
-                    out.println();
-                    out.print(DeployUtils.reformat(category, 4, 72));
-                    for (PluginType metadata : items) {
-                        out.println("  " + metadata.getName());
-                        for (PluginArtifactType instance : metadata.getPluginArtifact()) {
-                            String prefix;
-//                            if (!instance.isInstalled() && instance.isEligible()) {
-                            PluginType copy = PluginInstallerGBean.copy(metadata, instance);
-                                available.add(copy);
-                                prefix = Integer.toString(available.size());
-                                if (available.size() < 10) {
-                                    prefix += " ";
-                                }
-                                prefix += ": ";
-//                            }
-                            out.print(DeployUtils.reformat(
-                                    prefix + " (" + instance.getModuleId().getVersion() + ")", 8, 72));
-                            out.flush();
-                        }
-                    }
-                }
-                if (available.size() == 0) {
-                    out.println();
-                    out.println("No plugins from this site are eligible for installation.");
+                Map<String, List<PluginType>> categories = getPluginCategories(repo, mgr, consoleReader);
+                if (categories == null) {
                     return;
                 }
-                out.println();
-                out.print("Install Service [enter number or 'q' to quit]: ");
-                out.flush();
-                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-                String answer = in.readLine();
-                if (answer.equalsIgnoreCase("q")) {
+
+                PluginListType list = getInstallList(categories, consoleReader, repo);
+                if (list == null) {
                     return;
                 }
-                int selection = Integer.parseInt(answer);
-                PluginType target = available.get(selection - 1);
-                PluginArtifactType targetInstance = target.getPluginArtifact().get(0);
-                PluginListType list = new PluginListType();
-                list.getPlugin().add(target);
-                list.getDefaultRepository().add(repo);
-                long start = System.currentTimeMillis();
-                Object key = mgr.startInstall(list, null, null);
-                DownloadResults results = CommandInstallCAR.showProgress(mgr, key);
-                int time = (int) (System.currentTimeMillis() - start) / 1000;
-                out.println();
-                if (!results.isFailed()) {
-                    out.print(DeployUtils.reformat("**** Installation Complete!", 4, 72));
-                    for (int i = 0; i < results.getDependenciesPresent().length; i++) {
-                        Artifact uri = results.getDependenciesPresent()[i];
-                        out.print(DeployUtils.reformat("Used existing: " + uri, 4, 72));
-                    }
-                    for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
-                        Artifact uri = results.getDependenciesInstalled()[i];
-                        out.print(DeployUtils.reformat("Installed new: " + uri, 4, 72));
-                    }
-                    out.println();
-                    out.print(DeployUtils.reformat(
-                            "Downloaded " + (results.getTotalDownloadBytes() / 1024) + " kB in " + time + "s (" + results.getTotalDownloadBytes() / (1024 * time) + " kB/s)",
-                            4, 72));
-                }
-                if (results.isFinished() && !results.isFailed()) {
-                    out.print(DeployUtils.reformat("Now starting " + PluginInstallerGBean.toArtifact(targetInstance.getModuleId()) + "...", 4, 72));
-                    out.flush();
-                    new CommandStart().execute(out, connection,
-                            new BaseCommandArgs(new String[]{PluginInstallerGBean.toArtifact(targetInstance.getModuleId()).toString()}));
-                }
+
+                installPlugins(mgr, list, consoleReader, connection);
             } catch (IOException e) {
                 throw new DeploymentException("Unable to install configuration", e);
             } catch (NumberFormatException e) {
@@ -167,23 +79,148 @@
         }
     }
 
-    private String getRepository(PrintWriter out, BufferedReader in, GeronimoDeploymentManager mgr) throws IOException, DeploymentException {
+    public void installPlugins(GeronimoDeploymentManager mgr, PluginListType list, ConsoleReader consoleReader, ServerConnection connection) throws IOException, DeploymentException {
+        long start = System.currentTimeMillis();
+        Object key = mgr.startInstall(list, null, null);
+        DownloadResults results = CommandInstallCAR.showProgress(mgr, key);
+        int time = (int) (System.currentTimeMillis() - start) / 1000;
+        consoleReader.printNewline();
+        if (!results.isFailed()) {
+            consoleReader.printString(DeployUtils.reformat("**** Installation Complete!", 4, 72));
+            consoleReader.printNewline();
+
+            for (int i = 0; i < results.getDependenciesPresent().length; i++) {
+                Artifact uri = results.getDependenciesPresent()[i];
+                consoleReader.printString(DeployUtils.reformat("Used existing: " + uri, 4, 72));
+                consoleReader.printNewline();
+
+            }
+            for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
+                Artifact uri = results.getDependenciesInstalled()[i];
+                consoleReader.printString(DeployUtils.reformat("Installed new: " + uri, 4, 72));
+                consoleReader.printNewline();
+
+            }
+            consoleReader.printNewline();
+            consoleReader.printString(DeployUtils.reformat(
+                    "Downloaded " + (results.getTotalDownloadBytes() / 1024) + " kB in " + time + "s (" + results.getTotalDownloadBytes() / (1024 * time) + " kB/s)",
+                    4, 72));
+            consoleReader.printNewline();
+
+        }
+        if (results.isFinished() && !results.isFailed()) {
+            for (PluginType plugin : list.getPlugin()) {
+                for (PluginArtifactType targetInstance : plugin.getPluginArtifact()) {
+                    consoleReader.printString(DeployUtils.reformat("Now starting " + PluginInstallerGBean.toArtifact(targetInstance.getModuleId()) + "...", 4, 72));
+                    consoleReader.flushConsole();
+                    new CommandStart().execute(consoleReader, connection,
+                            new BaseCommandArgs(new String[]{PluginInstallerGBean.toArtifact(targetInstance.getModuleId()).toString()}));
+                }
+            }
+        }
+    }
+
+    public PluginListType getInstallList(Map<String, List<PluginType>> categories, ConsoleReader consoleReader, String repo) throws IOException {
+        List<PluginType> available = new ArrayList<PluginType>();
+        for (Map.Entry<String, List<PluginType>> entry : categories.entrySet()) {
+            String category = entry.getKey();
+            if (category == null) {
+                category = "<no category>";
+            }
+            List<PluginType> items = entry.getValue();
+            consoleReader.printNewline();
+            consoleReader.printString(DeployUtils.reformat(category, 4, 72));
+            for (PluginType metadata : items) {
+                consoleReader.printString("  " + metadata.getName());
+                for (PluginArtifactType instance : metadata.getPluginArtifact()) {
+                    String prefix;
+//                            if (!instance.isInstalled() && instance.isEligible()) {
+                    PluginType copy = PluginInstallerGBean.copy(metadata, instance);
+                    available.add(copy);
+                    prefix = Integer.toString(available.size());
+                    if (available.size() < 10) {
+                        prefix += " ";
+                    }
+                    prefix += ": ";
+//                            }
+                    consoleReader.printString(DeployUtils.reformat(
+                            prefix + " (" + instance.getModuleId().getVersion() + ")", 8, 72));
+                    consoleReader.printNewline();
+                }
+            }
+        }
+        if (available.size() == 0) {
+            consoleReader.printNewline();
+            consoleReader.printString("No plugins from this site are eligible for installation.");
+            consoleReader.printNewline();
+            return null;
+        }
+        consoleReader.printNewline();
+//                consoleReader.print("Install Service [enter number or 'q' to quit]: ");
+        consoleReader.flushConsole();
+        String answer = consoleReader.readLine("Install Services [enter a comma separated list of numbers or 'q' to quit]: ").trim();
+        if (answer.equalsIgnoreCase("q")) {
+            return null;
+        }
+        PluginListType list = new PluginListType();
+        for (String instance : answer.split(",")) {
+            int selection = Integer.parseInt(instance.trim());
+            PluginType target = available.get(selection - 1);
+            list.getPlugin().add(target);
+        }
+        list.getDefaultRepository().add(repo);
+        return list;
+    }
+
+    public Map<String, List<PluginType>> getPluginCategories(String repo, GeronimoDeploymentManager mgr, ConsoleReader consoleReader) throws DeploymentException, IOException {
+        PluginListType data;
+        URL repository;
+        try {
+            repository = new URL(repo);
+            data = mgr.listPlugins(repository, null, null);
+        } catch (IOException e) {
+            throw new DeploymentException("Unable to list configurations", e);
+        } catch (FailedLoginException e) {
+            throw new DeploymentException("Invalid login for Maven repository '" + repo + "'", e);
+        }
+        if (data == null) {
+            consoleReader.printNewline();
+            consoleReader.printString("No plugins were returned from this site.");
+            consoleReader.printNewline();
+            consoleReader.flushConsole();
+            return null;
+        }
+        Map<String, List<PluginType>> categories = new HashMap<String, List<PluginType>>();
+        for (PluginType metadata : data.getPlugin()) {
+            List<PluginType> list = categories.get(metadata.getCategory());
+            if (list == null) {
+                list = new ArrayList<PluginType>();
+                categories.put(metadata.getCategory(), list);
+            }
+            list.add(metadata);
+        }
+        return categories;
+    }
+
+    public String getRepository(ConsoleReader consoleReader, GeronimoDeploymentManager mgr) throws IOException, DeploymentException {
         URL[] all = mgr.getRepositories();
         if (all.length == 0) {
             throw new DeploymentException("No default repositories available.  Please either specify the repository " +
                     "URL on the command line, or go into the console Plugin page and update the list of available " +
                     "repositories.");
         }
-        out.println();
-        out.println("Select repository:");
+        consoleReader.printNewline();
+        consoleReader.printString("Select repository:");
+        consoleReader.printNewline();
         for (int i = 0; i < all.length; i++) {
             URL url = all[i];
-            out.println("  " + (i + 1) + ". " + url);
+            consoleReader.printString("  " + (i + 1) + ". " + url);
+            consoleReader.printNewline();
         }
-        out.println();
-        out.print("Enter Repository Number: ");
-        out.flush();
-        String entry = in.readLine().trim();
+        consoleReader.printNewline();
+//        consoleReader.print("Enter Repository Number: ");
+        consoleReader.flushConsole();
+        String entry = consoleReader.readLine("Enter Repository Number: ").trim();
         int index = Integer.parseInt(entry);
         return all[index - 1].toString();
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java Fri Nov 16 08:46:15 2007
@@ -18,6 +18,7 @@
 package org.apache.geronimo.deployment.cli;
 
 import java.io.PrintWriter;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 
@@ -29,6 +30,7 @@
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.cli.deployer.ListModulesCommandArgs;
 import org.apache.geronimo.common.DeploymentException;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to list modules.
@@ -37,7 +39,7 @@
  */
 public class CommandListModules extends AbstractCommand {
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         if (!(commandArgs instanceof ListModulesCommandArgs)) {
             throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + ListModulesCommandArgs.class + "]");
         }
@@ -80,20 +82,26 @@
         // print the module count, and if there are more than one
         // targets print that count, too
         int total = running.length+notrunning.length;
-        out.print("Found "+total+" module"+(total != 1 ? "s" : ""));
-        if ((tlist != null) && (tlist.length > 1)) {
-            out.println(" deployed to " + tlist.length + " target" + (tlist.length != 1 ? "s" : ""));
-        } else {
-            out.println("");
-        }
+        try {
+            consoleReader.printString("Found "+total+" module"+(total != 1 ? "s" : ""));
+            consoleReader.printNewline();
+            if ((tlist != null) && (tlist.length > 1)) {
+                consoleReader.printString(" deployed to " + tlist.length + " target" + (tlist.length != 1 ? "s" : ""));
+            }
+            consoleReader.printNewline();
 
-        // for each target, print the modules that were deployed to it
-        for (int i = 0; (tlist != null) && (i < tlist.length); i++) {
-            Target target = tlist[i];
-            if (tlist.length > 1)
-                out.println("\n Target " + target);
-            printTargetModules(out, target, running, "  + ");
-            printTargetModules(out, target, notrunning, "    ");
+            // for each target, print the modules that were deployed to it
+            for (int i = 0; (tlist != null) && (i < tlist.length); i++) {
+                Target target = tlist[i];
+                if (tlist.length > 1) {
+                    consoleReader.printNewline();
+                    consoleReader.printString(" Target " + target);
+                }
+                printTargetModules(consoleReader, target, running, "  + ");
+                printTargetModules(consoleReader, target, notrunning, "    ");
+            }
+        } catch (IOException e) {
+            throw new DeploymentException("Could not print to console", e);
         }
     }
 
@@ -110,15 +118,17 @@
      * @param prefix a <code>String</code> value that will be
      * prepended to each module
      */
-    void printTargetModules(PrintWriter out, Target target, TargetModuleID[] modules, String prefix) {
+    void printTargetModules(ConsoleReader out, Target target, TargetModuleID[] modules, String prefix) throws IOException {
         for (int i = 0; i < modules.length; i++) {
             TargetModuleID result = modules[i];
             if (result.getTarget().equals(target)) {
-                out.println(prefix+result.getModuleID());
+                out.printString(prefix+result.getModuleID());
+                out.printNewline();
                 if(result.getChildTargetModuleID() != null) {
                     for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                         TargetModuleID child = result.getChildTargetModuleID()[j];
-                        out.println("      `-> "+child.getModuleID());
+                        out.printString("      `-> "+child.getModuleID());
+                        out.printNewline();
                     }
                 }
             }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListTargets.java Fri Nov 16 08:46:15 2007
@@ -17,12 +17,13 @@
 
 package org.apache.geronimo.deployment.cli;
 
-import java.io.PrintWriter;
+import java.io.IOException;
 
 import javax.enterprise.deploy.spi.Target;
 
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to list targets.
@@ -31,16 +32,23 @@
  */
 public class CommandListTargets extends AbstractCommand {
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
-        Target[] list = connection.getDeploymentManager().getTargets();
-        if ((list == null) || (list.length == 0)) {
-            out.println("No available targets.");
-        } else {
-            out.println("Available Targets:");
-            for (int i = 0; i < list.length; i++) {
-                Target target = list[i];
-                out.println("  "+target.getName());
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+        try {
+            Target[] list = connection.getDeploymentManager().getTargets();
+            if ((list == null) || (list.length == 0)) {
+                consoleReader.printString("No available targets.");
+                consoleReader.printNewline();
+            } else {
+                consoleReader.printString("Available Targets:");
+                consoleReader.printNewline();
+                for (int i = 0; i < list.length; i++) {
+                    Target target = list[i];
+                    consoleReader.printString("  "+target.getName());
+                    consoleReader.printNewline();
+                }
             }
+        } catch (IOException e) {
+            throw new DeploymentException("Could not write to console", e);
         }
     }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandLogin.java Fri Nov 16 08:46:15 2007
@@ -25,13 +25,12 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.PrintWriter;
 import java.util.Properties;
 
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.util.SimpleEncryption;
 import org.apache.geronimo.util.EncryptionManager;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to start.
@@ -40,7 +39,7 @@
  */
 public class CommandLogin extends AbstractCommand {
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
         try {
             File authFile = new File(System.getProperty("user.home"), ".geronimo-deployer");
             if(!authFile.exists()) {
@@ -52,15 +51,16 @@
                 throw new DeploymentException("Saved login file "+authFile.getAbsolutePath()+" is not readable or not writable");
             }
             Properties props = new Properties();
-            InputStream in = new BufferedInputStream(new FileInputStream(authFile));
-            props.load(in);
-            in.close();
+            InputStream authIn = new BufferedInputStream(new FileInputStream(authFile));
+            props.load(authIn);
+            authIn.close();
             props.setProperty("login."+connection.getServerURI(), EncryptionManager.encrypt(connection.getAuthentication()));
             OutputStream save = new BufferedOutputStream(new FileOutputStream(authFile));
             props.store(save, "Saved authentication information to connect to Geronimo servers");
             save.flush();
             save.close();
-            System.out.print(DeployUtils.reformat("Saved login for: "+connection.getServerURI(), 4, 72));
+            consoleReader.printString(DeployUtils.reformat("Saved login for: "+connection.getServerURI(), 4, 72));
+            consoleReader.printNewline();
         } catch (IOException e) {
             throw new DeploymentException("Unable to save authentication to login file", e);
         }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java Fri Nov 16 08:46:15 2007
@@ -19,7 +19,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,6 +31,7 @@
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to redeploy.
@@ -40,112 +40,117 @@
  */
 public class CommandRedeploy extends AbstractCommand {
 
-    public void execute(PrintWriter out, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
-        String[] args = commandArgs.getArgs();
-        setOut(out);
-
-        DeploymentManager mgr = connection.getDeploymentManager();
-        Target[] allTargets = mgr.getTargets();
-        TargetModuleID[] allModules;
+    public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs commandArgs) throws DeploymentException {
+        ProgressObject po = null;
         try {
-            allModules = mgr.getAvailableModules(null, allTargets);
-        } catch(TargetException e) {
-            throw new DeploymentException("Unable to load modules from server", e);
-        }
-        
-        List modules = new ArrayList();
-        File module = null;
-        File plan = null;
-        File test = new File(args[0]); // Guess whether the first argument is a module or a plan
-        if(!test.exists()) {
-            throw new DeploymentSyntaxException("Must specify a module or plan (or both) and optionally module IDs to replace");
-        }
-        if(!test.canRead()) {
-            throw new DeploymentException("Cannot read file "+test.getAbsolutePath());
-        }
-        if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-            module = test;
-        } else {
-            plan = test;
-        }
-        if(args.length > 1) { // Guess whether the second argument is a module, plan, ModuleID, or TargetModuleID
-            test = new File(args[1]);
-            if(test.exists() && test.canRead() && !args[1].equals(args[0])) {
-                if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-                    if(module != null) {
-                        throw new DeploymentSyntaxException("Module and plan cannot both be JAR files or directories!");
+            String[] args = commandArgs.getArgs();
+            setConsole(consoleReader);
+
+            DeploymentManager mgr = connection.getDeploymentManager();
+            Target[] allTargets = mgr.getTargets();
+            TargetModuleID[] allModules;
+            try {
+                allModules = mgr.getAvailableModules(null, allTargets);
+            } catch(TargetException e) {
+                throw new DeploymentException("Unable to load modules from server", e);
+            }
+
+            List modules = new ArrayList();
+            File module = null;
+            File plan = null;
+            File test = new File(args[0]); // Guess whether the first argument is a module or a plan
+            if(!test.exists()) {
+                throw new DeploymentSyntaxException("Must specify a module or plan (or both) and optionally module IDs to replace");
+            }
+            if(!test.canRead()) {
+                throw new DeploymentException("Cannot read file "+test.getAbsolutePath());
+            }
+            if(DeployUtils.isJarFile(test) || test.isDirectory()) {
+                module = test;
+            } else {
+                plan = test;
+            }
+            if(args.length > 1) { // Guess whether the second argument is a module, plan, ModuleID, or TargetModuleID
+                test = new File(args[1]);
+                if(test.exists() && test.canRead() && !args[1].equals(args[0])) {
+                    if(DeployUtils.isJarFile(test) || test.isDirectory()) {
+                        if(module != null) {
+                            throw new DeploymentSyntaxException("Module and plan cannot both be JAR files or directories!");
+                        }
+                        module = test;
+                    } else {
+                        if(plan != null) {
+                            throw new DeploymentSyntaxException("Module or plan must be a JAR file or directory!");
+                        }
+                        plan = test;
                     }
-                    module = test;
                 } else {
-                    if(plan != null) {
-                        throw new DeploymentSyntaxException("Module or plan must be a JAR file or directory!");
-                    }
-                    plan = test;
+                    modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[1], false));
                 }
-            } else {
-                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(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
-        }
-        // If we don't have any moduleIDs, try to guess one.
-        if(modules.size() == 0 && connection.isGeronimo()) {
-            emit("No ModuleID or TargetModuleID provided.  Attempting to guess based on the content of the "+(plan == null ? "archive" : "plan")+".");
-            String moduleId = null;
-            try {
-                if(plan != null) {
-                    moduleId = DeployUtils.extractModuleIdFromPlan(plan);
-                    if(moduleId == null) { // plan just doesn't have a config ID
-                        String fileName = module == null ? plan.getName() : module.getName();
-                        int pos = fileName.lastIndexOf('.');
-                        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.");
-                    }
-                } else if(module != null) {
-                    moduleId = DeployUtils.extractModuleIdFromArchive(module);
-                    if(moduleId == null) {
-                        int pos = module.getName().lastIndexOf('.');
-                        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.");
+            for(int i=2; i<args.length; i++) { // Any arguments beyond 2 must be a ModuleID or TargetModuleID
+                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()) {
+                emit("No ModuleID or TargetModuleID provided.  Attempting to guess based on the content of the "+(plan == null ? "archive" : "plan")+".");
+                String moduleId = null;
+                try {
+                    if(plan != null) {
+                        moduleId = DeployUtils.extractModuleIdFromPlan(plan);
+                        if(moduleId == null) { // plan just doesn't have a config ID
+                            String fileName = module == null ? plan.getName() : module.getName();
+                            int pos = fileName.lastIndexOf('.');
+                            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.");
+                        }
+                    } else if(module != null) {
+                        moduleId = DeployUtils.extractModuleIdFromArchive(module);
+                        if(moduleId == null) {
+                            int pos = module.getName().lastIndexOf('.');
+                            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.");
+                        }
                     }
+                } catch (IOException e) {
+                    throw new DeploymentException("Unable to read input files: "+e.getMessage(), e);
+                }
+                if(moduleId != null) {
+                    emit("Attempting to use ModuleID '"+moduleId+"'");
+                    modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId, true));
+                } else {
+                    emit("Unable to calculate a ModuleID from supplied module and/or plan.");
                 }
-            } catch (IOException e) {
-                throw new DeploymentException("Unable to read input files: "+e.getMessage(), e);
             }
-            if(moduleId != null) {
-                emit("Attempting to use ModuleID '"+moduleId+"'");
-                modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId, true));
-            } else {
-                emit("Unable to calculate a ModuleID from supplied module and/or plan.");
+            if(modules.size() == 0) { // Either not deploying to Geronimo or unable to identify modules
+                throw new DeploymentSyntaxException("No ModuleID or TargetModuleID available.  Nothing to do.  Maybe you should add a ModuleID or TargetModuleID to the command line?");
+            }
+            if(module != null) {
+                module = module.getAbsoluteFile();
             }
-        }
-        if(modules.size() == 0) { // Either not deploying to Geronimo or unable to identify modules
-            throw new DeploymentSyntaxException("No ModuleID or TargetModuleID available.  Nothing to do.  Maybe you should add a ModuleID or TargetModuleID to the command line?");
-        }
-        if(module != null) {
-            module = module.getAbsoluteFile();
-        }
-        if(plan != null) {
-            plan = plan.getAbsoluteFile();
-        }
-        // Now that we've sorted out all the arguments, do the work
-        TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
-        boolean multiple = isMultipleTargets(ids);
-        ProgressObject po = mgr.redeploy(ids, module, plan);
-        waitForProgress(out, po);
-        TargetModuleID[] done = po.getResultTargetModuleIDs();
-        for(int i = 0; i < done.length; i++) {
-            TargetModuleID id = done[i];
-            emit("Redeployed "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName() : "")+(id.getWebURL() == null ? "" : " @ "+id.getWebURL()));
-            if(id.getChildTargetModuleID() != null) {
-                for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
-                    TargetModuleID child = id.getChildTargetModuleID()[j];
-                    emit("  `-> "+child.getModuleID()+(child.getWebURL() == null ? "" : " @ "+child.getWebURL()));
+            if(plan != null) {
+                plan = plan.getAbsoluteFile();
+            }
+            // Now that we've sorted out all the arguments, do the work
+            TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
+            boolean multiple = isMultipleTargets(ids);
+            po = mgr.redeploy(ids, module, plan);
+            waitForProgress(consoleReader, po);
+            TargetModuleID[] done = po.getResultTargetModuleIDs();
+            for(int i = 0; i < done.length; i++) {
+                TargetModuleID id = done[i];
+                emit("Redeployed "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName() : "")+(id.getWebURL() == null ? "" : " @ "+id.getWebURL()));
+                if(id.getChildTargetModuleID() != null) {
+                    for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
+                        TargetModuleID child = id.getChildTargetModuleID()[j];
+                        emit("  `-> "+child.getModuleID()+(child.getWebURL() == null ? "" : " @ "+child.getWebURL()));
+                    }
                 }
             }
+        } catch (IOException e) {
+            throw new DeploymentException("Could not write to console", e);
         }
         if(po.getDeploymentStatus().isFailed()) {
             throw new DeploymentException("Operation failed: "+po.getDeploymentStatus().getMessage());

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java?rev=595732&r1=595731&r2=595732&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java Fri Nov 16 08:46:15 2007
@@ -22,12 +22,14 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
+import jline.ConsoleReader;
+
 /**
  * The CLI deployer logic to restart.
  */
 public class CommandRestart extends CommandStart {
 
-    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[] ids) {
+    protected ProgressObject runCommand(ConsoleReader out, DeploymentManager mgr, TargetModuleID[] ids) {
         ProgressObject po = mgr.stop(ids);
         waitForProgress(out, po);
         if(po.getDeploymentStatus().isCompleted()) {



Mime
View raw message