// Lookup and invoke.
Object instance = createInstance(factoryInstance.getInstanceClass());
if (instance == null)
{
MessageException me = new MessageException("Null instance returned from: " + factoryInstance);
me.setCode("Server.Processing");
throw me;
}
Class c = instance.getClass();
MethodMatcher methodMatcher = remotingDestination.getMethodMatcher();
Method method = methodMatcher.getMethod(c, methodName, parameters);
result = method.invoke(instance, parameters.toArray());
saveInstance(instance);
}
catch (InvocationTargetException ex)
{
/*
* If the invocation exception wraps a message exception, unwrap it and
* rethrow the nested message exception. Otherwise, build and throw a new
* message exception.
*/
Throwable cause = ex.getCause();
if ((cause != null) && (cause instanceof MessageException))
{
throw (MessageException) cause;
}
else if (cause != null)
{
// Log a warning for this client's selector and continue
if (Log.isError())
{
Log.getLogger(LOG_CATEGORY).error("Error processing remote invocation: " +
cause.toString() + StringUtils.NEWLINE +
" incomingMessage: " + message + StringUtils.NEWLINE +
ExceptionUtil.toString(cause));
}
MessageException me = new MessageException(cause.getClass().getName() + " : " + cause.getMessage());
me.setCode("Server.Processing");
me.setRootCause(cause);
throw me;
}
else
{
MessageException me = new MessageException(ex.getMessage());
me.setCode("Server.Processing");
throw me;
}
}
catch (IllegalAccessException ex)
{
MessageException me = new MessageException(ex.getMessage());
me.setCode("Server.Processing");
throw me;
}
return result;
}