}
Object result;
logger.debug("Message received by RemoteDispatcherComponent");
ByteArrayInputStream in = new ByteArrayInputStream((byte[]) context.transformMessage(DataType.BYTE_ARRAY_DATA_TYPE));
RemoteDispatcherNotification action = (RemoteDispatcherNotification) ((MuleMessage)wireFormat.read(in)).getPayload();
// because we serialized a message inside a message, we need to inject the the muleContext ourselves
//TODO review the serialization format for RemoteDispatching
if(action.getMessage()!=null)
{
Method m = action.getMessage().getClass().getDeclaredMethod("initAfterDeserialisation", MuleContext.class);
m.setAccessible(true);
m.invoke(action.getMessage(), muleContext);
}
if (RemoteDispatcherNotification.ACTION_INVOKE == action.getAction())
{
result = invokeAction(action, context);
}
else if (RemoteDispatcherNotification.ACTION_SEND == action.getAction() ||
RemoteDispatcherNotification.ACTION_DISPATCH == action.getAction())
{
result = sendAction(action, context);
}
else if (RemoteDispatcherNotification.ACTION_RECEIVE == action.getAction())
{
result = receiveAction(action, context);
}
else
{
result = handleException(null, new DefaultMuleException(
CoreMessages.eventTypeNotRecognised("RemoteDispatcherNotification:" + action.getAction())));
}
return result;
}