Source Code Cross Referenced for GLMStimulatorServlet.java in  » Science » Cougaar12_4 » org » cougaar » glm » servlet » 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.glm.servlet 
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.glm.servlet;
028:
029:        import java.io.PrintWriter;
030:
031:        import org.cougaar.core.servlet.SimpleServletSupport;
032:        import org.cougaar.planning.servlet.ServletBase;
033:        import org.cougaar.planning.servlet.ServletWorker;
034:
035:        /**
036:         * <pre>
037:         * A servlet that injects tasks into an agent.
038:         *
039:         * Parses an xml file that defines a batch of tasks.
040:         *
041:         * The servlet takes these parameters:
042:         * 1) The file name of the xml file
043:         *    URL param is inputFileName
044:         * 2) The number of batches of tasks to be sent (defaults to 1)
045:         *    URL param is numberOfBatches
046:         * 3) The interval to wait between batches being sent (defaults to 1 second)
047:         *    URL param is interval
048:         * 4) Whether to wait or not for each task to complete before sending the next
049:         *    This can be very useful for performance measurements.
050:         *    URL param is wait
051:         * 5) Which format you'd like the results back in : XML, HTML, or serialized objects
052:         *    The results, when you wait for each task to complete, is a list of completion times
053:         *    plus the total time to complete.  See GLMStimulatorResponseData for sample output.
054:         *
055:         * A typical URL would be :
056:         *
057:         * http://localhost:8800/$3-FSB/stimulator?inputFileName=Supply.dat.xml&tasksPerBatch=1&numberOfBatches=1&interval=1000&format=html
058:         *
059:         * It requires a special servlet component in the ini file (or equivalent XML entry) :
060:         *
061:         * plugin = org.cougaar.planning.servlet.BlackboardServletComponent(org.cougaar.glm.servlet.GLMStimulatorServlet, /stimulator)
062:         *
063:         * Also, if the xml file that defines a task that needs a prototype that is not provided by the XMLPrototypeProvider, you 
064:         * may need to register the prototype using an xml file, e.g.:
065:         *
066:         * plugin = org.cougaar.lib.plugin.UTILLdmXMLPlugin(ldmFile={String}Ammo_AssetList.ldm.xml)
067:         * 
068:         * Gordon Vidaver
069:         * gvidaver@bbn.com
070:         * (617) 873-3558
071:         * </pre>
072:         */
073:        public class GLMStimulatorServlet extends ServletBase {
074:            public void setSimpleServletSupport(SimpleServletSupport support) {
075:                super .setSimpleServletSupport(support);
076:            }
077:
078:            public static final String INPUT_FILE = "inputFileName";
079:            public static final String FOR_PREP = "forPrep";
080:            public static final String NUM_BATCHES = "numberOfBatches";
081:            public static final String TASKS_PER_BATCH = "tasksPerBatch";
082:            public static final String INTERVAL = "interval";
083:            public static final String WAIT_BEFORE = "waitBefore";
084:            public static final String WAIT_AFTER = "waitAfter";
085:            public static final String RESCIND_AFTER_COMPLETE = "rescindAfterComplete";
086:            public static final String USE_CONFIDENCE = "useConfidence";
087:            public static final String TASK_PARSER_CLASS = "taskParserClass";
088:            public static final boolean DEBUG = false;
089:            public static boolean VERBOSE = false;
090:
091:            static {
092:                VERBOSE = Boolean
093:                        .getBoolean("org.cougaar.glm.plugins.tools.GLMStimulatorServlet.verbose");
094:            }
095:
096:            protected ServletWorker createWorker() {
097:                return new GLMStimulatorWorker();
098:            }
099:
100:            /** initial page presented when the servlet is called with no arguments */
101:            public void getUsage(PrintWriter out, SimpleServletSupport support) {
102:                out
103:                        .print("<HTML><HEAD><TITLE>GLMStimulatorServlet</TITLE></HEAD><BODY>\n"
104:                                + "<H2><CENTER>GLMStimulatorServlet</CENTER></H2><P>\n"
105:                                + "<FORM METHOD=\"GET\" ACTION=\"/$");
106:                out.print(support.getEncodedAgentName());
107:                out.print(support.getPath());
108:                out.print("\">\n");
109:                // ask what task file 
110:                out.print("<font size=+1>Inject tasks into agent <b>"
111:                        + support.getAgentIdentifier() + "</b></font><p>\n");
112:
113:                out.println("<table>\n");
114:
115:                // ask what task file 
116:                out.println("<tr><td>");
117:                out.print("Input Task File");
118:                out.print("</td><td>");
119:                out.print("<INPUT TYPE=\"text\" NAME=\"" + INPUT_FILE
120:                        + "\" SIZE=40>");
121:                out.println("</td></tr>");
122:
123:                // allow optional override of file's FOR prep
124:                out.println("<tr><td>");
125:                out.print("Override \"FOR\" prepositional phrase value");
126:                out.print("</td><td>");
127:                out.print("<INPUT TYPE=\"text\" NAME=\"" + FOR_PREP
128:                        + "\" SIZE=40>");
129:                out.println("</td></tr>");
130:
131:                // get task parser class
132:                out.println("<tr><td>");
133:                out
134:                        .print("Task Parser Class (if you want to override default parser)");
135:                out.print("</td><td>");
136:                out
137:                        .print("<INPUT TYPE=\"text\" NAME=\""
138:                                + TASK_PARSER_CLASS
139:                                + "\" "
140:                                + "VALUE=\"org.cougaar.glm.parser.GLMTaskParser\" SIZE=40>");
141:                out.println("</td></tr>");
142:
143:                // get number of batches to send 
144:                out.println("<tr><td>");
145:                out.print("Number of batches");
146:                out.print("</td><td>");
147:                out.print("<INPUT TYPE=\"text\" NAME=\"" + NUM_BATCHES + "\" "
148:                        + "VALUE=\"1\">");
149:                out.println("</td></tr>");
150:
151:                // get number of tasks per batch
152:                out.print("<tr><td>");
153:                out.print("Tasks per batch");
154:                out.print("</td><td>");
155:                out.print("<INPUT TYPE=\"text\" NAME=\"" + TASKS_PER_BATCH
156:                        + "\" " + "VALUE=\"1\">");
157:                out.println("</td></tr>");
158:
159:                // get wait interval
160:                out.println("<tr><td>");
161:                out.print("Wait interval between batches");
162:                out.print("</td><td>");
163:                out.print("<INPUT TYPE=\"text\" NAME=\"" + INTERVAL + "\" "
164:                        + "VALUE=\"1000\">&nbsp;millis");
165:                out.println("</td></tr>");
166:
167:                // choose whether to wait for batch completion, or not
168:                out.println("<tr><td>");
169:                out
170:                        .print("Wait for each batch to complete before sending more");
171:                out.print("</td><td>");
172:                out.print("<INPUT TYPE=\"checkbox\" NAME=\"" + WAIT_BEFORE
173:                        + "\" VALUE=\"true\">");
174:                out.println("</td></tr>");
175:
176:                // choose whether to wait for being done, or not
177:                out.println("<tr><td>");
178:                out
179:                        .print("Wait for all tasks to complete before returning results");
180:                out.print("</td><td>");
181:                out.print("<INPUT TYPE=\"checkbox\" NAME=\"" + WAIT_AFTER
182:                        + "\" VALUE=\"true\">");
183:                out.println("</td></tr>");
184:
185:                // choose whether to rescind tasks after injecting them
186:                out.println("<tr><td>");
187:                out.print("Remove injected tasks after all complete");
188:                out.print("</td><td>");
189:                out.print("<INPUT TYPE=\"checkbox\" NAME=\""
190:                        + RESCIND_AFTER_COMPLETE + "\" VALUE=\"true\">");
191:                out.println("</td></tr>");
192:
193:                // choose whether to use 100% confidence as completion test
194:                out.println("<tr><td>");
195:                out
196:                        .print("A task is complete when it has a 100% confident reported result. "
197:                                + "<br>Otherwise waits only until plan element is attached.");
198:                out.print("</td><td>");
199:                out.print("<INPUT TYPE=\"checkbox\" NAME=\"" + USE_CONFIDENCE
200:                        + "\" VALUE=\"true\">");
201:                out.println("</td></tr>");
202:                out.println("</table><p>");
203:
204:                // choose data format - html, xml, or java objects 
205:                out.print("<center>Show results as "
206:                        + "&nbsp;&nbsp;<INPUT TYPE=\"radio\" NAME=\"format\" "
207:                        + "VALUE=\"html\" CHECKED>" + "&nbsp;html&nbsp;");
208:                out.print("<INPUT TYPE=\"radio\" NAME=\"format\" "
209:                        + "VALUE=\"xml\">&nbsp;xml&nbsp;");
210:                out.print("<INPUT TYPE=\"radio\" NAME=\"format\" "
211:                        + "VALUE=\"data\">"
212:                        + "&nbsp;serialized Java objects<p>\n");
213:                out.print("<INPUT TYPE=\"submit\" NAME=\"Inject\"></center>\n"
214:                        + "</FORM></BODY></HTML>");
215:            }
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.