i'll fo it (i should have done it since the build was passed ;)) well this feature is not from me but a guy who noticed during the Tours JUG that we can do it through JMX instead of SSH and he was so right i had to add to it.
- Romain 2012/4/8 David Blevins <[email protected]> > Great feature btw :) > > On Apr 8, 2012, at 1:18 PM, David Blevins wrote: > > > 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); > >> + } > >> + } > >> +} > >> > >> > >> > > > >
