Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 4292 invoked from network); 29 Dec 2009 07:54:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Dec 2009 07:54:33 -0000 Received: (qmail 3202 invoked by uid 500); 29 Dec 2009 07:54:32 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 3127 invoked by uid 500); 29 Dec 2009 07:54:32 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 3118 invoked by uid 99); 29 Dec 2009 07:54:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Dec 2009 07:54:32 +0000 X-ASF-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,FB_GET_MEDS X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Dec 2009 07:54:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A42EE2388996; Tue, 29 Dec 2009 07:54:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r894321 [1/2] - in /geronimo/server/trunk/framework/modules/geronimo-shell-base: ./ src/main/java/org/apache/geronimo/shell/ src/main/java/org/apache/geronimo/shell/cluster/ src/main/java/org/apache/geronimo/shell/completers/ src/main/java/... Date: Tue, 29 Dec 2009 07:54:01 -0000 To: scm@geronimo.apache.org From: genspring@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091229075405.A42EE2388996@eris.apache.org> Author: genspring Date: Tue Dec 29 07:53:50 2009 New Revision: 894321 URL: http://svn.apache.org/viewvc?rev=894321&view=rev Log: GERONIMO-4948 To migrate existing geronimo gshell commands to karaf based shell. --- committing migrated commands into shell-base. Thanks Vanessa for her help. Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/cluster/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/cluster/ClusterCommand.java - copied, changed from r894297, geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ClusterCommand.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/GeronimoCompleter.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/AssembleServerCommand.java - copied, changed from r894297, geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/AssembleServerCommand.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ConnectCommand.java - copied, changed from r894297, geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConnectCommand.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DeployModuleCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DisconnectCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DistributeCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallLibraryCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallPluginCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListModulesCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListPluginsCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListTargetsCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/LoginCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/NewInstanceCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RedeployModuleCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RestartModuleCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StartModuleCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StopModuleCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UndeployModuleCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/AntBuilder.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/BaseJavaCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/ProcessLauncher.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/ServerProxy.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/StartClientCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/StartServerCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/StartServerstrapper.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/StopServerCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/WaitForServerCommand.java (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-deploy.xml (with props) geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/resources/OSGI-INF/blueprint/shell-geronimo.xml (with props) Removed: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/AssembleServerCommand.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ClusterCommand.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConnectCommand.java Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/pom.xml geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConfigurationManagerCommandSupport.java geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/KernelCommandSupport.java Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/pom.xml?rev=894321&r1=894320&r2=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/pom.xml (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/pom.xml Tue Dec 29 07:53:50 2009 @@ -10,8 +10,9 @@ org.apache.geronimo.framework geronimo-shell-base + bundle 3.0-SNAPSHOT - geronimo-shell-base + Apache Geronimo :: Shell org.apache.geronimo.framework @@ -36,5 +37,16 @@ org.apache.felix.karaf.shell.console 1.1.0-SNAPSHOT + + org.apache.felix + org.osgi.core + provided + + + org.apache.felix + org.osgi.compendium + provided + + Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java?rev=894321&r1=894320&r2=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/BaseCommandSupport.java Tue Dec 29 07:53:50 2009 @@ -32,6 +32,7 @@ /** * @version $Rev$ $Date$ */ + public abstract class BaseCommandSupport extends OsgiCommandSupport implements ConsoleReader { Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConfigurationManagerCommandSupport.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConfigurationManagerCommandSupport.java?rev=894321&r1=894320&r2=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConfigurationManagerCommandSupport.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConfigurationManagerCommandSupport.java Tue Dec 29 07:53:50 2009 @@ -27,6 +27,7 @@ /** * @version $Rev$ $Date$ */ + public abstract class ConfigurationManagerCommandSupport extends KernelCommandSupport { protected void doExecute(Kernel kernel) throws Exception { ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); Modified: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/KernelCommandSupport.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/KernelCommandSupport.java?rev=894321&r1=894320&r2=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/KernelCommandSupport.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/KernelCommandSupport.java Tue Dec 29 07:53:50 2009 @@ -26,18 +26,19 @@ /** * @version $Rev$ $Date$ */ + public abstract class KernelCommandSupport extends BaseCommandSupport { protected Object doExecute() throws Exception { ServiceReference ref = getBundleContext().getServiceReference(Kernel.class.getName()); if (ref == null) { - System.out.println("FeaturesService service is unavailable."); + println("FeaturesService service is unavailable."); return null; } try { Kernel kernel = (Kernel) getBundleContext().getService(ref); if (kernel == null) { - System.out.println("FeaturesService service is unavailable."); + println("FeaturesService service is unavailable."); return null; } Copied: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/cluster/ClusterCommand.java (from r894297, geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ClusterCommand.java) URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/cluster/ClusterCommand.java?p2=geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/cluster/ClusterCommand.java&p1=geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ClusterCommand.java&r1=894297&r2=894321&rev=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ClusterCommand.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/cluster/ClusterCommand.java Tue Dec 29 07:53:50 2009 @@ -18,7 +18,7 @@ */ -package org.apache.geronimo.shell; +package org.apache.geronimo.shell.cluster; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -36,6 +36,7 @@ import org.apache.geronimo.deployment.cli.ServerConnection; import org.apache.geronimo.deployment.cli.CommandListConfigurations; import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager; +import org.apache.geronimo.shell.deploy.ConnectCommand; import org.apache.geronimo.system.plugin.Farm; import org.apache.geronimo.system.plugin.DownloadResults; @@ -44,6 +45,7 @@ /** * @version $Rev$ $Date$ */ + @Command(scope = "geronimo", name = "cluster", description = "administer cluster") public class ClusterCommand extends ConnectCommand { @Option(name="-c", aliases={"--cluster"}, description="Cluster to perform action on") Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/GeronimoCompleter.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/GeronimoCompleter.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/GeronimoCompleter.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/GeronimoCompleter.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,84 @@ +/* + * 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.shell.completers; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.felix.karaf.shell.console.Completer; +import org.apache.felix.karaf.shell.console.completer.StringsCompleter; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.cm.ConfigurationEvent; + +/** + * @version $Rev$ $Date$ + */ + +public class GeronimoCompleter implements Completer { + + private final StringsCompleter delegate = new StringsCompleter(); + + private ConfigurationAdmin admin; + + public void setAdmin(ConfigurationAdmin admin) { + this.admin = admin; + } + + public void init() { + Configuration[] configs; + try { + configs = admin.listConfigurations(null); + if (configs == null) { + return; + } + } catch (Exception e) { + return; + } + + Collection pids = new ArrayList(); + + for (Configuration config : configs) { + if (config.getFactoryPid() != null) { + pids.add(config.getFactoryPid()); + } else { + pids.add(config.getPid()); + } + } + + delegate.getStrings().addAll(pids); + + } + + public int complete(final String buffer, final int cursor, final List candidates) { + return delegate.complete(buffer, cursor, candidates); + } + + public void configurationEvent(ConfigurationEvent configurationEvent) { + String pid = configurationEvent.getFactoryPid()!=null ? configurationEvent.getFactoryPid() : configurationEvent.getPid(); + if (configurationEvent.getType() == ConfigurationEvent.CM_DELETED) { + delegate.getStrings().remove(pid); + } else if (configurationEvent.getType() == ConfigurationEvent.CM_UPDATED) { + delegate.getStrings().add(pid); + } + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/completers/GeronimoCompleter.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/AssembleServerCommand.java (from r894297, geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/AssembleServerCommand.java) URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/AssembleServerCommand.java?p2=geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/AssembleServerCommand.java&p1=geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/AssembleServerCommand.java&r1=894297&r2=894321&rev=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/AssembleServerCommand.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/AssembleServerCommand.java Tue Dec 29 07:53:50 2009 @@ -18,11 +18,8 @@ */ -package org.apache.geronimo.shell; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.IOException; +package org.apache.geronimo.shell.deploy; import java.util.List; @@ -34,16 +31,14 @@ import org.apache.geronimo.deployment.cli.CommandListConfigurations; import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager; import org.apache.geronimo.kernel.repository.Artifact; -import org.apache.geronimo.system.plugin.model.PluginArtifactType; import org.apache.geronimo.system.plugin.model.PluginListType; -import org.apache.geronimo.system.plugin.model.PluginType; -import org.osgi.service.command.CommandSession; /** * @version $Rev$ $Date$ */ -@Command(scope = "geronimo", name = "assemble-server", description = "Extract a geronimo server from the current one") + +@Command(scope = "deploy", name = "assemble-server", description = "Extract a geronimo server from the current one") public class AssembleServerCommand extends ConnectCommand { @Option (name = "-l", aliases = {"--list"}, description = "refresh plugin list") boolean refreshList = false; Copied: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ConnectCommand.java (from r894297, geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConnectCommand.java) URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ConnectCommand.java?p2=geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ConnectCommand.java&p1=geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConnectCommand.java&r1=894297&r2=894321&rev=894321&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/ConnectCommand.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ConnectCommand.java Tue Dec 29 07:53:50 2009 @@ -18,13 +18,11 @@ */ -package org.apache.geronimo.shell; -import java.io.BufferedReader; -import java.io.InputStreamReader; +package org.apache.geronimo.shell.deploy; + import java.io.IOException; -import org.apache.felix.gogo.commands.Argument; import org.apache.felix.gogo.commands.Command; import org.apache.felix.gogo.commands.Option; import org.apache.geronimo.deployment.cli.ServerConnection; @@ -32,31 +30,32 @@ import org.apache.geronimo.deployment.plugin.factories.BaseDeploymentFactory; import org.apache.geronimo.cli.deployer.ConnectionParamsImpl; import org.apache.geronimo.kernel.basic.BasicKernel; +import org.apache.geronimo.shell.BaseCommandSupport; import org.osgi.service.command.CommandSession; /** * @version $Rev$ $Date$ */ -@Command(scope = "geronimo", name = "connect", description = "Connect to a Geronimo server") +@Command(scope = "deploy", name = "connect", description = "Connect to a Geronimo server") public class ConnectCommand extends BaseCommandSupport { // the environment variable name use to store the session. 1 public static final String SERVER_CONNECTION = "geronimo.ServerConnection"; @Option(name="-s", aliases={"--hostname", "--server"}, description="Hostname, default localhost", required = false, multiValued = false) - String hostname = "localhost"; + protected String hostname = "localhost"; @Option(name="-p", aliases={"--port"}, description="Port, default 1099", required = false, multiValued = false) - int port = 1099; + protected int port = 1099; @Option(name="-u", aliases={"--username"}, description="Username", required = false, multiValued = false) - String username; + protected String username; @Option(name="-w", aliases={"--password"}, description="Password", required = false, multiValued = false) - String password; + protected String password; @Option(name="--secure", description="Use secure channel", required = false, multiValued = false) - boolean secure = false; + protected boolean secure = false; /** * Base execution method. This serves as both the body @@ -113,7 +112,7 @@ if (connection != null) { try { - connection.close(); + connection.close(); } catch (Exception e) { // ignore @@ -136,7 +135,7 @@ */ protected ServerConnection openConnection(boolean quiet) throws Exception { if (!quiet) { - println("Connecting to Geronimo server: " + hostname + ":" + port); + println("Connecting to Geronimo server: " + hostname + ":" + port); } BasicKernel kernel = new BasicKernel("Geronimo deployer", getBundleContext()); Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DeployModuleCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DeployModuleCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DeployModuleCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DeployModuleCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,75 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.LinkedList; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; +import org.apache.geronimo.cli.deployer.DistributeCommandArgs; +import org.apache.geronimo.cli.deployer.DistributeCommandArgsImpl; +import org.apache.geronimo.deployment.cli.CommandDeploy; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "deploy-module", description = "Deploy a module") +public class DeployModuleCommand extends ConnectCommand { + + @Option(name = "-i", aliases = { "--inPlace" }, description = "In-place deployment") + boolean inPlace; + + @Option(name = "-t", aliases = { "--targets" }, description = "Targets") + String targets; + + @Argument(required = true, index = 0, description = "Module file") + String module; + + @Argument(index = 1, description = "Module plan") + String modulePlan; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + CommandDeploy command = new CommandDeploy(); + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + List commandArgs = new LinkedList(); + commandArgs.add(module); + + if (modulePlan != null) { + commandArgs.add(modulePlan); + } + + DistributeCommandArgs args = new DistributeCommandArgsImpl(commandArgs.toArray(new String[commandArgs.size()])); + + command.execute(consoleReader, connection, args); + + return null; + } + +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DeployModuleCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DisconnectCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DisconnectCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DisconnectCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DisconnectCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,53 @@ +/* + * 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.shell.deploy; + +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.deployment.cli.ServerConnection; + +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "disconnect", description = "Disconnect from a Geronimo server") +public class DisconnectCommand extends ConnectCommand { + @Override + protected Object doExecute() throws Exception { + + ServerConnection connection = (ServerConnection) session.get(ConnectCommand.SERVER_CONNECTION); + + if (connection != null) { + println("Disconnecting from Geronimo server"); + + try { + connection.close(); + } catch (Exception e) { + // ignore + } + + // session.close(); + + println("Connection ended"); + } else { + println("Not connected"); + } + return null; + } + +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DisconnectCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DistributeCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DistributeCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DistributeCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DistributeCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,99 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.LinkedList; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; +import org.apache.geronimo.cli.deployer.DistributeCommandArgs; +import org.apache.geronimo.deployment.cli.CommandDistribute; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "distribute-module", description = "Distribute a module") +public class DistributeCommand extends ConnectCommand { + + @Option(name = "-i", aliases = { "--inPlace" }, description = "In-place deployment") + boolean inPlace; + + @Option(name = "-t", aliases = { "--targets" }, description = "Targets") + String targets; + + @Argument(required = true, index = 0, description = "Module file") + String module; + + @Argument(index = 1, description = "Module plan") + String modulePlan; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + CommandDistribute command = new CommandDistribute(); + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + List commandArgs = new LinkedList(); + commandArgs.add(module); + + if (modulePlan != null) { + commandArgs.add(modulePlan); + } + + DistributeCommandArgs args = new DistributeCommandArgsImpl(commandArgs.toArray(new String[commandArgs.size()]), + (targets == null ? new String[0] : targets.split(";")), inPlace); + + command.execute(consoleReader, connection, args); + return null; + } + +} + +class DistributeCommandArgsImpl implements DistributeCommandArgs { + String[] args; + + String[] targets; + + boolean inPlace; + + public DistributeCommandArgsImpl(String[] args, String[] targets, boolean inPlace) { + this.args = args; + this.targets = targets; + this.inPlace = inPlace; + } + + public String[] getTargets() { + return targets; + } + + public boolean isInPlace() { + return inPlace; + } + + public String[] getArgs() { + return args; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/DistributeCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallLibraryCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallLibraryCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallLibraryCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallLibraryCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,80 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.Arrays; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; +import org.apache.geronimo.cli.deployer.InstallLibraryCommandArgs; +import org.apache.geronimo.deployment.cli.CommandInstallLibrary; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; + +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "install-library", description = "Install library") +public class InstallLibraryCommand extends ConnectCommand { + + @Option(name = "-g", aliases = { "--groupId" }, description = "Group id") + String groupId; + + @Argument(required = true, description = "Library file") + String libraryFile; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + CommandInstallLibrary command = new CommandInstallLibrary(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + InstallLibraryCommandArgs args = new InstallLibraryCommandArgsImpl(Arrays.asList(libraryFile).toArray( + new String[1]), groupId); + + command.execute(consoleReader, connection, args); + return null; + } + +} + +class InstallLibraryCommandArgsImpl implements InstallLibraryCommandArgs { + String[] args; + + String groupId; + + public InstallLibraryCommandArgsImpl(String[] args, String groupId) { + this.args = args; + this.groupId = groupId; + } + + public String getGroupId() { + return groupId; + } + + public String[] getArgs() { + return args; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallLibraryCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallPluginCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallPluginCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallPluginCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallPluginCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,54 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.CommandInstallCAR; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "install-plugin", description = "Install plugin") +public class InstallPluginCommand extends ConnectCommand { + + @Argument(required = true, description = "Plugin file") + String pluginFile; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + CommandInstallCAR command = new CommandInstallCAR(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + BaseCommandArgs args = new BaseCommandArgs(pluginFile.split("")); + + command.execute(consoleReader, connection, args); + return null; + } + +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/InstallPluginCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListModulesCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListModulesCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListModulesCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListModulesCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,100 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; +import org.apache.geronimo.cli.deployer.ListModulesCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandListModules; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "list-modules", description = "List modules") +public 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") + boolean stopped = false; + + @Option(name = "-r", aliases = { "--started" }, description = "Show started modules only") + boolean started = false; + + @Argument(description = "Target name") + List targets; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandListModules(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + ListModulesCommandArgs args = new ListModulesCommandArgsImpl((targets == null ? new String[0] + : (String[]) targets.toArray()), all, started, stopped); + + command.execute(consoleReader, connection, args); + return null; + } + +} + +class ListModulesCommandArgsImpl implements ListModulesCommandArgs { + String[] args; + + boolean all; + + boolean started; + + boolean stopped; + + public ListModulesCommandArgsImpl(String[] args, boolean all, boolean started, boolean stopped) { + this.all = all; + this.args = args; + this.started = started; + this.stopped = stopped; + } + + public boolean isAll() { + return all; + } + + public boolean isStarted() { + return started; + } + + public boolean isStopped() { + return stopped; + } + + public String[] getArgs() { + return args; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListModulesCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListPluginsCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListPluginsCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListPluginsCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListPluginsCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,100 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.felix.gogo.commands.Option; +import org.apache.geronimo.deployment.cli.CommandListConfigurations; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager; +import org.apache.geronimo.system.plugin.model.PluginListType; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "list-plugins", description = "List plugins") +public class ListPluginsCommand extends ConnectCommand { + + @Option(name = "-rr", aliases = { "--refresh-repository" }, description = "refresh repository") + boolean refreshRepo = false; + + @Option(name = "-rl", aliases = { "--refresh-list" }, description = "refresh plugin list") + boolean refreshList = false; + + @Option(name = "-r", aliases = { "--respository" }, description = "Repository URL") + String mavenRepoURL; + + @Argument(multiValued = true) + List pluginArtifacts; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + CommandListConfigurations command = new CommandListConfigurations(); + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + String repo = null; + PluginListType plugins = null; + + if (mavenRepoURL != null) { + plugins = command.getPluginCategories(mavenRepoURL, (GeronimoDeploymentManager) connection + .getDeploymentManager(), consoleReader); + repo = mavenRepoURL; + } else { + println("Listing configurations from Geronimo server"); + + repo = (String) session.get("PluginRepository"); + if (refreshRepo || repo == null) { + repo = command.getRepository(consoleReader, (GeronimoDeploymentManager) connection + .getDeploymentManager()); + session.put("PluginRepository", repo); + } + + plugins = (PluginListType) session.get("AvailablePlugins"); + if (refreshList || plugins == null) { + plugins = command.getPluginCategories(repo, (GeronimoDeploymentManager) connection + .getDeploymentManager(), consoleReader); + session.put("AvailablePlugins", plugins); + } + } + + if (plugins != null) { + if (pluginArtifacts != null) { + command.installPlugins((GeronimoDeploymentManager) connection.getDeploymentManager(), pluginArtifacts, + plugins, repo, consoleReader, connection); + } else { + PluginListType pluginsToInstall = command.getInstallList(plugins, consoleReader, repo); + + if (pluginsToInstall != null) { + command.installPlugins((GeronimoDeploymentManager) connection.getDeploymentManager(), + pluginsToInstall, repo, consoleReader, connection); + } + } + } + + println("list ended"); + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListPluginsCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListTargetsCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListTargetsCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListTargetsCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListTargetsCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,48 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; + +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandListTargets; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "list-targets", description = "List targets") +public class ListTargetsCommand extends ConnectCommand { + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandListTargets(); + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + BaseCommandArgs args = new BaseCommandArgs(new String[1]); + + command.execute(consoleReader, connection, args); + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/ListTargetsCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/LoginCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/LoginCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/LoginCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/LoginCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,50 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; + +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandLogin; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "login", description = "Saves the username and password for this connection") +public class LoginCommand extends ConnectCommand { + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandLogin(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + BaseCommandArgs args = new BaseCommandArgs(new String[0]); + + command.execute(consoleReader, connection, args); + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/LoginCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/NewInstanceCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/NewInstanceCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/NewInstanceCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/NewInstanceCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,57 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; + +import javax.enterprise.deploy.spi.DeploymentManager; + +import jline.ConsoleReader; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager; +import org.apache.geronimo.system.plugin.NewServerInstance; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "new-server-instance", description = "Create new server instance in a server") +public class NewInstanceCommand extends ConnectCommand { + + @Argument(required = true, description = "Name of new server instance") + String serverName; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + ConsoleReader consoleReader = new ConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + String repo = null; + String plugins = null; + + DeploymentManager deploymentManager = connection.getDeploymentManager(); + NewServerInstance newServerInstance = (NewServerInstance) ((RemoteDeploymentManager) deploymentManager) + .getImplementation(NewServerInstance.class); + newServerInstance.newServerInstance(serverName); + println("Server created"); + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/NewInstanceCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RedeployModuleCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RedeployModuleCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RedeployModuleCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RedeployModuleCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,77 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.LinkedList; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandRedeploy; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "redeploy-module", description = "Redeploy a module") +public class RedeployModuleCommand extends ConnectCommand { + + @Argument(index = 0, description = "Module file") + String moduleName; + + @Argument(index = 1, description = "Module plan") + String modulePlan; + + @Argument(index = 2, description = "Module id") + List moduleIds; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandRedeploy(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + List commandArgs = new LinkedList(); + + if (moduleName != null) { + commandArgs.add(moduleName); + } + + if (modulePlan != null) { + commandArgs.add(modulePlan); + } + + if (moduleIds != null) { + commandArgs.addAll(moduleIds); + } + + BaseCommandArgs args = new BaseCommandArgs(commandArgs.toArray(new String[commandArgs.size()])); + + command.execute(consoleReader, connection, args); + return null; + } + +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RedeployModuleCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RestartModuleCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RestartModuleCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RestartModuleCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RestartModuleCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,55 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandRestart; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "restart-module", description = "Restart a module") +public class RestartModuleCommand extends ConnectCommand { + + @Argument(required = true, multiValued = true, description = "Module name") + List moduleNames; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandRestart(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + BaseCommandArgs args = new BaseCommandArgs(moduleNames.toArray(new String[moduleNames.size()])); + + command.execute(consoleReader, connection, args); + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/RestartModuleCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StartModuleCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StartModuleCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StartModuleCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StartModuleCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,55 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandStart; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "start-module", description = "Start a module") +public class StartModuleCommand extends ConnectCommand { + + @Argument(required = true, description = "Module name") + String moduleNames; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandStart(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + BaseCommandArgs args = new BaseCommandArgs(moduleNames.split(" ")); + + command.execute(consoleReader, connection, args); + + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StartModuleCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StopModuleCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StopModuleCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StopModuleCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StopModuleCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,56 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandStop; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "stop-module", description = "Stop a module") +public class StopModuleCommand extends ConnectCommand { + + @Argument(required = true, description = "Module name") + String moduleNames; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandStop(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + BaseCommandArgs args = new BaseCommandArgs(moduleNames.split(" ")); + + command.execute(consoleReader, connection, args); + + return null; + } + +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/StopModuleCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UndeployModuleCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UndeployModuleCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UndeployModuleCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UndeployModuleCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,55 @@ +/* + * 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.shell.deploy; + +import java.io.PrintWriter; +import java.util.List; + +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; +import org.apache.geronimo.cli.deployer.BaseCommandArgs; +import org.apache.geronimo.deployment.cli.AbstractCommand; +import org.apache.geronimo.deployment.cli.CommandUndeploy; +import org.apache.geronimo.deployment.cli.ConsoleReader; +import org.apache.geronimo.deployment.cli.ServerConnection; +import org.apache.geronimo.deployment.cli.StreamConsoleReader; +/** + * @version $Rev$ $Date$ + */ +@Command(scope = "deploy", name = "undeploy-module", description = "Undeploy a module") +public class UndeployModuleCommand extends ConnectCommand { + + @Argument(required = true, multiValued = true, description = "Module name") + List moduleNames; + + @Override + protected Object doExecute() throws Exception { + ServerConnection connection = connect(); + + AbstractCommand command = new CommandUndeploy(); + + ConsoleReader consoleReader = new StreamConsoleReader(session.getKeyboard(),new PrintWriter(session.getConsole(),true)); + + BaseCommandArgs args = new BaseCommandArgs(moduleNames.toArray(new String[moduleNames.size()])); + + command.execute(consoleReader, connection, args); + return null; + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/deploy/UndeployModuleCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/AntBuilder.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/AntBuilder.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/AntBuilder.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/AntBuilder.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,94 @@ +/* + * 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.shell.geronimo; + +import java.io.PrintStream; + +import org.apache.tools.ant.DefaultLogger; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.slf4j.Logger; +/** + * @version $Rev$ $Date$ + */ +public class AntBuilder { + Project project; + + public AntBuilder(final Logger log) { + project = new Project(); + project.addBuildListener(new OutputAdapter(log)); + project.init(); + project.getBaseDir(); + + } + + public Task createTask(String task){ + return project.createTask(task); + } + + private static class OutputAdapter extends DefaultLogger { + private Logger log; + + public OutputAdapter(final Logger log) { + assert log != null; + + this.log = log; + + setOutputPrintStream(new PrintStream(System.out, true)); + setErrorPrintStream(new PrintStream(System.err, true)); + setEmacsMode(true); + + String level = System.getProperty("gshell.log.console.level"); + if ("DEBUG".equals(level)) { + setMessageOutputLevel(Project.MSG_DEBUG); + } else { + setMessageOutputLevel(Project.MSG_INFO); + } + } + + protected void printMessage(final String message, final PrintStream stream, final int priority) { + assert message != null; + assert stream != null; + + switch (priority) { + case Project.MSG_ERR: + log.error(message); + break; + + case Project.MSG_WARN: + log.warn(message); + break; + + case Project.MSG_INFO: + stream.println(message); + break; + + case Project.MSG_VERBOSE: + case Project.MSG_DEBUG: + log.debug(message); + break; + + default: + // Should never happen + throw new Error("Invalid priority: " + priority); + } + } + } +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/AntBuilder.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/BaseJavaCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/BaseJavaCommand.java?rev=894321&view=auto ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/BaseJavaCommand.java (added) +++ geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/BaseJavaCommand.java Tue Dec 29 07:53:50 2009 @@ -0,0 +1,177 @@ +/* + * 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.shell.geronimo; + +import java.io.File; +import java.net.InetAddress; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.felix.gogo.commands.Option; +import org.apache.geronimo.shell.BaseCommandSupport; +/** + * @version $Rev$ $Date$ + */ +public class BaseJavaCommand extends BaseCommandSupport { + + AntBuilder ant; + + // @Option(required=true, name = "shellInfo") + // ShellInfo shellInfo; + + @Option(name = "-H", aliases = { "--home" }, description = "Use a specific Geronimo home directory") + String geronimoHome; + + @Option(name = "-j", aliases = { "--jvm" }, description = "Use a specific Java Virtual Machine for server process") + String javaVirtualMachine; + + @Option(name = "-A", aliases = { "--javaagent" }, description = "Use a specific Java Agent, set to \"none\" to disable") + String javaAgent; + + @Option(name = "-l", aliases = { "--logfile" }, description = "Capture console output to file") + String logFile; + + @Option(name = "-b", aliases = { "--background" }, description = "Run the server process in the background") + boolean background = false; + + @Option(name = "-t", aliases = { "--timeout" }, description = "Specify the timeout for the server process in seconds") + int timeout = -1; + + @Option(name = "-P", aliases = { "--profile" }, multiValued = true, description = "Select a configuration profile") + List profiles; + + Map properties = new HashMap();; + + protected void addPropertyFrom(final String nameValue, final String prefix) { + assert nameValue != null; + + String name, value; + int i = nameValue.indexOf("="); + + if (i == -1) { + name = nameValue; + value = Boolean.TRUE.toString(); + } else { + name = nameValue.substring(0, i); + value = nameValue.substring(i + 1, nameValue.length()); + } + name = name.trim(); + + if (prefix != null) { + name = prefix + name; + } + + properties.put(name, value); + } + + @Option(name = "-D", aliases = { "--property" }, multiValued = true, description = "Define system properties") + List propertyFrom; + + @Option(name = "-G", aliases = { "--gproperty" }, multiValued = true, description = "Define an org.apache.geronimo property") + List gPropertyFrom; + + @Option(name = "-J", aliases = { "--javaopt" }, description = "Set a JVM flag") + List javaFlags; + + protected File getJavaAgentJar() { + File file = new File(geronimoHome, "bin/jpa.jar"); + + if (javaAgent != null) { + if (javaAgent.toLowerCase() == "none") { + file = null; + } else { + file = new File(javaAgent); + + if (!file.exists()) { + log.warn("Disabling Java Agent support; missing jar: "+ file); + file = null; + } + } + } + + return file; + } +/* + * No need of rc.d + * definely need java6 and totally change the way server started + */ + /** + * Process custom rc.d scripts. + + protected void processScripts() { + // + // FIXME: Make the base directory configurable + // + + File basedir = new File(geronimoHome, "etc/rc.d"); + if (!basedir.exists()) { + log.debug("Skipping script processing; missing base directory: "+basedir); + return; + } + + // Use the target commands name (not the alias name) + String name = context.info.name; + + def scanner = ant.fileScanner { + fileset(dir: basedir) { + include(name: "${name},*.groovy"); + } + } + + Binding binding = new Binding([command: this, log: log, io: io]); + GroovyShell shell = new GroovyShell(binding); + + for (file in scanner) { + log.debug("Evaluating script: "+file); + + // Use InputStream method to avoid classname problems from the file's name + shell.evaluate(file.newInputStream()); + } + } + */ + + protected String prefixSystemPath(final String name, final File file) { + assert name != null; + assert file != null; + + String path = file.getPath(); + String prop = System.getProperty(name, ""); + if (prop != null) { + path += File.pathSeparator + prop; + } + + return path; + } + + @Override + protected Object doExecute() throws Exception { + // TODO Auto-generated method stub + return null; + } +} + +interface ShellInfo { + File getHomeDir(); + + InetAddress getLocalHost(); + + String getUserName(); +} Propchange: geronimo/server/trunk/framework/modules/geronimo-shell-base/src/main/java/org/apache/geronimo/shell/geronimo/BaseJavaCommand.java ------------------------------------------------------------------------------ svn:eol-style = native