You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/01/18 21:33:26 UTC
svn commit: r1233050 - in
/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli:
./ command/
Author: rmannibucau
Date: Wed Jan 18 20:33:26 2012
New Revision: 1233050
URL: http://svn.apache.org/viewvc?rev=1233050&view=rev
Log:
adding deploy and undeploy command in CliRunnable
Added:
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Deploy.java
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Undeploy.java
Modified:
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/AbstractCommand.java
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyCommand.java
openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyFileCommand.java
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java?rev=1233050&r1=1233049&r2=1233050&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/CliRunnable.java Wed Jan 18 20:33:26 2012
@@ -6,12 +6,14 @@ import org.apache.openejb.assembler.clas
import org.apache.openejb.assembler.classic.cmd.Info2Properties;
import org.apache.openejb.loader.SystemInstance;
import org.apache.openejb.server.cli.command.AbstractCommand;
+import org.apache.openejb.server.cli.command.Deploy;
import org.apache.openejb.server.cli.command.ExitCommand;
import org.apache.openejb.server.cli.command.GroovyCommand;
import org.apache.openejb.server.cli.command.GroovyFileCommand;
import org.apache.openejb.server.cli.command.HelpCommand;
import org.apache.openejb.server.cli.command.ListCommand;
import org.apache.openejb.server.cli.command.PropertiesCommand;
+import org.apache.openejb.server.cli.command.Undeploy;
import org.apache.openejb.server.groovy.OpenEJBGroovyShell;
import org.apache.openejb.util.helper.CommandHelper;
import org.apache.xbean.recipe.ObjectRecipe;
@@ -35,6 +37,7 @@ public class CliRunnable implements Runn
private static final List<Class<? extends AbstractCommand>> COMMAND_CLASSES
= Arrays.asList(GroovyCommand.class, GroovyFileCommand.class,
ListCommand.class, PropertiesCommand.class,
+ Deploy.class, Undeploy.class,
HelpCommand.class, ExitCommand.class);
static {
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/AbstractCommand.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/AbstractCommand.java?rev=1233050&r1=1233049&r2=1233050&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/AbstractCommand.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/AbstractCommand.java Wed Jan 18 20:33:26 2012
@@ -1,7 +1,13 @@
package org.apache.openejb.server.cli.command;
+import org.apache.openejb.core.LocalInitialContextFactory;
import org.apache.openejb.server.cli.StreamManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Properties;
+
public abstract class AbstractCommand {
protected StreamManager streamManager;
protected String command;
@@ -21,4 +27,17 @@ public abstract class AbstractCommand {
public void setCommand(String command) {
this.command = command;
}
+
+ public <T> T lookup(final Class<T> clazz, final String jndiName) throws NamingException {
+ Properties p = new Properties();
+ p.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ try {
+ return (T) new InitialContext(p).lookup(jndiName);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+ }
}
Added: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Deploy.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Deploy.java?rev=1233050&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Deploy.java (added)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Deploy.java Wed Jan 18 20:33:26 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.openejb.server.cli.command;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.assembler.Deployer;
+
+import javax.naming.NamingException;
+
+public class Deploy extends AbstractCommand {
+ @Override
+ public String name() {
+ return "deploy";
+ }
+
+ @Override
+ public String usage() {
+ return name() + "<location>";
+ }
+
+ @Override
+ public void execute(String cmd) {
+ try {
+ lookup(Deployer.class, "openejb/DeployerBusinessRemote").deploy(cmd.substring(name().length()).trim());
+ } catch (Exception e) {
+ streamManager.writeErr(e);
+ }
+ }
+
+ @Override
+ public String description() {
+ return "deploy an application";
+ }
+}
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyCommand.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyCommand.java?rev=1233050&r1=1233049&r2=1233050&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyCommand.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyCommand.java Wed Jan 18 20:33:26 2012
@@ -23,7 +23,7 @@ public class GroovyCommand extends Abstr
@Override
public void execute(final String cmd) {
try {
- streamManager.writeOut(streamManager.asString(shell.evaluate(cmd.substring(name().length() + 1))));
+ streamManager.writeOut(streamManager.asString(shell.evaluate(cmd.substring(name().length() + 1).trim())));
} catch (Exception e) {
streamManager.writeErr(e);
}
Modified: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyFileCommand.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyFileCommand.java?rev=1233050&r1=1233049&r2=1233050&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyFileCommand.java (original)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/GroovyFileCommand.java Wed Jan 18 20:33:26 2012
@@ -25,7 +25,7 @@ public class GroovyFileCommand extends A
@Override
public void execute(final String cmd) {
try {
- streamManager.writeOut(streamManager.asString(shell.evaluate(new File(cmd.substring(name().length() + 1)))));
+ streamManager.writeOut(streamManager.asString(shell.evaluate(new File(cmd.substring(name().length() + 1).trim()))));
} catch (Exception e) {
streamManager.writeErr(e);
}
Added: openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Undeploy.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Undeploy.java?rev=1233050&view=auto
==============================================================================
--- openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Undeploy.java (added)
+++ openejb/trunk/openejb/server/openejb-common-cli/src/main/java/org/apache/openejb/server/cli/command/Undeploy.java Wed Jan 18 20:33:26 2012
@@ -0,0 +1,46 @@
+/**
+ * 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.openejb.server.cli.command;
+
+import org.apache.openejb.assembler.Deployer;
+
+public class Undeploy extends AbstractCommand {
+ @Override
+ public String name() {
+ return "undeploy";
+ }
+
+ @Override
+ public String usage() {
+ return name() + "<location>";
+ }
+
+ @Override
+ public void execute(String cmd) {
+ try {
+ lookup(Deployer.class, "openejb/DeployerBusinessRemote").undeploy(cmd.substring(name().length()).trim());
+ } catch (Exception e) {
+ streamManager.writeErr(e);
+ }
+ }
+
+ @Override
+ public String description() {
+ return "undeploy an application. Note the location should be the same than for deploy";
+ }
+}