Source Code Cross Referenced for BlackboardCountClient.java in  » Science » Cougaar12_4 » org » cougaar » lib » web » axis » blackboardCount » 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 » Science » Cougaar12_4 » org.cougaar.lib.web.axis.blackboardCount 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         *
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         *
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.lib.web.axis.blackboardCount;
028:
029:        import java.net.URL;
030:        import java.util.Iterator;
031:        import java.util.Map;
032:
033:        import javax.xml.namespace.QName;
034:        import javax.xml.rpc.ParameterMode;
035:
036:        import org.apache.axis.AxisFault;
037:        import org.apache.axis.client.Call;
038:        import org.apache.axis.client.Service;
039:        import org.apache.axis.encoding.XMLType;
040:        import org.apache.axis.utils.Options;
041:        import org.apache.axis.encoding.ser.BeanDeserializerFactory;
042:        import org.apache.axis.encoding.ser.BeanSerializerFactory;
043:
044:        /**
045:         * A command-line client that uses SOAP to ask Cougaar for a count of
046:         * all objects on a node-agent's blackboard.
047:         * <p>
048:         * To run on Windows:<pre>
049:         *   SET CP=-classpath %CIP%\lib\webaxis.jar;%CIP%\sys\axis_1_2_beta.jar;%CIP%\sys\mail.jar;%CIP%\sys\activation.jar
050:         *   SET CL=org.cougaar.lib.web.axis.blackboardCount.BlackboardCountClient
051:         *   SET URL=-lhttp://localhost:8800/axis/services
052:         *   java -classpath %CP% %CL% %URL% %*
053:         * </pre>
054:         * or on Linux/Unix Bash:<pre>
055:         *   CP="$CIP/lib/webaxis.jar:$CIP/sys/axis_1_2_beta.jar:$CIP/sys/activation.jar:$CIP/sys/mail.jar"
056:         *   CL="org.cougaar.lib.web.axis.blackboardCount.BlackboardCountClient"
057:         *   URL="-lhttp://localhost:8800/axis/services"
058:         *   java -classpath $CP $CL $URL $*
059:         * </pre>
060:         * <p>
061:         * The expected output is:<pre>
062:         *  getBlackboardCount(*)={
063:         *    org.cougaar.lib.web.axis.blackboardCount.BlackboardCountPlugin$TestOne=1,
064:         *    org.cougaar.lib.web.axis.blackboardCount.BlackboardCountPlugin$TestTwo=2,
065:         *  }
066:         * </pre>
067:         * <p>
068:         * Most of this is Axis/SOAP boilerplate, based on the Axis sample code:<pre>
069:         *   $AXIS_HOME/samples/stock/GetQuote.java
070:         * </pre>
071:         */
072:        public class BlackboardCountClient {
073:
074:            public static void main(String args[]) throws Exception {
075:                // parse options
076:                Options opts = new Options(args);
077:                String[] extraArgs = opts.getRemainingArgs();
078:                String surl = opts.getURL();
079:                String classFilter = (extraArgs == null
080:                        || extraArgs.length <= 0 ? "*" : extraArgs[0]);
081:
082:                // invoke
083:                Map m = BlackboardCountClient.getBlackboardCount(surl,
084:                        classFilter);
085:
086:                // print result
087:                System.out.print("getBlackboardCount(" + classFilter + ")={");
088:                for (Iterator iter = m.entrySet().iterator(); iter.hasNext();) {
089:                    Map.Entry me = (Map.Entry) iter.next();
090:                    System.out.println("  " + me.getKey() + "=" + me.getValue()
091:                            + ",");
092:                }
093:                System.out.println("}");
094:            }
095:
096:            // helper function; does all the real work
097:            //
098:            // see the Axis samples for more examples; this one is based on
099:            //   $AXIS_HOME/samples/stock/GetQuote.java 
100:            private static Map getBlackboardCount(String surl,
101:                    String classFilter) throws Exception {
102:
103:                URL url = new URL(surl);
104:
105:                Service service = new Service();
106:
107:                Call call = (Call) service.createCall();
108:
109:                // register types:
110:                Class cl = ResultEntry.class;
111:                QName qn = new QName("urn:BeanService", "ResultEntry");
112:                call.registerTypeMapping(cl, qn, new BeanSerializerFactory(cl,
113:                        qn), new BeanDeserializerFactory(cl, qn));
114:
115:                cl = ResultMap.class;
116:                qn = new QName("urn:BeanService", "ResultMap");
117:                call.registerTypeMapping(cl, qn, new BeanSerializerFactory(cl,
118:                        qn), new BeanDeserializerFactory(cl, qn));
119:
120:                call.setTargetEndpointAddress(url);
121:                call.setOperationName(new QName("urn:Cougaar-blackboard-count",
122:                        "getBlackboardCount"));
123:                call.addParameter("classFilter", XMLType.XSD_STRING,
124:                        ParameterMode.IN);
125:                call.setReturnType(qn);
126:
127:                Object ret = call.invoke(new Object[] { classFilter });
128:                if (ret instanceof  String) {
129:                    System.out
130:                            .println("Received problem response from server: "
131:                                    + ret);
132:                    throw new AxisFault("", (String) ret, null, null);
133:                }
134:                ResultMap rm = (ResultMap) ret;
135:                return rm.toMap();
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.