|
|
Re: Correct way to deploy configuration artifacts from tooling [message #723426 is a reply to message #722583] |
Thu, 08 September 2011 14:22 |
Jack Lynch Messages: 9 Registered: August 2011 |
Junior Member |
|
|
Just mentioning this in case you're not aware of it; there is a Deployer interface accessible via JMX. For example, the code below allows you to deploy for example a WAR file, without needing access to the ApplicationDeployer interface.
private void deployViaJMX(File file) {
final String objectNameStr = "org.eclipse.virgo.kernel:category=Control,type=Deployer";
final String operationName = "deploy";
final String pathToFile = "file://" + file.getAbsolutePath();
try {
final ObjectName objectName = new ObjectName(objectNameStr);
final boolean recoverOnStartup = false; // would need to guarantee the File would exist on restart..
Object result = mbeanConnection.invoke(objectName,
operationName,
new Object[] { pathToFile, recoverOnStartup },
new String[] { String.class.getName(), boolean.class.getName() } );
// (CompositeData)result; // gives symbolicName, type, version of app deployed
} catch (InstanceNotFoundException noMBeanInstanceFound) {
System.err.println("ERROR: Could not find MBean with name "
+ objectNameStr + " in MBeanServer:\n"
+ noMBeanInstanceFound.getMessage());
} catch (MBeanException mbeanEx) {
System.err.println("ERROR: Exception encountered on invoked MBean:\n" + mbeanEx.getMessage());
} catch (ReflectionException reflectionEx) {
System.err.println("ERROR trying to reflectively invoke remote MBean:\n" + reflectionEx.getMessage());
} catch (Exception ex) {
System.err.println("ERROR trying to communicate with remote MBeanServer:\n" + ex.getMessage());
}
}
[Updated on: Thu, 08 September 2011 14:25] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03698 seconds