Source Code Cross Referenced for JMSTest.java in  » J2EE » enhydra » samples » jms » 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 » J2EE » enhydra » samples.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001, 2002,2004 The Apache Software Foundation.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package samples.jms;
018:
019:        import org.apache.axis.AxisFault;
020:        import org.apache.axis.client.Call;
021:        import org.apache.axis.client.Service;
022:        import org.apache.axis.configuration.XMLStringProvider;
023:        import org.apache.axis.deployment.wsdd.WSDDConstants;
024:        import org.apache.axis.encoding.XMLType;
025:        import org.apache.axis.transport.jms.JMSConstants;
026:        import org.apache.axis.transport.jms.JMSTransport;
027:        import org.apache.axis.transport.jms.SimpleJMSListener;
028:        import org.apache.axis.utils.Options;
029:
030:        import javax.xml.namespace.QName;
031:        import javax.xml.rpc.ParameterMode;
032:        import java.util.HashMap;
033:
034:        /** Tests the JMS transport.  To run:
035:         *      java org.apache.axis.utils.Admin client client_deploy.xml
036:         *      java org.apache.axis.utils.Admin server deploy.xml
037:         *      java samples.transport.FileTest IBM
038:         *      java samples.transport.FileTest XXX
039:         *
040:         * JMSTest is a simple test driver for the JMS transport. It sets up a
041:         *   JMS listener, then calls a delayed quote service for each of the symbols
042:         *   specified on the command line.
043:         *
044:         * @author Jaime Meritt  (jmeritt@sonicsoftware.com)
045:         * @author Richard Chung (rchung@sonicsoftware.com)
046:         * @author Dave Chappell (chappell@sonicsoftware.com)
047:         */
048:
049:        public class JMSTest {
050:            static final String wsdd = "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" "
051:                    + "xmlns:java=\""
052:                    + WSDDConstants.URI_WSDD_JAVA
053:                    + "\">\n"
054:                    + " <transport name=\"JMSTransport\" pivot=\"java:org.apache.axis.transport.jms.JMSSender\"/>\n"
055:                    + " <service name=\""
056:                    + WSDDConstants.URI_WSDD
057:                    + "\" provider=\"java:MSG\">\n"
058:                    + "  <parameter name=\"allowedMethods\" value=\"AdminService\"/>\n"
059:                    + "  <parameter name=\"className\" value=\"org.apache.axis.utils.Admin\"/>\n"
060:                    + " </service>\n" + "</deployment>";
061:
062:            public static void main(String args[]) throws Exception {
063:                Options opts = new Options(args);
064:
065:                // first check if we should print usage
066:                if ((opts.isFlagSet('?') > 0) || (opts.isFlagSet('h') > 0))
067:                    printUsage();
068:
069:                HashMap connectorMap = SimpleJMSListener
070:                        .createConnectorMap(opts);
071:                HashMap cfMap = SimpleJMSListener.createCFMap(opts);
072:                String destination = opts.isValueSet('d');
073:                String username = opts.getUser();
074:                String password = opts.getPassword();
075:                // create the jms listener
076:                SimpleJMSListener listener = new SimpleJMSListener(
077:                        connectorMap, cfMap, destination, username, password,
078:                        false);
079:                listener.start();
080:
081:                args = opts.getRemainingArgs();
082:                if (args == null || args.length == 0)
083:                    printUsage();
084:
085:                Service service = new Service(new XMLStringProvider(wsdd));
086:
087:                // create the transport
088:                JMSTransport transport = new JMSTransport(connectorMap, cfMap);
089:
090:                // create a new Call object
091:                Call call = (Call) service.createCall();
092:
093:                call.setOperationName(new QName("urn:xmltoday-delayed-quotes",
094:                        "getQuote"));
095:                call.addParameter("symbol", XMLType.XSD_STRING,
096:                        ParameterMode.IN);
097:                call.setReturnType(XMLType.XSD_FLOAT);
098:                call.setTransport(transport);
099:
100:                // set additional params on the call if desired
101:                //call.setUsername(username );
102:                //call.setPassword(password );
103:                //call.setProperty(JMSConstants.WAIT_FOR_RESPONSE, Boolean.FALSE);
104:                //call.setProperty(JMSConstants.PRIORITY, new Integer(5));
105:                //call.setProperty(JMSConstants.DELIVERY_MODE,
106:                //    new Integer(javax.jms.DeliveryMode.PERSISTENT));
107:                //call.setProperty(JMSConstants.TIME_TO_LIVE, new Long(20000));
108:
109:                call.setProperty(JMSConstants.DESTINATION, destination);
110:                call.setTimeout(new Integer(10000));
111:
112:                Float res = new Float(0.0F);
113:
114:                // invoke a call for each of the symbols and print out
115:                for (int i = 0; i < args.length; i++) {
116:                    try {
117:                        res = (Float) call.invoke(new Object[] { args[i] });
118:                        System.out.println(args[i] + ": " + res);
119:                    } catch (AxisFault af) {
120:                        System.out.println(af.dumpToString());
121:                    }
122:                }
123:
124:                // shutdown
125:                listener.shutdown();
126:                transport.shutdown();
127:            }
128:
129:            public static void printUsage() {
130:                System.out
131:                        .println("JMSTest: Tests JMS transport by obtaining stock quote");
132:                System.out
133:                        .println("  Usage: JMSTest <symbol 1> <symbol 2> <symbol 3> ...");
134:                System.out.println("   Opts: -? this message");
135:                System.out.println();
136:                System.out
137:                        .println("       -c connection factory properties filename");
138:                System.out.println("       -d destination");
139:                System.out
140:                        .println("       -t topic [absence of -t indicates queue]");
141:                System.out.println();
142:                System.out.println("       -u username");
143:                System.out.println("       -w password");
144:                System.out.println();
145:                System.out.println("       -s single-threaded listener");
146:                System.out
147:                        .println("          [absence of option => multithreaded]");
148:
149:                System.exit(1);
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.