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.activemq.ra;
018
019 import javax.jms.Connection;
020 import javax.jms.ConnectionConsumer;
021 import javax.jms.ConnectionMetaData;
022 import javax.jms.Destination;
023 import javax.jms.ExceptionListener;
024 import javax.jms.JMSException;
025 import javax.jms.Queue;
026 import javax.jms.QueueConnection;
027 import javax.jms.QueueSession;
028 import javax.jms.ServerSessionPool;
029 import javax.jms.Session;
030 import javax.jms.Topic;
031 import javax.jms.TopicConnection;
032 import javax.jms.TopicSession;
033
034 import org.apache.activemq.ActiveMQConnectionMetaData;
035
036 /**
037 * A {@link Connection} implementation which can be used with the ActiveMQ JCA
038 * Resource Adapter to publish messages using the same JMS session that is used to dispatch
039 * messages.
040 *
041 * @version $Revision$
042 */
043 public class InboundConnectionProxy implements Connection, QueueConnection, TopicConnection {
044
045 public Session createSession(boolean transacted, int ackMode) throws JMSException {
046 // TODO we could decide to barf if someone passes in incompatible options
047 return new InboundSessionProxy();
048 }
049
050 public QueueSession createQueueSession(boolean transacted, int ackMode) throws JMSException {
051 // TODO we could decide to barf if someone passes in incompatible options
052 return new InboundSessionProxy();
053 }
054
055 public TopicSession createTopicSession(boolean transacted, int ackMode) throws JMSException {
056 // TODO we could decide to barf if someone passes in incompatible options
057 return new InboundSessionProxy();
058 }
059
060 public void start() throws JMSException {
061 // the JCA RA is in control of this
062 }
063
064 public void stop() throws JMSException {
065 // the JCA RA is in control of this
066 }
067
068 public void close() throws JMSException {
069 // the JCA RA is in control of this
070 }
071
072 public ConnectionMetaData getMetaData() throws JMSException {
073 return ActiveMQConnectionMetaData.INSTANCE;
074 }
075
076 public String getClientID() throws JMSException {
077 throw createNotSupported("getClientID()");
078 }
079
080 public void setClientID(String s) throws JMSException {
081 throw createNotSupported("setClient()");
082 }
083
084 public ExceptionListener getExceptionListener() throws JMSException {
085 throw createNotSupported("getExceptionListener()");
086 }
087
088 public void setExceptionListener(ExceptionListener exceptionListener) throws JMSException {
089 throw createNotSupported("setExceptionListener()");
090 }
091
092 public ConnectionConsumer createConnectionConsumer(Destination destination, String s, ServerSessionPool serverSessionPool, int i) throws JMSException {
093 throw createNotSupported("createConnectionConsumer()");
094 }
095
096 public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String s, String s1, ServerSessionPool serverSessionPool, int i) throws JMSException {
097 throw createNotSupported("createDurableConnectionConsumer()");
098 }
099
100 public ConnectionConsumer createConnectionConsumer(Queue queue, String s, ServerSessionPool serverSessionPool, int i) throws JMSException {
101 throw createNotSupported("createConnectionConsumer()");
102 }
103
104 public ConnectionConsumer createConnectionConsumer(Topic topic, String s, ServerSessionPool serverSessionPool, int i) throws JMSException {
105 throw createNotSupported("createConnectionConsumer()");
106 }
107
108 protected JMSException createNotSupported(String text) {
109 return new JMSException("Operation: " + text + " is not supported for this proxy JCA ResourceAdapter provider");
110 }
111 }