ObjectName objectName,
String operationName,
String[] params,
String[] signature){
OperationResultData resultData =
new OperationResultData(appConfig.getName());
ServerConnection serverConnection = null;
try {
serverConnection = ServerConnector.getServerConnection(appConfig);
Object[] typedParams = getTypedArray(appConfig,
params, signature);
final Object result = serverConnection.invoke(objectName, operationName,
typedParams, signature);
resultData.setOutput(result);
UserActivityLogger.getInstance().logActivity(
context.getUser().getUsername(),
"Performed "+operationName+" on "+objectName.getCanonicalName()
+ " in application " + appConfig.getName());
} catch (ConnectionFailedException e) {
logger.log(Level.INFO, "Error executing operation " +
operationName + " on " + objectName, e);
resultData.setResult(OperationResultData.RESULT_ERROR);
resultData.setErrorString(ErrorCatalog.getMessage(ErrorCodes.CONNECTION_FAILED));
} catch (RuntimeException e){
logger.log(Level.SEVERE, "Error executing operation " +
operationName + " on " + objectName, e);
resultData.setResult(OperationResultData.RESULT_ERROR);
if(e.getCause() != null){
if(e.getCause().getClass().getName().
equals("javax.management.RuntimeMBeanException") &&
e.getCause().getCause() != null){
resultData.setException(e.getCause().getCause());
}else{
resultData.setException(e.getCause());
}
}else{
resultData.setException(e);
}
} catch (Exception e){
logger.log(Level.SEVERE, "Error executing operation " +
operationName + " on " + objectName, e);
resultData.setResult(OperationResultData.RESULT_ERROR);
resultData.setException(e);
} finally {
ServiceUtils.close(serverConnection);
}
return resultData;
}