Methods Summary |
---|
private java.util.Properties | buildJNDIEnv()
if (jndiEnv == null)
{
jndiEnv = new Properties();
// Parse the query string for name=value pairs to put into the env
String query = deployURI.getQuery();
if (query != null)
{
log.debug("Parsing query string: " + query);
StringTokenizer tokenizer = new StringTokenizer(query, "=&");
while (tokenizer.hasMoreTokens())
{
String name = tokenizer.nextToken();
String value = tokenizer.nextToken();
jndiEnv.setProperty(name, value);
}
}
// Set defaults for missing properties
if (jndiEnv.getProperty(Context.INITIAL_CONTEXT_FACTORY) == null)
{
jndiEnv.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
}
if (jndiEnv.getProperty(Context.PROVIDER_URL) == null)
{
String host = deployURI.getHost();
if (host == null)
{
try
{
host = InetAddress.getLocalHost().getHostName();
}
catch (UnknownHostException e)
{
host = "localhost";
}
}
int port = deployURI.getPort();
if (port <= 0)
{
port = 1099;
}
String jnpURL = "jnp://" + host + ':" + port;
jndiEnv.setProperty(Context.PROVIDER_URL, jnpURL);
}
if (jndiEnv.getProperty(Context.OBJECT_FACTORIES) == null)
{
jndiEnv.setProperty(Context.OBJECT_FACTORIES, "org.jboss.naming");
}
}
return jndiEnv;
|
private void | convertChildren(TargetModuleIDImpl parent, SerializableTargetModuleID parentID)
SerializableTargetModuleID[] children = parentID.getChildModuleIDs();
int length = children != null ? children.length : 0;
for (int n = 0; n < length; n++)
{
SerializableTargetModuleID id = children[n];
String moduleID = id.getModuleID();
boolean isRunning = id.isRunning();
ModuleType type = ModuleType.getModuleType(id.getModuleType());
TargetModuleIDImpl child = new TargetModuleIDImpl(this, moduleID, parent, isRunning, type);
parent.addChildTargetModuleID(child);
convertChildren(child, id);
}
|
public void | deploy(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)Deploy a given module
TargetModuleIDImpl moduleID = (TargetModuleIDImpl)targetModuleID;
SerializableTargetModuleID smoduleID = new SerializableTargetModuleID(moduleID);
MBeanServerConnection server = getMBeanServerConnection();
String url = targetModuleID.getModuleID();
Object[] args = { smoduleID };
String[] sig = { smoduleID.getClass().getName() };
log.info("Begin deploy: " + url);
server.invoke(jsr88MBean, "deploy", args, sig);
log.info("End deploy");
|
public javax.enterprise.deploy.spi.TargetModuleID[] | getAvailableModules(javax.enterprise.deploy.shared.ModuleType moduleType)Retrieve the list of all J2EE application modules running or not running
on the identified targets.
try
{
List list = new ArrayList();
MBeanServerConnection server = getMBeanServerConnection();
Object[] args = { new Integer(moduleType.getValue()) };
String[] sig = { int.class.getName() };
SerializableTargetModuleID[] modules = (SerializableTargetModuleID[])server.invoke(jsr88MBean, "getAvailableModules", args, sig);
for (int n = 0; n < modules.length; n++)
{
SerializableTargetModuleID id = modules[n];
String moduleID = id.getModuleID();
boolean isRunning = id.isRunning();
ModuleType type = ModuleType.getModuleType(id.getModuleType());
TargetModuleIDImpl tmid = new TargetModuleIDImpl(this, moduleID, null, isRunning, type);
convertChildren(tmid, id);
list.add(tmid);
}
TargetModuleID[] targetModuleIDs = new TargetModuleID[list.size()];
list.toArray(targetModuleIDs);
return targetModuleIDs;
}
catch (Exception e)
{
log.error("Cannot get available modules", e);
TargetException tex = new TargetException("");
tex.initCause(e);
throw tex;
}
|
public java.lang.String | getDescription()Get the target's description
return "JBoss JMX deployment target";
|
public java.lang.String | getHostName()Get the target's host name
return deployURI.getHost();
|
private javax.management.MBeanServerConnection | getMBeanServerConnection()
Properties env = buildJNDIEnv();
String lookupPath = deployURI.getPath();
log.debug("JNDI lookup: " + lookupPath);
log.trace("Creating InitialContext with env: " + env);
InitialContext ctx = new InitialContext(env);
MBeanServerConnection server = (MBeanServerConnection)ctx.lookup(lookupPath);
return server;
|
public java.lang.String | getName()Get the target's name
return deployURI.toString();
|
private void | parseQuery()Parse the query portion of the deployment URI to look for options:
jsr88MBean : specifies the JSR88 mbean service that provides the
deployment manager deploy/start/stop/undeploy operations.
String query = deployURI.getRawQuery();
log.debug("DeployURI.rawQuery: " + query);
Properties params = new Properties();
if (query != null)
{
/* Break the raw query into the name=value pairs. This processing is
too fragile to how the URI was built as it expects that only
the name/value portions of the query were encoded.
*/
String[] options = query.split("[&=]");
for (int n = 0; n < options.length; n += 2)
{
String name = URLDecoder.decode(options[n], "UTF-8");
String value = URLDecoder.decode(options[n + 1], "UTF-8");
params.setProperty(name, value);
}
}
String name = params.getProperty(JSR88_MBEAN_OPT, JSR88_MBEAN);
jsr88MBean = new ObjectName(name);
|
public void | start(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)Start a given module
MBeanServerConnection server = getMBeanServerConnection();
URL url = new URL(targetModuleID.getModuleID());
Object[] args = { url };
String[] sig = { URL.class.getName() };
log.debug("Start: " + url);
args = new Object[] { url.toExternalForm() };
sig = new String[] { String.class.getName() };
log.info("Begin start: " + url);
server.invoke(jsr88MBean, "start", args, sig);
log.info("End start");
|
public void | stop(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)Stop a given module
MBeanServerConnection server = getMBeanServerConnection();
URL url = new URL(targetModuleID.getModuleID());
Object[] args = { url };
String[] sig = { URL.class.getName() };
log.debug("Stop: " + url);
args = new Object[] { url.toExternalForm() };
sig = new String[] { String.class.getName() };
log.info("Begin stop: " + url);
server.invoke(jsr88MBean, "stop", args, sig);
log.info("End stop");
|
public void | undeploy(javax.enterprise.deploy.spi.TargetModuleID targetModuleID)Undeploy a given module
MBeanServerConnection server = getMBeanServerConnection();
String url = targetModuleID.getModuleID();
Object[] args = { url };
String[] sig = { String.class.getName() };
log.info("Begin undeploy: " + url);
server.invoke(jsr88MBean, "undeploy", args, sig);
log.info("End undeploy");
|