001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.servicemix.common;
018:
019: import java.util.MissingResourceException;
020: import java.util.logging.Logger;
021:
022: import javax.jbi.JBIException;
023: import javax.jbi.component.ComponentContext;
024: import javax.jbi.management.MBeanNames;
025: import javax.jbi.messaging.DeliveryChannel;
026: import javax.jbi.messaging.MessagingException;
027: import javax.jbi.servicedesc.ServiceEndpoint;
028: import javax.management.MBeanServer;
029: import javax.naming.InitialContext;
030: import javax.xml.namespace.QName;
031:
032: import org.w3c.dom.Document;
033: import org.w3c.dom.DocumentFragment;
034:
035: public class EndpointComponentContext implements ComponentContext {
036:
037: private Endpoint endpoint;
038: private ComponentContext context;
039: private DeliveryChannel channel;
040:
041: public EndpointComponentContext(Endpoint endpoint) {
042: this .endpoint = endpoint;
043: this .context = endpoint.getServiceUnit().getComponent()
044: .getComponentContext();
045: }
046:
047: public Endpoint getEndpoint() {
048: return endpoint;
049: }
050:
051: public ComponentContext getComponentContext() {
052: return context;
053: }
054:
055: public ServiceEndpoint activateEndpoint(QName serviceName,
056: String endpointName) throws JBIException {
057: throw new UnsupportedOperationException();
058: }
059:
060: public void deactivateEndpoint(ServiceEndpoint endpoint)
061: throws JBIException {
062: throw new UnsupportedOperationException();
063: }
064:
065: public void deregisterExternalEndpoint(
066: ServiceEndpoint externalEndpoint) throws JBIException {
067: throw new UnsupportedOperationException();
068: }
069:
070: public String getComponentName() {
071: return context.getComponentName();
072: }
073:
074: public DeliveryChannel getDeliveryChannel()
075: throws MessagingException {
076: if (this .channel == null) {
077: this .channel = new EndpointDeliveryChannel(endpoint);
078: }
079: return this .channel;
080: }
081:
082: public ServiceEndpoint getEndpoint(QName service, String name) {
083: return context.getEndpoint(service, name);
084: }
085:
086: public Document getEndpointDescriptor(ServiceEndpoint endpoint)
087: throws JBIException {
088: return context.getEndpointDescriptor(endpoint);
089: }
090:
091: public ServiceEndpoint[] getEndpoints(QName interfaceName) {
092: return context.getEndpoints(interfaceName);
093: }
094:
095: public ServiceEndpoint[] getEndpointsForService(QName serviceName) {
096: return context.getEndpointsForService(serviceName);
097: }
098:
099: public ServiceEndpoint[] getExternalEndpoints(QName interfaceName) {
100: return context.getExternalEndpoints(interfaceName);
101: }
102:
103: public ServiceEndpoint[] getExternalEndpointsForService(
104: QName serviceName) {
105: return context.getExternalEndpointsForService(serviceName);
106: }
107:
108: public String getInstallRoot() {
109: return context.getInstallRoot();
110: }
111:
112: public Logger getLogger(String suffix, String resourceBundleName)
113: throws MissingResourceException, JBIException {
114: return context.getLogger(suffix, resourceBundleName);
115: }
116:
117: public MBeanNames getMBeanNames() {
118: return context.getMBeanNames();
119: }
120:
121: public MBeanServer getMBeanServer() {
122: return context.getMBeanServer();
123: }
124:
125: public InitialContext getNamingContext() {
126: return context.getNamingContext();
127: }
128:
129: public Object getTransactionManager() {
130: return context.getTransactionManager();
131: }
132:
133: public String getWorkspaceRoot() {
134: return context.getWorkspaceRoot();
135: }
136:
137: public void registerExternalEndpoint(
138: ServiceEndpoint externalEndpoint) throws JBIException {
139: throw new UnsupportedOperationException();
140: }
141:
142: public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
143: return context.resolveEndpointReference(epr);
144: }
145:
146: }
|