Source Code Cross Referenced for HTTPServerIL.java in  » EJB-Server-JBoss-4.2.1 » messaging » org » jboss » mq » il » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » messaging » org.jboss.mq.il.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.il.http;
023:
024:        import java.io.Serializable;
025:        import java.net.URL;
026:
027:        import javax.jms.Destination;
028:        import javax.jms.Queue;
029:        import javax.jms.TemporaryQueue;
030:        import javax.jms.TemporaryTopic;
031:        import javax.jms.Topic;
032:        import javax.transaction.xa.Xid;
033:
034:        import org.jboss.logging.Logger;
035:        import org.jboss.mq.AcknowledgementRequest;
036:        import org.jboss.mq.ConnectionToken;
037:        import org.jboss.mq.DurableSubscriptionID;
038:        import org.jboss.mq.Recoverable;
039:        import org.jboss.mq.SpyDestination;
040:        import org.jboss.mq.SpyMessage;
041:        import org.jboss.mq.Subscription;
042:        import org.jboss.mq.TransactionRequest;
043:        import org.jboss.mq.il.ServerIL;
044:
045:        /**
046:         * Client proxy to the server.  For each request, an HTTP or HTTPS
047:         * request is created, and posted to the given URL.  The URL is supplied
048:         * in the HTTPServerILService MBean configuration, or automatically generated
049:         * by as localhost here, but can be overridden on the client side by specifying
050:         * a property name for the URL value, which will be resolved to a system property
051:         * on the client side.
052:         *
053:         * @author    Nathan Phelps (nathan@jboss.org)
054:         * @version   $Revision: 57198 $
055:         * @created   January 15, 2003
056:         */
057:        public class HTTPServerIL implements  Serializable, ServerIL,
058:                Recoverable {
059:            static final long serialVersionUID = -864073076154976490L;
060:
061:            private static Logger log = Logger.getLogger(HTTPClient.class);
062:
063:            private String serverUrlValue = null;
064:            private URL serverUrl = null;
065:
066:            public HTTPServerIL(String url) throws Exception {
067:                if (log.isTraceEnabled()) {
068:                    log.trace("created(String " + url + ")");
069:                }
070:                this .serverUrlValue = url;
071:            }
072:
073:            public void acknowledge(ConnectionToken dc,
074:                    AcknowledgementRequest item) throws Exception {
075:                if (log.isTraceEnabled()) {
076:                    log.trace("acknowledge(ConnectionToken " + dc.toString()
077:                            + ", AcknowledgementRequest " + item.toString()
078:                            + ")");
079:                }
080:                HTTPILRequest request = new HTTPILRequest();
081:                request.setMethodName("acknowledge");
082:                request.setArguments(new Object[] { dc, item }, new Class[] {
083:                        ConnectionToken.class, AcknowledgementRequest.class });
084:                this .postRequest(request);
085:            }
086:
087:            public void addMessage(ConnectionToken dc, SpyMessage message)
088:                    throws Exception {
089:                if (log.isTraceEnabled()) {
090:                    log.trace("addMessage(ConnectionToken " + dc.toString()
091:                            + ", SpyMessage " + message.toString() + ")");
092:                }
093:                HTTPILRequest request = new HTTPILRequest();
094:                request.setMethodName("addMessage");
095:                request.setArguments(new Object[] { dc, message }, new Class[] {
096:                        ConnectionToken.class, SpyMessage.class });
097:                this .postRequest(request);
098:            }
099:
100:            public String authenticate(String userName, String password)
101:                    throws Exception {
102:                if (log.isTraceEnabled()) {
103:                    log.trace("authenticate(String " + userName + ", String "
104:                            + password + ")");
105:                }
106:                HTTPILRequest request = new HTTPILRequest();
107:                request.setMethodName("authenticate");
108:                request.setArguments(new Object[] { userName, password },
109:                        new Class[] { String.class, String.class });
110:                return (String) this .postRequest(request);
111:            }
112:
113:            public SpyMessage[] browse(ConnectionToken dc, Destination dest,
114:                    String selector) throws Exception {
115:                if (log.isTraceEnabled()) {
116:                    log.trace("browse(ConnectionToken " + dc.toString()
117:                            + ", Destination " + dest.toString() + ", String "
118:                            + selector + ")");
119:                }
120:                HTTPILRequest request = new HTTPILRequest();
121:                request.setMethodName("browse");
122:                request.setArguments(new Object[] { dc, dest, selector },
123:                        new Class[] { ConnectionToken.class, Destination.class,
124:                                String.class });
125:                return (SpyMessage[]) this .postRequest(request);
126:            }
127:
128:            public void checkID(String ID) throws Exception {
129:                if (log.isTraceEnabled()) {
130:                    log.trace("checkID(String " + ID + ")");
131:                }
132:                HTTPILRequest request = new HTTPILRequest();
133:                request.setMethodName("checkID");
134:                request.setArguments(new Object[] { ID },
135:                        new Class[] { String.class });
136:                this .postRequest(request);
137:            }
138:
139:            public String checkUser(String userName, String password)
140:                    throws Exception {
141:                if (log.isTraceEnabled()) {
142:                    log.trace("checkUser(String " + userName + ", String "
143:                            + password + ")");
144:                }
145:                HTTPILRequest request = new HTTPILRequest();
146:                request.setMethodName("checkUser");
147:                request.setArguments(new Object[] { userName, password },
148:                        new Class[] { String.class, String.class });
149:                return (String) this .postRequest(request);
150:            }
151:
152:            public ServerIL cloneServerIL() throws Exception {
153:                if (log.isTraceEnabled()) {
154:                    log.trace("cloneServerIL()");
155:                }
156:                return this ; // We can return this becuase we're stateless
157:            }
158:
159:            public void connectionClosing(ConnectionToken dc) throws Exception {
160:                if (log.isTraceEnabled()) {
161:                    log.trace("connectionClosing(ConnectionToken "
162:                            + dc.toString() + ")");
163:                }
164:                HTTPILRequest request = new HTTPILRequest();
165:                request.setMethodName("connectionClosing");
166:                request.setArguments(new Object[] { dc },
167:                        new Class[] { ConnectionToken.class });
168:                this .postRequest(request);
169:            }
170:
171:            public Queue createQueue(ConnectionToken dc, String dest)
172:                    throws Exception {
173:                if (log.isTraceEnabled()) {
174:                    log.trace("createQueue(ConnectionToken " + dc.toString()
175:                            + ", String " + dest.toString() + ")");
176:                }
177:                HTTPILRequest request = new HTTPILRequest();
178:                request.setMethodName("createQueue");
179:                request.setArguments(new Object[] { dc, dest }, new Class[] {
180:                        ConnectionToken.class, String.class });
181:                return (Queue) this .postRequest(request);
182:            }
183:
184:            public Topic createTopic(ConnectionToken dc, String dest)
185:                    throws Exception {
186:                if (log.isTraceEnabled()) {
187:                    log.trace("createTopic(ConnectionToken " + dc.toString()
188:                            + ", String " + dest.toString() + ")");
189:                }
190:                HTTPILRequest request = new HTTPILRequest();
191:                request.setMethodName("createTopic");
192:                request.setArguments(new Object[] { dc, dest }, new Class[] {
193:                        ConnectionToken.class, String.class });
194:                return (Topic) this .postRequest(request);
195:            }
196:
197:            public void deleteTemporaryDestination(ConnectionToken dc,
198:                    SpyDestination dest) throws Exception {
199:                if (log.isTraceEnabled()) {
200:                    log.trace("deleteTemporaryDestination(ConnectionToken "
201:                            + dc.toString() + ", SpyDestination "
202:                            + dest.toString() + ")");
203:                }
204:                HTTPILRequest request = new HTTPILRequest();
205:                request.setMethodName("deleteTemporaryDestination");
206:                request.setArguments(new Object[] { dc, dest }, new Class[] {
207:                        ConnectionToken.class, SpyDestination.class });
208:                this .postRequest(request);
209:            }
210:
211:            public void destroySubscription(ConnectionToken dc,
212:                    DurableSubscriptionID id) throws Exception {
213:                if (log.isTraceEnabled()) {
214:                    log.trace("destroySubscription(ConnectionToken "
215:                            + dc.toString() + ", DurableSubscriptionID "
216:                            + id.toString() + ")");
217:                }
218:                HTTPILRequest request = new HTTPILRequest();
219:                request.setMethodName("destroySubscription");
220:                request.setArguments(new Object[] { dc, id }, new Class[] {
221:                        ConnectionToken.class, DurableSubscriptionID.class });
222:                this .postRequest(request);
223:            }
224:
225:            public String getID() throws Exception {
226:                if (log.isTraceEnabled()) {
227:                    log.trace("getID()");
228:                }
229:                HTTPILRequest request = new HTTPILRequest();
230:                request.setMethodName("getID");
231:                return (String) this .postRequest(request);
232:            }
233:
234:            public TemporaryQueue getTemporaryQueue(ConnectionToken dc)
235:                    throws Exception {
236:                if (log.isTraceEnabled()) {
237:                    log.trace("getTemporaryQueue(ConnectionToken "
238:                            + dc.toString() + ")");
239:                }
240:                HTTPILRequest request = new HTTPILRequest();
241:                request.setMethodName("getTemporaryQueue");
242:                request.setArguments(new Object[] { dc },
243:                        new Class[] { ConnectionToken.class });
244:                return (TemporaryQueue) this .postRequest(request);
245:            }
246:
247:            public TemporaryTopic getTemporaryTopic(ConnectionToken dc)
248:                    throws Exception {
249:                if (log.isTraceEnabled()) {
250:                    log.trace("getTemporaryTopic(ConnectionToken "
251:                            + dc.toString() + ")");
252:                }
253:                HTTPILRequest request = new HTTPILRequest();
254:                request.setMethodName("getTemporaryTopic");
255:                request.setArguments(new Object[] { dc },
256:                        new Class[] { ConnectionToken.class });
257:                return (TemporaryTopic) this .postRequest(request);
258:            }
259:
260:            public void ping(ConnectionToken dc, long clientTime)
261:                    throws Exception {
262:                // This is never called because we don't do pings.  It is here for completeness.
263:                if (log.isTraceEnabled()) {
264:                    log.trace("ping(ConnectionToken " + dc.toString()
265:                            + ", long " + String.valueOf(clientTime) + ")");
266:                }
267:                HTTPILRequest request = new HTTPILRequest();
268:                request.setMethodName("ping");
269:                request.setArguments(new Object[] { dc, new Long(clientTime) },
270:                        new Class[] { ConnectionToken.class, Long.class });
271:                this .postRequest(request);
272:            }
273:
274:            public SpyMessage receive(ConnectionToken dc, int subscriberId,
275:                    long wait) throws Exception {
276:                if (log.isTraceEnabled()) {
277:                    log.trace("receive(ConnectionToken " + dc.toString()
278:                            + ", int " + String.valueOf(subscriberId)
279:                            + ", long " + String.valueOf(wait) + ")");
280:                }
281:                HTTPILRequest request = new HTTPILRequest();
282:                request.setMethodName("receive");
283:                request.setArguments(new Object[] { dc,
284:                        new Integer(subscriberId), new Long(wait) },
285:                        new Class[] { ConnectionToken.class, Integer.class,
286:                                Long.class });
287:                return (SpyMessage) this .postRequest(request);
288:            }
289:
290:            public void setConnectionToken(ConnectionToken newConnectionToken)
291:                    throws Exception {
292:                // Since we're stateless, we don't cache the ConnectionToken.
293:            }
294:
295:            public void setEnabled(ConnectionToken dc, boolean enabled)
296:                    throws Exception {
297:                if (log.isTraceEnabled()) {
298:                    log.trace("setEnabled(ConnectionToken " + dc.toString()
299:                            + ", boolean " + String.valueOf(enabled) + ")");
300:                }
301:                HTTPILRequest request = new HTTPILRequest();
302:                request.setMethodName("setEnabled");
303:                request.setArguments(new Object[] { dc, new Boolean(enabled) },
304:                        new Class[] { ConnectionToken.class, Boolean.class });
305:                this .postRequest(request);
306:            }
307:
308:            public void subscribe(ConnectionToken dc, Subscription s)
309:                    throws Exception {
310:                if (log.isTraceEnabled()) {
311:                    log.trace("subscribe(ConnectionToken " + dc.toString()
312:                            + ", Subscription " + s.toString() + ")");
313:                }
314:                HTTPILRequest request = new HTTPILRequest();
315:                request.setMethodName("subscribe");
316:                request.setArguments(new Object[] { dc, s }, new Class[] {
317:                        ConnectionToken.class, Subscription.class });
318:                this .postRequest(request);
319:            }
320:
321:            public void transact(ConnectionToken dc, TransactionRequest t)
322:                    throws Exception {
323:                if (log.isTraceEnabled()) {
324:                    log.trace("transact(ConnectionToken " + dc.toString()
325:                            + ", TransactionRequest " + t.toString() + ")");
326:                }
327:                HTTPILRequest request = new HTTPILRequest();
328:                request.setMethodName("transact");
329:                request.setArguments(new Object[] { dc, t }, new Class[] {
330:                        ConnectionToken.class, TransactionRequest.class });
331:                this .postRequest(request);
332:            }
333:
334:            public Xid[] recover(ConnectionToken dc, int flags)
335:                    throws Exception {
336:                if (log.isTraceEnabled())
337:                    log.trace("recover(ConnectionToken " + dc + ", flags="
338:                            + flags + ")");
339:                HTTPILRequest request = new HTTPILRequest();
340:                request.setMethodName("recover");
341:                request.setArguments(new Object[] { dc, new Integer(flags) },
342:                        new Class[] { ConnectionToken.class, Integer.class });
343:                return (Xid[]) this .postRequest(request);
344:            }
345:
346:            public void unsubscribe(ConnectionToken dc, int subscriptionId)
347:                    throws Exception {
348:                if (log.isTraceEnabled()) {
349:                    log.trace("unsubscribe(ConnectionToken " + dc.toString()
350:                            + ", int " + String.valueOf(subscriptionId) + ")");
351:                }
352:                HTTPILRequest request = new HTTPILRequest();
353:                request.setMethodName("unsubscribe");
354:                request.setArguments(new Object[] { dc,
355:                        new Integer(subscriptionId) }, new Class[] {
356:                        ConnectionToken.class, Integer.class });
357:                this .postRequest(request);
358:            }
359:
360:            private Object postRequest(HTTPILRequest request) throws Exception {
361:                if (log.isTraceEnabled()) {
362:                    log.trace("postRequest(HTTPILRequest " + request.toString()
363:                            + ")");
364:                }
365:                if (this.serverUrl == null) {
366:                    this.serverUrl = HTTPClient
367:                            .resolveServerUrl(this.serverUrlValue);
368:                }
369:                return HTTPClient.post(this.serverUrl, request);
370:            }
371:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.