KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > server > JMSServerInvoker


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq.server;
23
24 import javax.jms.Destination JavaDoc;
25 import javax.jms.JMSException JavaDoc;
26 import javax.jms.Queue JavaDoc;
27 import javax.jms.TemporaryQueue JavaDoc;
28 import javax.jms.TemporaryTopic JavaDoc;
29 import javax.jms.Topic JavaDoc;
30 import javax.transaction.xa.Xid JavaDoc;
31
32 import org.jboss.logging.Logger;
33 import org.jboss.mq.AcknowledgementRequest;
34 import org.jboss.mq.ConnectionToken;
35 import org.jboss.mq.DurableSubscriptionID;
36 import org.jboss.mq.Recoverable;
37 import org.jboss.mq.SpyDestination;
38 import org.jboss.mq.SpyMessage;
39 import org.jboss.mq.SpyTopic;
40 import org.jboss.mq.Subscription;
41 import org.jboss.mq.TransactionRequest;
42 import org.jboss.mq.il.Invoker;
43
44 /**
45  * A pass through JMSServerInvoker.
46  *
47  * @author <a HREF="mailto:pra@tim.se">Peter Antman</a>
48  * @author <a HREF="adrian@jboss.org">Adrian Brock</a>
49  * @version $Revision: 45317 $
50  */

51 public class JMSServerInvoker implements Invoker, Recoverable
52 {
53    protected Logger log;
54    /**
55     * Next invoker in chain.
56     */

57    protected JMSServerInterceptor nextInterceptor = null;
58
59    public JMSServerInvoker()
60    {
61       log = Logger.getLogger(this.getClass().getName());
62    }
63
64    /**
65     * Set next invoker in chain to be called. Is mot often the real JMSServer
66     */

67    public void setNext(JMSServerInterceptor server)
68    {
69       this.nextInterceptor = server;
70    }
71
72    /**
73     * @see JMSServerInterceptor#getNext()
74     */

75    public JMSServerInterceptor getNext()
76    {
77       return this.nextInterceptor;
78    }
79
80    public ThreadGroup JavaDoc getThreadGroup()
81    {
82       return nextInterceptor.getThreadGroup();
83    }
84
85    public String JavaDoc getID() throws JMSException JavaDoc
86    {
87       return nextInterceptor.getID();
88    }
89
90    public TemporaryTopic JavaDoc getTemporaryTopic(ConnectionToken dc) throws JMSException JavaDoc
91    {
92       return nextInterceptor.getTemporaryTopic(dc);
93    }
94
95    public TemporaryQueue JavaDoc getTemporaryQueue(ConnectionToken dc) throws JMSException JavaDoc
96    {
97       return nextInterceptor.getTemporaryQueue(dc);
98    }
99
100    public void connectionClosing(ConnectionToken dc) throws JMSException JavaDoc
101    {
102       nextInterceptor.connectionClosing(dc);
103    }
104
105    public void checkID(String JavaDoc ID) throws JMSException JavaDoc
106    {
107       nextInterceptor.checkID(ID);
108    }
109
110    public void addMessage(ConnectionToken dc, SpyMessage message) throws JMSException JavaDoc
111    {
112       nextInterceptor.addMessage(dc, message);
113    }
114
115    public Queue JavaDoc createQueue(ConnectionToken dc, String JavaDoc dest) throws JMSException JavaDoc
116    {
117       return nextInterceptor.createQueue(dc, dest);
118    }
119
120    public Topic JavaDoc createTopic(ConnectionToken dc, String JavaDoc dest) throws JMSException JavaDoc
121    {
122       return nextInterceptor.createTopic(dc, dest);
123    }
124
125    public void deleteTemporaryDestination(ConnectionToken dc, SpyDestination dest) throws JMSException JavaDoc
126    {
127       nextInterceptor.deleteTemporaryDestination(dc, dest);
128    }
129
130    public void transact(ConnectionToken dc, TransactionRequest t) throws JMSException JavaDoc
131    {
132       nextInterceptor.transact(dc, t);
133    }
134
135    public void acknowledge(ConnectionToken dc, AcknowledgementRequest item) throws JMSException JavaDoc
136    {
137       nextInterceptor.acknowledge(dc, item);
138    }
139
140    public SpyMessage[] browse(ConnectionToken dc, Destination JavaDoc dest, String JavaDoc selector) throws JMSException JavaDoc
141    {
142       return nextInterceptor.browse(dc, dest, selector);
143    }
144
145    public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait) throws JMSException JavaDoc
146    {
147       return nextInterceptor.receive(dc, subscriberId, wait);
148    }
149
150    public void setEnabled(ConnectionToken dc, boolean enabled) throws JMSException JavaDoc
151    {
152       nextInterceptor.setEnabled(dc, enabled);
153    }
154
155    public void unsubscribe(ConnectionToken dc, int subscriptionId) throws JMSException JavaDoc
156    {
157       nextInterceptor.unsubscribe(dc, subscriptionId);
158    }
159
160    public void destroySubscription(ConnectionToken dc, DurableSubscriptionID id) throws JMSException JavaDoc
161    {
162       nextInterceptor.destroySubscription(dc, id);
163    }
164
165    public String JavaDoc checkUser(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
166    {
167       return nextInterceptor.checkUser(userName, password);
168    }
169
170    public String JavaDoc authenticate(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
171    {
172       return nextInterceptor.authenticate(userName, password);
173    }
174
175    public void subscribe(org.jboss.mq.ConnectionToken dc, org.jboss.mq.Subscription s) throws JMSException JavaDoc
176    {
177       nextInterceptor.subscribe(dc, s);
178    }
179
180    public void ping(ConnectionToken dc, long clientTime) throws JMSException JavaDoc
181    {
182       nextInterceptor.ping(dc, clientTime);
183    }
184
185    public SpyTopic getDurableTopic(DurableSubscriptionID sub) throws JMSException JavaDoc
186    {
187       return nextInterceptor.getDurableTopic(sub);
188    }
189
190    public Subscription getSubscription(ConnectionToken dc, int subscriberId) throws JMSException JavaDoc
191    {
192       return nextInterceptor.getSubscription(dc, subscriberId);
193    }
194
195    public Xid JavaDoc[] recover(ConnectionToken dc, int flags) throws Exception JavaDoc
196    {
197       JMSServerInterceptor next = nextInterceptor;
198       while (next != null && next instanceof Recoverable == false)
199          next = next.getNext();
200       if (next == null)
201          throw new IllegalStateException JavaDoc("No interceptor implements " + Recoverable.class.getName());
202       Recoverable recoverable = (Recoverable) next;
203       return recoverable.recover(dc, flags);
204    }
205 }
206
Popular Tags