1 17 package org.apache.servicemix.jbi.resolver; 18 19 import javax.jbi.JBIException; 20 import javax.jbi.component.ComponentContext; 21 import javax.jbi.messaging.MessageExchange; 22 import javax.jbi.servicedesc.ServiceEndpoint; 23 import javax.xml.namespace.QName ; 24 25 import org.apache.servicemix.jbi.NoServiceAvailableException; 26 27 32 public class ServiceAndEndpointNameResolver extends EndpointResolverSupport { 33 34 private QName serviceName; 35 private String endpointName; 36 37 public ServiceAndEndpointNameResolver() { 38 } 39 40 public ServiceAndEndpointNameResolver(QName serviceName, String endpointName) { 41 this.serviceName = serviceName; 42 this.endpointName = endpointName; 43 } 44 45 public ServiceEndpoint[] resolveAvailableEndpoints(ComponentContext context, MessageExchange exchange) throws JBIException { 46 ServiceEndpoint endpoint = context.getEndpoint(serviceName, endpointName); 47 if (endpoint != null) { 48 return new ServiceEndpoint[]{endpoint}; 49 } 50 else { 51 return new ServiceEndpoint[0]; 52 } 53 } 54 55 public QName getServiceName() { 58 return serviceName; 59 } 60 61 public void setServiceName(QName serviceName) { 62 this.serviceName = serviceName; 63 } 64 65 public String getEndpointName() { 66 return endpointName; 67 } 68 69 public void setEndpointName(String endpointName) { 70 this.endpointName = endpointName; 71 } 72 73 protected JBIException createServiceUnavailableException() { 76 return new NoServiceAvailableException(serviceName); 77 } 78 } 79 | Popular Tags |