EmsConnection connection = this.serverComponent.getEmsConnection();
if (connection == null) {
throw new ExecutionFailedException("Can not connect to the server");
}
EmsBean bean = connection.getBean(mbeanName);
EmsOperation operation = bean.getOperation(operationName);
/*
* Now see if we got the 'real' method (the one with no param) or the
* overloaded one. This is a workaround for a bug in EMS that prevents
* finding operations with same name and different signature.
* http://sourceforge
* .net/tracker/index.php?func=detail&aid=2007692&group_id
* =60228&atid=493495
*
* In addition, as we offer the user to specify any MBean and any
* method, we'd need a clever way for the user to specify parameters
* anyway.
*/
try {
List<EmsParameter> params = operation.getParameters();
int count = params.size();
if (count == 0)
operation.invoke(new Object[0]);
else { // overloaded operation
operation.invoke(new Object[] { 0 }); // return code of 0
}
} catch (RuntimeException e) {
throw new ExecutionFailedException("Shutting down the server using JMX failed: " + e.getMessage(), e);
}