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().getComponentContext();
044 }
045
046 public Endpoint getEndpoint() {
047 return endpoint;
048 }
049
050 public ComponentContext getComponentContext() {
051 return context;
052 }
053
054 public ServiceEndpoint activateEndpoint(QName serviceName, String endpointName) throws JBIException {
055 throw new UnsupportedOperationException();
056 }
057
058 public void deactivateEndpoint(ServiceEndpoint endpoint) throws JBIException {
059 throw new UnsupportedOperationException();
060 }
061
062 public void deregisterExternalEndpoint(ServiceEndpoint externalEndpoint) throws JBIException {
063 throw new UnsupportedOperationException();
064 }
065
066 public String getComponentName() {
067 return context.getComponentName();
068 }
069
070 public DeliveryChannel getDeliveryChannel() throws MessagingException {
071 if (this.channel == null) {
072 this.channel = new EndpointDeliveryChannel(endpoint);
073 }
074 return this.channel;
075 }
076
077 public ServiceEndpoint getEndpoint(QName service, String name) {
078 return context.getEndpoint(service, name);
079 }
080
081 public Document getEndpointDescriptor(ServiceEndpoint endpoint) throws JBIException {
082 return context.getEndpointDescriptor(endpoint);
083 }
084
085 public ServiceEndpoint[] getEndpoints(QName interfaceName) {
086 return context.getEndpoints(interfaceName);
087 }
088
089 public ServiceEndpoint[] getEndpointsForService(QName serviceName) {
090 return context.getEndpointsForService(serviceName);
091 }
092
093 public ServiceEndpoint[] getExternalEndpoints(QName interfaceName) {
094 return context.getExternalEndpoints(interfaceName);
095 }
096
097 public ServiceEndpoint[] getExternalEndpointsForService(QName serviceName) {
098 return context.getExternalEndpointsForService(serviceName);
099 }
100
101 public String getInstallRoot() {
102 return context.getInstallRoot();
103 }
104
105 public Logger getLogger(String suffix, String resourceBundleName) throws MissingResourceException, JBIException {
106 return context.getLogger(suffix, resourceBundleName);
107 }
108
109 public MBeanNames getMBeanNames() {
110 return context.getMBeanNames();
111 }
112
113 public MBeanServer getMBeanServer() {
114 return context.getMBeanServer();
115 }
116
117 public InitialContext getNamingContext() {
118 return context.getNamingContext();
119 }
120
121 public Object getTransactionManager() {
122 return context.getTransactionManager();
123 }
124
125 public String getWorkspaceRoot() {
126 return context.getWorkspaceRoot();
127 }
128
129 public void registerExternalEndpoint(ServiceEndpoint externalEndpoint) throws JBIException {
130 throw new UnsupportedOperationException();
131 }
132
133 public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
134 return context.resolveEndpointReference(epr);
135 }
136
137 }