public ImmutableEndpoint processEndpoint(AnnotatedEndpointData epData) throws MuleException
{
preprocessEndpointData(epData);
ImmutableEndpoint endpoint;
EndpointBuilder endpointBuilder = getEndpointBuilder(epData);
if (epData.getProperties() != null && epData.getProperties().size() > 0)
{
endpointBuilder.setProperties(epData.getProperties());
}
if (epData.getTransformers() != null)
{
List<Transformer> transformers = (List) convertProperty(List.class, epData.getTransformers());
endpointBuilder.setTransformers(transformers);
}
if (epData.getFilter() != null)
{
Filter filter = (Filter) convertProperty(Filter.class, epData.getFilter());
endpointBuilder.addMessageProcessor(new MessageFilter(filter));
}
if (epData.getEncoding() != null)
{
endpointBuilder.setEncoding(parsePlaceholderValues(epData.getEncoding()));
}
AbstractConnector connector;
if (epData.getConnectorName() != null)
{
connector = (AbstractConnector) muleContext.getRegistry().lookupConnector(parsePlaceholderValues(epData.getConnectorName()));
}
else if (epData.getConnector() != null)
{
connector = (AbstractConnector) epData.getConnector();
}
else
{
//We always create a new connecotr for annotations when one has not been configured
MuleEndpointURI uri = new MuleEndpointURI(parsePlaceholderValues(epData.getAddress()), muleContext);
connector = (AbstractConnector) transportFactory.createConnector(uri);
//The ibeans transport factory will not always create a new connector, check before registering
if (muleContext.getRegistry().lookupConnector(connector.getName()) == null)
{
muleContext.getRegistry().registerConnector(connector);
}
}
endpointBuilder.setConnector(connector);
//Set threading for this connector. Note we simplify by setting all profiles with a single value 'threads'
//that can be set by the user
String threadsString = (String) epData.getProperties().get("threads");
if (threadsString != null)
{
int threads = Integer.valueOf(threadsString);
connector.setMaxDispatchersActive(threads);
connector.setMaxRequestersActive(threads);
connector.getReceiverThreadingProfile().setMaxThreadsActive(threads);
connector.getReceiverThreadingProfile().setMaxThreadsIdle(threads);
}
if (epData.getName() != null)
{
endpointBuilder.setName(parsePlaceholderValues(epData.getName()));
}
endpointBuilder.setExchangePattern(epData.getMep());
if (epData.getType() == ChannelType.Inbound)
{
endpoint = endpointBuilder.buildInboundEndpoint();
}
else if (epData.getType() == ChannelType.Outbound)
{
endpoint = endpointBuilder.buildOutboundEndpoint();
}
else
{
throw new IllegalArgumentException("Channel type not recognised: " + epData.getType());
}