* @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
*/
public class ExampleRunner {
public static void main(String[] args) throws Exception {
DomainDeploymentUtils utils = null;
try {
utils = new DomainDeploymentUtils("ds-mbean.sar", Test.class.getPackage());
utils.deploy();
ObjectName objectName = new ObjectName("jboss:name=test,type=ds");
MBeanServerConnection mbeanServer = utils.getServerOneConnection();
System.out.println("Calling TestMBean.test() on server one");
String s = (String) mbeanServer.invoke(objectName, "test", new Object[0], new String[0]);
System.out.println("Received reply: " + s);
mbeanServer = utils.getServerTwoConnection();
System.out.println("Calling TestMBean.test() on server two");
s = (String) mbeanServer.invoke(objectName, "test", new Object[0], new String[0]);
System.out.println("Received reply: " + s);
} catch (Exception e) {
Throwable parent = e;
while (parent != null) {
if (parent instanceof NameNotFoundException && e.getMessage().indexOf("H2DS") > -1) {
usage(parent);
return;
}
parent = parent.getCause();
}
e.printStackTrace();
} finally {
utils.undeploy();
safeClose(utils);
}
}