if (destComponent != null)
{
Object flowConstruct = muleContext.getRegistry().lookupObject(destComponent);
if (!(flowConstruct instanceof FlowConstruct && flowConstruct instanceof MessageProcessor))
{
return handleException(null, new DefaultMuleException(ClientMessages.noSuchFlowConstruct(destComponent)));
}
// Need to do this otherise when the event is invoked the
// transformer associated with the Mule Admin queue will be invoked, but
// the message will not be of expected type
EndpointBuilder builder = new EndpointURIEndpointBuilder(inboundEndpoint);
// TODO - is this correct? it stops any other transformer from being set
builder.setTransformers(new LinkedList());
InboundEndpoint ep = muleContext.getEndpointFactory().getInboundEndpoint(builder);
MuleEvent event = new DefaultMuleEvent(action.getMessage(), ep, context.getFlowConstruct(),
context.getSession());
event = RequestContext.setEvent(event);
if (context.getExchangePattern().hasResponse())
{
MuleEvent resultEvent = ((MessageProcessor) flowConstruct).process(event);
result = resultEvent == null || VoidMuleEvent.getInstance().equals(resultEvent)
? null
: resultEvent.getMessage();
if (result == null)
{
return null;
}
else
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
wireFormat.write(out, result, getEncoding());
return out.toByteArray();
}
}
else
{
((MessageProcessor) flowConstruct).process(event);
return null;
}
}
else
{
return handleException(result, new DefaultMuleException(
CoreMessages.couldNotDetermineDestinationComponentFromEndpoint(endpoint)));
}
}