Java Doc for CompletionWatcherWorker.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 Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.cougaar.planning.servlet.ServletWorker
      org.cougaar.glm.servlet.CompletionWatcherWorker

CompletionWatcherWorker
public class CompletionWatcherWorker extends ServletWorker (Code)
 One created for every URL access.
 Uses a blackboard
 service, a watcher, and a trigger to monitor published tasks to see
 when they are complete.
 Note : may not return if it can't go through all it's states.
 


Field Summary
protected  ObjectdoneSignal
    
protected  longfirstIntervalsecondInterval
    
protected  booleangetImage
    
protected  SetincompleteTasks
    
protected  GLMStimulatorResponseDataresponseData
    
protected  longstartend
    
protected  intstate
    
protected  CompletionWatcherSupportsupport
    
protected  TriggerModeltm
    
protected  CollectionverbsToInclude
    
protected  SubscriptionWatcherwatcher
    


Method Summary
protected  voidadvanceState(boolean allComplete, boolean hadNewTasks, boolean expired)
     Calls changeState -- then tests if isDone and if so signals doneSignal in getResult ().
protected  voidblackboardChanged()
    
 Called when either 
 1) the task subscription changes
 2) the plan element subscription changes
 3) a timer expires
 Does book-keeping to keep track of incomplete tasks.
protected  voidcancelTimer()
     Cancel the timer.
protected  voidchangeState(boolean waitedLongEnough, boolean allComplete, boolean hadNewTasks)
    
public  voidexecute(HttpServletRequest request, HttpServletResponse response, SimpleServletSupport support)
    
 Handles all HTTP and HTTPS service requests.
protected  StringgetElapsedTime(long diff)
    
protected  StringgetPrefix()
    
protected  XMLablegetResult()
     Main work done here.
public  voidgetSettings(String name, String value)
    
protected  voidgetUsageImage(HttpServletResponse response)
    
protected  booleanisDone()
    
protected  booleanisVerbIncluded(Verb verb)
    
protected  CollectionparseVerbs(String verbs)
    
final public  voidsetSchedulerService(SchedulerService ss)
    
protected  voidstartFirstWait()
    
protected  voidstartSecondWait()
    
protected  voidstartTimer(long delay)
     Schedule a update wakeup after some interval of time.
protected  booleantimerExpired()
     Test if the timer has expired.

Field Detail
doneSignal
protected Object doneSignal(Code)



firstIntervalsecondInterval
protected long firstIntervalsecondInterval(Code)



getImage
protected boolean getImage(Code)



incompleteTasks
protected Set incompleteTasks(Code)



responseData
protected GLMStimulatorResponseData responseData(Code)
returned response



startend
protected long startend(Code)



state
protected int state(Code)



support
protected CompletionWatcherSupport support(Code)



tm
protected TriggerModel tm(Code)
for waiting for a subscription on the blackboard



verbsToInclude
protected Collection verbsToInclude(Code)



watcher
protected SubscriptionWatcher watcher(Code)
for waiting for a subscription on the blackboard





Method Detail
advanceState
protected void advanceState(boolean allComplete, boolean hadNewTasks, boolean expired)(Code)
Calls changeState -- then tests if isDone and if so signals doneSignal in getResult ().
See Also:   CompletionWatcherWorker.getResult



blackboardChanged
protected void blackboardChanged()(Code)
 Called when either 
 1) the task subscription changes
 2) the plan element subscription changes
 3) a timer expires
 Does book-keeping to keep track of incomplete tasks. 
 (If a plan element has completed, it's task is removed from the
 set of incomplete tasks.)
 Given whether all tasks are complete, if any arrived in the last transaction,
 or if a timer expired, calls advance state.
 



cancelTimer
protected void cancelTimer()(Code)
Cancel the timer.



changeState
protected void changeState(boolean waitedLongEnough, boolean allComplete, boolean hadNewTasks)(Code)
 States are :
 BEFORE_FIRST - some tasks are incomplete
 Transition : when all are complete, start first timer, go to next state
 DURING_FIRST - all tasks are complete
 Transition : waited first interval, go to next state
 Transition : saw incomplete task before time elapsed, go to previous state
 END_OF_FIRST - the required quiet interval has elapsed
 Transition : saw first incomplete task, mark time, go to next state
 AFTER_FIRST  - there are some incomplete tasks
 Transition : all tasks complete, mark time, start second timer, go to next state
 DURING_SECOND - all tasks are complete again, we're possibly done
 Transition : waited second interval, go to next state
 Transition : saw incomplete task before time elapsed, forget end time, go to previous state
 AFTER_SECOND - we waited long enough to make sure we're done
 

Parameters:
  waitedLongEnough - -- if the timer expired, signaling the required wait was completed
Parameters:
  allComplete - - are all tasks complete
Parameters:
  hadNewTasks - - even if all tasks were complete, did any new tasks appear?



execute
public void execute(HttpServletRequest request, HttpServletResponse response, SimpleServletSupport support) throws IOException, ServletException(Code)
 Handles all HTTP and HTTPS service requests.
 Makes a watcher to watch
 the blackboard, a trigger that will call blackboardChanged (), 
 and a trigger model to connect them.
 When a change to a subscription happens, the method call cascade is :
 1) The watcher's signalNotify method is called, which
 2) Triggers the TriggerModel
 3) The TriggerModel queues the trigger with the SchedulerService
 4) The SchedulerService calls my Trigger's trigger method
 5) That trigger method calls blackboardChanged
 Does these in order :
 - Creates all the watcher, trigger model, trigger overhead
 - Creates subscriptions to tasks and plan elements
 - Calls getResult
 - Writes results to output stream with writeResponse ()
 - Unsubscribes
 - Has the watcher unregister interest
 - Tells the trigger model to stop.
 

See Also:   CompletionWatcherWorker.getResult
See Also:   CompletionWatcherWorker.blackboardChanged
See Also:   org.cougaar.planning.servlet.ServletWorker.writeResponse
See Also:   org.cougaar.core.blackboard.SubscriptionWatcher.signalNotify
See Also:   org.cougaar.util.Trigger.trigger
See Also:   org.cougaar.util.SyncTriggerModelImpl
See Also:   org.cougaar.core.service.SchedulerService



getElapsedTime
protected String getElapsedTime(long diff)(Code)
encodes a time interval in a min:sec:millis format



getPrefix
protected String getPrefix()(Code)



getResult
protected XMLable getResult()(Code)
Main work done here.

Calls blackboard changed initially, then waits until the state machine has reached "done."

Then records run elapsed time.
See Also:   CompletionWatcherWorker.getSettings
See Also:   CompletionWatcherWorker.blackboardChanged an "XMLable" result.




getSettings
public void getSettings(String name, String value)(Code)
 Use a query parameter to set a field
 Sets the recognized parameters : firstInterval, secondInterval
 



getUsageImage
protected void getUsageImage(HttpServletResponse response) throws IOException, ServletException(Code)
way to do img tags in a cougaar servlet



isDone
protected boolean isDone()(Code)
we're done if the state machine is in the final state



isVerbIncluded
protected boolean isVerbIncluded(Verb verb)(Code)



parseVerbs
protected Collection parseVerbs(String verbs)(Code)



setSchedulerService
final public void setSchedulerService(SchedulerService ss)(Code)



startFirstWait
protected void startFirstWait()(Code)



startSecondWait
protected void startSecondWait()(Code)



startTimer
protected void startTimer(long delay)(Code)
Schedule a update wakeup after some interval of time.

Uses an alarm.
Parameters:
  delay - how long to delay before the timer expires.
See Also:   org.cougaar.core.agent.service.alarm.Alarm
See Also:   org.cougaar.core.service.AlarmService.addRealTimeAlarm




timerExpired
protected boolean timerExpired()(Code)
Test if the timer has expired. false if the timer is not running or has not yet expiredelse return true.



Fields inherited from org.cougaar.planning.servlet.ServletWorker
final public static boolean DEBUG(Code)(Java Doc)
final public static int FORMAT_DATA(Code)(Java Doc)
final public static int FORMAT_HTML(Code)(Java Doc)
final public static int FORMAT_XML(Code)(Java Doc)
public static boolean VERBOSE(Code)(Java Doc)
protected int format(Code)(Java Doc)

Methods inherited from org.cougaar.planning.servlet.ServletWorker
final public static boolean eq(String a, String b)(Code)(Java Doc)
public void execute(HttpServletRequest request, HttpServletResponse response, SimpleServletSupport support) throws IOException, ServletException(Code)(Java Doc)
protected String getPrefix()(Code)(Java Doc)
protected void getSettings(String name, String value)(Code)(Java Doc)
protected boolean isDataFormat()(Code)(Java Doc)
protected boolean isHtmlFormat()(Code)(Java Doc)
protected boolean isXmlFormat()(Code)(Java Doc)
protected void writeResponse(XMLable result, OutputStream out, HttpServletRequest request, SimpleServletSupport support, int format)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.