| org.cougaar.core.plugin.ComponentPlugin org.cougaar.core.plugin.ServletPlugin
All known Subclasses: org.cougaar.demo.mandelbrot.v3.FractalServlet,
ServletPlugin | abstract public class ServletPlugin extends ComponentPlugin (Code) | | This plugin is a base class for servlets that either modify or subscribe
to the blackboard.
If a servlet only requires blackboard queries and no subscriptions or
add/change/remove modifications, then
ComponentServlet is
recommended.
If
ServletPlugin.isTransactional is true then all servlet processing work is
done single-threaded in the "execute()" method, where it can access
subscriptions and modify the blackboard using the standard
"blackboard.publish*" methods.
org.cougaar.core.servlet.ServletPlugin.timeout=60000Default timeout for ServletPlugin requests, which are processedin the plugin's "execute()" thread. |
Inner Class :final protected static class HttpJob | |
Method Summary | |
protected HttpServlet | createServlet() Create our servlet, which by default calls our doGet/doPost/doPost
methods.
A subclass can override this method if it's designed to create a separate
servlet. | protected String | decode(String s) | protected void | doGet(HttpServletRequest req, HttpServletResponse resp) | protected void | doPost(HttpServletRequest req, HttpServletResponse resp) | protected void | doPut(HttpServletRequest req, HttpServletResponse resp) | protected String | encode(String s) | protected void | execute() | protected String | getEncodedAgentName() | protected String | getPath() Get the path for the Servlet's registration. | protected boolean | isTransactional() Return true (the default) if all servlet requests should run
single-threaded in the "execute()" method, otherwise false if they should
run in the servlet engine's threads (and possibly in parallel with other
servlet requests and the "execute()" thread).
If a servlet requires a cross-transaction result, e.g.:
- publishAdd object X
- wait another plugin to react to object X, e.g.
| public void | load() | protected void | notSupported(HttpServletRequest req, HttpServletResponse resp) | protected void | publishAdd(Object o) | protected void | publishChange(Object o) | protected void | publishChange(Object o, Collection changes) | protected void | publishRemove(Object o) | protected Collection | query(UnaryPredicate pred) | protected void | service(HttpServletRequest req, HttpServletResponse resp) | protected void | serviceLater(HttpServletRequest req, HttpServletResponse resp) | protected void | setupSubscriptions() | protected Subscription | subscribe(UnaryPredicate pred) | public void | unload() |
ServletPlugin | public ServletPlugin()(Code) | | |
createServlet | protected HttpServlet createServlet()(Code) | | Create our servlet, which by default calls our doGet/doPost/doPost
methods.
A subclass can override this method if it's designed to create a separate
servlet. However, if
ServletPlugin.isTransactional is true then it should use
ServletPlugin.serviceLater to do all blackboard work in the "execute()" method
instead of the servlet callback thread.
Even though we switch to the "execute()" thread, we must still block
the servlet callback until we finish the work, otherwise the servlet engine
will close our response stream.
|
execute | protected void execute()(Code) | | |
getEncodedAgentName | protected String getEncodedAgentName()(Code) | | Get the URL-encoded name of the local agent
|
getPath | protected String getPath()(Code) | | Get the path for the Servlet's registration.
Typically the path is supplied by a "path=" plugin argument, but a
subclass can hard-code the path by overriding this method.
|
isTransactional | protected boolean isTransactional()(Code) | | Return true (the default) if all servlet requests should run
single-threaded in the "execute()" method, otherwise false if they should
run in the servlet engine's threads (and possibly in parallel with other
servlet requests and the "execute()" thread).
If a servlet requires a cross-transaction result, e.g.:
- publishAdd object X
- wait another plugin to react to object X, e.g. via a
"notify()" callback or published response
- finish the servlet call
then "isTransactional()" must return false.
Also, if a servlet has no subscriptions or private state, then it's
slightly more efficient to have this method return false. This will allow
requests to run in parallel.
In all other cases, this method should return true. This allows the
"doGet(...)" method to access subscriptions and other internal state
without a synchronization lock, since the "execute()" method is always
single-threaded and runs in a blackboard transaction.
|
setupSubscriptions | protected void setupSubscriptions()(Code) | | |
unload | public void unload()(Code) | | |
|
|