1 /*
2 * @(#)RMILinkServer.java
3 *
4 * JFoxMQ the open source JMS MOM.
5 *
6 * Corpyright 2002-2003 Huihoo Power, Inc. All Rights Reserved. This software
7 * is licensed under LGPL license.
8 *
9 * For more information, please visit: http://www.huihoo.org
10 */
11
12 package org.huihoo.jfox.ms.crb.rmi;
13
14 import javax.jms.Destination;
15 import javax.jms.JMSException;
16 import javax.jms.Message;
17 import javax.jms.Queue;
18 import javax.jms.TemporaryQueue;
19 import javax.jms.TemporaryTopic;
20 import javax.jms.Topic;
21 import javax.naming.Context;
22 import javax.naming.InitialContext;
23
24 import org.huihoo.jfox.jndi.JNDIProperties;
25 import org.huihoo.jfox.ms.crb.GenConnectionFactoryImpl;
26 import org.huihoo.jfox.ms.crb.Interceptor;
27 import org.huihoo.jfox.ms.crb.LinkServer;
28
29 /***
30 * Defines the methods that can be called by a client on the server.
31 *
32 * @author Liang.Zhao (zlushangnwpu@sina.com)
33 * @version
34 * @created July 23th 2003
35 */
36
37 public class RMILinkServer extends java.rmi.server.UnicastRemoteObject implements LinkServerRemote {
38
39 private Interceptor firstInterceptor;
40
41 /***
42 * Constructor for the RMILinkServer object
43 *
44 * @param Interceptor s
45 */
46 public RMILinkServer(Interceptor s, int RMIPort) throws java.rmi.RemoteException {
47 super(RMIPort);
48 firstInterceptor = s;
49 }
50
51
52 /***
53 * @return LinkServer
54 * @exception Exception
55 */
56 public LinkServer cloneLinkServer() throws Exception {
57 return (LinkServer) this;
58 }
59
60 /***
61 * Get a clientID from the server.
62 * @return String an internally generated clientID
63 * @exception Exception
64 */
65 public String getID() throws Exception {
66 return firstInterceptor.getID();
67 }
68
69 /***
70 * Gets the TemporaryTopic
71 *
72 * @param
73 * @return TemporaryTopic
74 * @exception Exception
75 */
76 public TemporaryTopic createTemporaryTopic() throws Exception {
77 return firstInterceptor.createTemporaryTopic();
78 }
79
80 /***
81 * Gets the TemporaryQueue
82 *
83 * @param
84 * @return TemporaryQueue
85 * @exception Exception
86 */
87 public TemporaryQueue createTemporaryQueue() throws Exception {
88 return firstInterceptor.createTemporaryQueue();
89 }
90
91 /***
92 * not finished
93 * @exception JMSException Description of Exception
94 */
95 public void closeConnection()
96 throws JMSException {
97 //firstInterceptor.closeConnection();
98 }
99
100
101 /***
102 * Check if clientID is a valid ID
103 * @param String ID
104 * @exception Exception
105 */
106 public void checkID(String ID) throws Exception {
107 firstInterceptor.checkID(ID);
108 }
109
110 /***
111 * Send a message to the destination specifyed in the message.
112 * @param Message
113 * @exception Exception
114 */
115 public void sendMessage(Message message) throws Exception {
116 firstInterceptor.sendMessage(message);
117 }
118
119 /***
120 *Create a queue identity
121 *
122 * @param String destination
123 * @return Queue
124 * @exception Exception
125 */
126 public Queue createQueue(String destination) throws Exception {
127 return firstInterceptor.createQueue(destination);
128 }
129
130 /***
131 *Create a topic identity
132 *
133 * @param destination
134 * @return Topic
135 * @exception Exception
136 */
137 public Topic createTopic(String destination) throws Exception {
138 return firstInterceptor.createTopic(destination);
139 }
140
141 /***
142 *Delete a temporary destination from server
143 *
144 * @param Destination destination
145 * @exception Exception
146 */
147 public void deleteTemporaryDestination(Destination destination) throws Exception {
148 firstInterceptor.deleteTemporaryDestination(destination);
149 }
150
151 /***
152 *Commit a transaction
153 *
154 * @param TransactionRequest t
155 * @exception Exception
156 */
157 //public void commitTransaction(TransactionRequest t)throws Exception
158 //{
159 //firstInterceptor.commitTransaction(t);
160 // return null;
161 // }
162
163 /***
164 * Send a acknowledge to server
165 *
166 * @param AcknowledgementRequest ack
167 * @exception Exception
168 */
169 //public void sendAcknowledge(AcknowledgementRequest ack)throws Exception
170 //{
171 // firstInterceptor.sendAcknowledge(ack);
172 //}
173
174 /***
175 * Browse message on given destination
176 *
177 * @param Destination destination
178 * @param String selector
179 * @return Message[]
180 * @exception Exception
181 */
182 public Message[] browse(Destination destination, String selector) throws Exception {
183 return firstInterceptor.browse(destination, selector);
184 }
185
186 /***
187 * Receive a message synchronously.
188 *
189 * @param Destination destination
190 * @param long wait
191 * @return Message
192 * @exception Exception
193 */
194 public Message receiveMessage(Destination destination, long wait) throws Exception {
195 return firstInterceptor.receiveMessage(destination, wait);
196 }
197
198
199 /***
200 * Remove a subcriber.
201 *
202 * @param
203 * @exception Exception Description of Exception
204 */
205 public void removeSubscriber() throws Exception {
206 firstInterceptor.removeSubscriber();
207 }
208
209 /***
210 * Authenticate the user.
211 *
212 * @param String userName
213 * @param String password
214 * @return boolean
215 * @exception Exception
216 */
217 public boolean authenticate(String userName, String password) throws Exception {
218 return firstInterceptor.authenticate(userName, password);
219 }
220
221 /***
222 * @param Subscription s
223 * @exception java.lang.Exception The exception description.
224 */
225 //void addSubscriber(Subscription s)throws java.lang.Exception
226 //{
227 // firstInterceptor.getID(s);
228 // }
229
230 /***
231 * only for test
232 *
233 */
234
235 public static void main(String[] args) {
236 try {
237 GenConnectionFactoryImpl gcf = null;
238 System.setProperty("java.naming.factory.initial", JNDIProperties.INITIAL_CONTEXT_FACTORY);
239 System.setProperty("java.naming.factory.url.pkgs", "org.huihoo.jfox.jndi");
240 System.setProperty("java.naming.provider.url", JNDIProperties.PROVIDER_URL);
241
242
243 // Get an InitialContext
244 Context ctx = new InitialContext();
245
246 Object ref = ctx.lookup("ConnectionFactory");
247 gcf = (GenConnectionFactoryImpl) javax.rmi.PortableRemoteObject.narrow(ref, GenConnectionFactoryImpl.class);
248
249 LinkServer link = gcf.getLinkServer();
250 String s = link.getID();
251 if (s != null) System.out.print(s);
252 } catch (Exception e) {
253 System.out.println(e.toString());
254 }
255
256
257 }
258
259 }
This page was automatically generated by Maven