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 and endpoint name to resolve the {@link ServiceEndpoint}
29: *
30: * @version $Revision: 564607 $
31: */
32: public class ServiceAndEndpointNameResolver extends
33: EndpointResolverSupport {
34:
35: private QName serviceName;
36: private String endpointName;
37:
38: public ServiceAndEndpointNameResolver() {
39: }
40:
41: public ServiceAndEndpointNameResolver(QName serviceName,
42: String endpointName) {
43: this .serviceName = serviceName;
44: this .endpointName = endpointName;
45: }
46:
47: public ServiceEndpoint[] resolveAvailableEndpoints(
48: ComponentContext context, MessageExchange exchange)
49: throws JBIException {
50: ServiceEndpoint endpoint = context.getEndpoint(serviceName,
51: endpointName);
52: if (endpoint != null) {
53: return new ServiceEndpoint[] { endpoint };
54: } else {
55: return new ServiceEndpoint[0];
56: }
57: }
58:
59: // Properties
60: //-------------------------------------------------------------------------
61: public QName getServiceName() {
62: return serviceName;
63: }
64:
65: public void setServiceName(QName serviceName) {
66: this .serviceName = serviceName;
67: }
68:
69: public String getEndpointName() {
70: return endpointName;
71: }
72:
73: public void setEndpointName(String endpointName) {
74: this .endpointName = endpointName;
75: }
76:
77: // Implementation methods
78: //-------------------------------------------------------------------------
79: protected JBIException createServiceUnavailableException() {
80: return new NoServiceAvailableException(serviceName);
81: }
82: }
|