01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
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: /**
28: * Resolves the endpoint using the service name with a pluggable {@link EndpointChooser} selection
29: * policy if more than one endpoints are found.
30: *
31: * @version $Revision: 564607 $
32: */
33: public class ServiceNameEndpointResolver extends
34: EndpointResolverSupport {
35:
36: private QName serviceName;
37:
38: public ServiceNameEndpointResolver() {
39: }
40:
41: public ServiceNameEndpointResolver(QName serviceName) {
42: this .serviceName = serviceName;
43: }
44:
45: public ServiceEndpoint[] resolveAvailableEndpoints(
46: ComponentContext context, MessageExchange exchange) {
47: return context.getEndpointsForService(serviceName);
48: }
49:
50: // Properties
51: //-------------------------------------------------------------------------
52: public QName getServiceName() {
53: return serviceName;
54: }
55:
56: public void setServiceName(QName serviceName) {
57: this .serviceName = serviceName;
58: }
59:
60: // Implementation methods
61: //-------------------------------------------------------------------------
62: protected JBIException createServiceUnavailableException() {
63: return new NoServiceAvailableException(serviceName);
64: }
65: }
|