Let's add a jira for this new feature.
On Apr 8, 2012, at 7:28 AM, [email protected] wrote: > Author: rmannibucau > Date: Sun Apr 8 14:28:24 2012 > New Revision: 1311012 > > URL: http://svn.apache.org/viewvc?rev=1311012&view=rev > Log: > adding a JMX deployer for openejb (avoid ssh when not mandatory) > > Added: > > openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/JMXDeployer.java > > Added: > openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/JMXDeployer.java > URL: > http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/JMXDeployer.java?rev=1311012&view=auto > ============================================================================== > --- > openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/JMXDeployer.java > (added) > +++ > openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/JMXDeployer.java > Sun Apr 8 14:28:24 2012 > @@ -0,0 +1,68 @@ > +package org.apache.openejb.assembler; > + > +import java.util.Collection; > +import java.util.Properties; > +import javax.management.Description; > +import javax.management.MBean; > +import javax.management.ManagedAttribute; > +import javax.management.ManagedOperation; > +import javax.naming.Context; > +import javax.naming.InitialContext; > +import javax.naming.NamingException; > +import org.apache.openejb.assembler.classic.AppInfo; > +import org.apache.openejb.core.LocalInitialContextFactory; > + > +@MBean > +@Description("OpenEJB Deployer") > +public class JMXDeployer { > + @ManagedOperation > + @Description("Deploy the specified application") > + public String deploy(final String location) { > + try { > + deployer().deploy(location); > + return "OK"; > + } catch (Exception e) { > + return "ERR:" + e.getMessage(); > + } > + } > + > + @ManagedOperation > + @Description("Undeploy the specified application") > + public String undeploy(final String moduleId) { > + try { > + deployer().undeploy(moduleId); > + return "OK"; > + } catch (Exception e) { > + return "ERR:" + e.getMessage(); > + } > + } > + > + @ManagedAttribute > + @Description("List available applications") > + public String[] getDeployedApplications() { > + try { > + final Collection<AppInfo> apps = deployer().getDeployedApps(); > + final String[] appsNames = new String[apps.size()]; > + int i = 0; > + for (AppInfo info : apps) { > + appsNames[i++] = info.path; > + } > + return appsNames; > + } catch (Exception e) { > + return new String[] { "ERR:" + e.getMessage() }; > + } > + } > + > + private static Deployer deployer() throws NamingException { > + final Properties p = new Properties(); > + p.setProperty(Context.INITIAL_CONTEXT_FACTORY, > LocalInitialContextFactory.class.getName()); > + > + final ClassLoader oldCl = > Thread.currentThread().getContextClassLoader(); > + > Thread.currentThread().setContextClassLoader(DeployerEjb.class.getClassLoader()); > + try { > + return (Deployer) new > InitialContext(p).lookup("openejb/DeployerBusinessRemote"); > + } finally { > + Thread.currentThread().setContextClassLoader(oldCl); > + } > + } > +} > > >
