001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq.server;
023:
024: import javax.jms.Destination;
025: import javax.jms.JMSException;
026: import javax.jms.Queue;
027: import javax.jms.TemporaryQueue;
028: import javax.jms.TemporaryTopic;
029: import javax.jms.Topic;
030: import javax.transaction.xa.Xid;
031:
032: import org.jboss.logging.Logger;
033: import org.jboss.mq.AcknowledgementRequest;
034: import org.jboss.mq.ConnectionToken;
035: import org.jboss.mq.DurableSubscriptionID;
036: import org.jboss.mq.Recoverable;
037: import org.jboss.mq.SpyDestination;
038: import org.jboss.mq.SpyMessage;
039: import org.jboss.mq.SpyTopic;
040: import org.jboss.mq.Subscription;
041: import org.jboss.mq.TransactionRequest;
042: import org.jboss.mq.il.Invoker;
043:
044: /**
045: * A pass through JMSServerInvoker.
046: *
047: * @author <a href="mailto:pra@tim.se">Peter Antman</a>
048: * @author <a href="adrian@jboss.org">Adrian Brock</a>
049: * @version $Revision: 57198 $
050: */
051: public class JMSServerInvoker implements Invoker, Recoverable {
052: protected Logger log;
053: /**
054: * Next invoker in chain.
055: */
056: protected JMSServerInterceptor nextInterceptor = null;
057:
058: public JMSServerInvoker() {
059: log = Logger.getLogger(this .getClass().getName());
060: }
061:
062: /**
063: * Set next invoker in chain to be called. Is mot often the real JMSServer
064: */
065: public void setNext(JMSServerInterceptor server) {
066: this .nextInterceptor = server;
067: }
068:
069: /**
070: * @see JMSServerInterceptor#getNext()
071: */
072: public JMSServerInterceptor getNext() {
073: return this .nextInterceptor;
074: }
075:
076: public ThreadGroup getThreadGroup() {
077: return nextInterceptor.getThreadGroup();
078: }
079:
080: public String getID() throws JMSException {
081: return nextInterceptor.getID();
082: }
083:
084: public TemporaryTopic getTemporaryTopic(ConnectionToken dc)
085: throws JMSException {
086: return nextInterceptor.getTemporaryTopic(dc);
087: }
088:
089: public TemporaryQueue getTemporaryQueue(ConnectionToken dc)
090: throws JMSException {
091: return nextInterceptor.getTemporaryQueue(dc);
092: }
093:
094: public void connectionClosing(ConnectionToken dc)
095: throws JMSException {
096: nextInterceptor.connectionClosing(dc);
097: }
098:
099: public void checkID(String ID) throws JMSException {
100: nextInterceptor.checkID(ID);
101: }
102:
103: public void addMessage(ConnectionToken dc, SpyMessage message)
104: throws JMSException {
105: nextInterceptor.addMessage(dc, message);
106: }
107:
108: public Queue createQueue(ConnectionToken dc, String dest)
109: throws JMSException {
110: return nextInterceptor.createQueue(dc, dest);
111: }
112:
113: public Topic createTopic(ConnectionToken dc, String dest)
114: throws JMSException {
115: return nextInterceptor.createTopic(dc, dest);
116: }
117:
118: public void deleteTemporaryDestination(ConnectionToken dc,
119: SpyDestination dest) throws JMSException {
120: nextInterceptor.deleteTemporaryDestination(dc, dest);
121: }
122:
123: public void transact(ConnectionToken dc, TransactionRequest t)
124: throws JMSException {
125: nextInterceptor.transact(dc, t);
126: }
127:
128: public void acknowledge(ConnectionToken dc,
129: AcknowledgementRequest item) throws JMSException {
130: nextInterceptor.acknowledge(dc, item);
131: }
132:
133: public SpyMessage[] browse(ConnectionToken dc, Destination dest,
134: String selector) throws JMSException {
135: return nextInterceptor.browse(dc, dest, selector);
136: }
137:
138: public SpyMessage receive(ConnectionToken dc, int subscriberId,
139: long wait) throws JMSException {
140: return nextInterceptor.receive(dc, subscriberId, wait);
141: }
142:
143: public void setEnabled(ConnectionToken dc, boolean enabled)
144: throws JMSException {
145: nextInterceptor.setEnabled(dc, enabled);
146: }
147:
148: public void unsubscribe(ConnectionToken dc, int subscriptionId)
149: throws JMSException {
150: nextInterceptor.unsubscribe(dc, subscriptionId);
151: }
152:
153: public void destroySubscription(ConnectionToken dc,
154: DurableSubscriptionID id) throws JMSException {
155: nextInterceptor.destroySubscription(dc, id);
156: }
157:
158: public String checkUser(String userName, String password)
159: throws JMSException {
160: return nextInterceptor.checkUser(userName, password);
161: }
162:
163: public String authenticate(String userName, String password)
164: throws JMSException {
165: return nextInterceptor.authenticate(userName, password);
166: }
167:
168: public void subscribe(org.jboss.mq.ConnectionToken dc,
169: org.jboss.mq.Subscription s) throws JMSException {
170: nextInterceptor.subscribe(dc, s);
171: }
172:
173: public void ping(ConnectionToken dc, long clientTime)
174: throws JMSException {
175: nextInterceptor.ping(dc, clientTime);
176: }
177:
178: public SpyTopic getDurableTopic(DurableSubscriptionID sub)
179: throws JMSException {
180: return nextInterceptor.getDurableTopic(sub);
181: }
182:
183: public Subscription getSubscription(ConnectionToken dc,
184: int subscriberId) throws JMSException {
185: return nextInterceptor.getSubscription(dc, subscriberId);
186: }
187:
188: public Xid[] recover(ConnectionToken dc, int flags)
189: throws Exception {
190: JMSServerInterceptor next = nextInterceptor;
191: while (next != null && next instanceof Recoverable == false)
192: next = next.getNext();
193: if (next == null)
194: throw new IllegalStateException(
195: "No interceptor implements "
196: + Recoverable.class.getName());
197: Recoverable recoverable = (Recoverable) next;
198: return recoverable.recover(dc, flags);
199: }
200: }
|