KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > il > jvm > JVMServerIL


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.il.jvm;
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.mq.AcknowledgementRequest;
33 import org.jboss.mq.ConnectionToken;
34 import org.jboss.mq.DurableSubscriptionID;
35 import org.jboss.mq.Recoverable;
36 import org.jboss.mq.SpyDestination;
37 import org.jboss.mq.SpyMessage;
38 import org.jboss.mq.TransactionRequest;
39 import org.jboss.mq.il.Invoker;
40 import org.jboss.mq.il.ServerIL;
41
42 /**
43  * The JVM implementation of the ServerIL object
44  *
45  * @author Hiram Chirino (Cojonudo14@hotmail.com)
46  * @author Norbert Lataille (Norbert.Lataille@m4x.org)
47  * @author <a HREF="pra@tim.se">Peter Antman</a>
48  * @author <a HREF="adrian@jboss.org">Adrian Brock</a>
49  * @version $Revision: 45317 $
50  * @created August 16, 2001
51  */

52 public class JVMServerIL implements ServerIL, Recoverable
53 {
54    //The server implementation
55
private final Invoker server;
56
57    /**
58     * Constructor for the JVMServerIL object
59     *
60     * @param s Description of Parameter
61     */

62    public JVMServerIL(Invoker s)
63    {
64       if (s == null)
65          throw new IllegalArgumentException JavaDoc("JMSServer must be non null in constructor");
66       server = s;
67    }
68
69    public void setConnectionToken(ConnectionToken newConnectionToken)
70    {
71       // We cannot try to cache the token since this IL is stateless
72
}
73
74    public void setEnabled(ConnectionToken dc, boolean enabled) throws Exception JavaDoc
75    {
76       server.setEnabled(dc, enabled);
77    }
78
79    public String JavaDoc getID() throws JMSException JavaDoc
80    {
81       return server.getID();
82    }
83
84    public TemporaryQueue JavaDoc getTemporaryQueue(ConnectionToken dc) throws JMSException JavaDoc
85    {
86       return server.getTemporaryQueue(dc);
87    }
88
89    public TemporaryTopic JavaDoc getTemporaryTopic(ConnectionToken dc) throws JMSException JavaDoc
90    {
91       return server.getTemporaryTopic(dc);
92    }
93
94    public ServerIL cloneServerIL()
95    {
96       return this;
97    }
98
99    public void addMessage(ConnectionToken dc, SpyMessage val) throws JMSException JavaDoc
100    {
101       server.addMessage(dc, val.myClone());
102    }
103
104    public Topic JavaDoc createTopic(ConnectionToken dc, String JavaDoc dest) throws JMSException JavaDoc
105    {
106       return server.createTopic(dc, dest);
107    }
108
109    public Queue JavaDoc createQueue(ConnectionToken dc, String JavaDoc dest) throws JMSException JavaDoc
110    {
111       return server.createQueue(dc, dest);
112    }
113
114    public void deleteTemporaryDestination(ConnectionToken dc, SpyDestination dest) throws JMSException JavaDoc
115    {
116       server.deleteTemporaryDestination(dc, dest);
117    }
118
119    public void checkID(String JavaDoc ID) throws JMSException JavaDoc
120    {
121       server.checkID(ID);
122    }
123
124    public void connectionClosing(ConnectionToken dc) throws JMSException JavaDoc
125    {
126       server.connectionClosing(dc);
127    }
128
129    public void acknowledge(ConnectionToken dc, AcknowledgementRequest item) throws Exception JavaDoc
130    {
131       server.acknowledge(dc, item);
132    }
133
134    public SpyMessage[] browse(ConnectionToken dc, Destination JavaDoc dest, String JavaDoc selector) throws Exception JavaDoc
135    {
136       return server.browse(dc, dest, selector);
137    }
138
139    public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait) throws Exception JavaDoc
140    {
141       SpyMessage message = server.receive(dc, subscriberId, wait);
142       //copy message to avoid server side problems with persisted message if message is edited client side.
143
if (message != null)
144          message = message.myClone();
145       return message;
146    }
147
148    public void unsubscribe(ConnectionToken dc, int subscriptionId) throws Exception JavaDoc
149    {
150       server.unsubscribe(dc, subscriptionId);
151    }
152
153    public void destroySubscription(ConnectionToken dc, DurableSubscriptionID id) throws Exception JavaDoc
154    {
155       server.destroySubscription(dc, id);
156    }
157
158    public String JavaDoc checkUser(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
159    {
160       return server.checkUser(userName, password);
161    }
162
163    public String JavaDoc authenticate(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
164    {
165       return server.authenticate(userName, password);
166    }
167
168    public void subscribe(ConnectionToken dc, org.jboss.mq.Subscription s) throws Exception JavaDoc
169    {
170       server.subscribe(dc, s.myClone());
171    }
172
173    public void transact(org.jboss.mq.ConnectionToken dc, TransactionRequest t) throws JMSException JavaDoc
174    {
175       server.transact(dc, t);
176    }
177
178    public void ping(org.jboss.mq.ConnectionToken dc, long clientTime) throws JMSException JavaDoc
179    {
180       server.ping(dc, clientTime);
181    }
182
183    public Xid JavaDoc[] recover(ConnectionToken dc, int flags) throws Exception JavaDoc
184    {
185       if (server instanceof Recoverable)
186       {
187          Recoverable recoverable = (Recoverable) server;
188          return recoverable.recover(dc, flags);
189       }
190       throw new IllegalStateException JavaDoc("Invoker does not implement recoverable " + server);
191    }
192 }
193
Popular Tags