//By setting the connectorName we ensure that only one connector is created for each iBean
metaInfo.put("connectorName", metaData.getClazz().getSimpleName() + "." + scheme); //RM* THis affects the connector name generation + "#" + target.hashCode());
for (Iterator iterator = c.iterator(); iterator.hasNext();)
{
EndpointAnnotationParser parser = (EndpointAnnotationParser) iterator.next();
if (parser.supports(metaData.getAnnotation(), metaData.getClazz(), metaData.getMember()))
{
InterfaceBinding binding;
Method method = (Method) metaData.getMember();
boolean callChannel = false;
Annotation ann;
//This is a little messy, but we need to detect whether we are doing a Mule 'send' or Mule 'request' call.
//Request calls get data from a resource such as DB, email inbox or message queue. These types of request will
//not have any payload or headers defined.
//The other way to handle this is to introduce a new annotation to explicitly handle this (See the Get annotation).
//The issue is it may be difficult for the user to understand the difference between @Call and @Get. Instead we figure it out
//here.
for (int x = 0; x < method.getParameterAnnotations().length; x++)
{
ann = method.getParameterAnnotations()[x][0];
if (ann.annotationType().equals(Body.class) ||
ann.annotationType().equals(BodyParam.class) ||
ann.annotationType().equals(HeaderParam.class))
{
callChannel = true;
break;
}
}
//TODO remove the HTTP hack above. Its required becuase HTTP request on the dispatcher
//don't honour authenitcation for some reason. Also even though there may not be any headers
//defined we still need to attach some headers to the HTTP method. This is very difficult when
//using request
if (callChannel || http)
{
OutboundEndpoint endpoint = parser.parseOutboundEndpoint(metaData.getAnnotation(), metaInfo);
binding = new CallInterfaceBinding(this.flow);
binding.setEndpoint(endpoint);
}
else
{
InboundEndpoint endpoint = parser.parseInboundEndpoint(metaData.getAnnotation(), Collections.EMPTY_MAP);
binding = new DynamicRequestInterfaceBinding();
binding.setEndpoint(endpoint);
}
binding.setInterface(getInterface());