org.sandev.tools.UIProcessor
Class FastXMLWSServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.sandev.tools.UIProcessor.FastXMLWSServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, GeneratedServletInterface, org.sandev.ui.util.SandUIAdaptor

public class FastXMLWSServlet
extends javax.servlet.http.HttpServlet
implements GeneratedServletInterface, org.sandev.ui.util.SandUIAdaptor

A servlet for processing SAND messages serialized into XML with the XMLSerializer utility. This provides a simple and fast HTTP comms bridge. FastXMLWSServlet is an implementation of RequestAdaptor that calls through to a local CommBridge implementation for processing.

The FastXMLWSServlet is initialized with:

  1. The name of a locally accessible node implementing CommBridge.

See Also:
Serialized Form

Field Summary
protected  org.sandev.basics.util.CommBridge commBridge
          A reference to our local CommBridge we use for work.
protected  javax.servlet.http.HttpServlet controlServlet
          The original servlet for this request.
protected  java.lang.String ownerNodeName
          The name of the local node instance implementing CommBridge.
protected  org.sandev.basics.nodecommon.SingletonAccessor singletonAccessor
          The SingletonAccessor we will use to bridge from here to the application processing.
 
Constructor Summary
FastXMLWSServlet()
          Default ctor does nothing.
 
Method Summary
protected  void debug(java.lang.String text)
          Dump out the given text to the debug log.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Pass HTTP 'GET' request over to handleRequest method.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Pass HTTP 'POST' request over to handleRequest method.
protected  void dumpTraceIfUseful(java.lang.Throwable e)
          Print a stack trace for the given exception unless it is due to the app not being ready where this is just log noise.
protected  org.sandev.basics.nodecommon.SandRoot findSandRoot()
          Locate the SandRoot or throw if it can't be found.
protected  org.sandev.basics.util.CommBridge getCommBridge()
          Initializing accessor for commBridge.
 javax.servlet.http.HttpServlet getControlServlet()
          accessor for controlServlet
 java.lang.String getOwnerNodeName()
          accessor for ownerNodeName
 org.sandev.basics.nodecommon.SingletonAccessor getSingletonAccessor()
          accessor for singletonAccessor
protected  void handleRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Use our CommBridge to process the request.
protected  void returnText(org.sandev.basics.sandmessages.AuthWrapper aw, javax.servlet.http.HttpServletResponse res)
          Write the XML for the given message as the response.
 void setCharSerializerClassName(java.lang.String val)
          This method does nothing and is provided just for initialization signature completeness.
 void setControlServlet(javax.servlet.http.HttpServlet val)
          mutator for controlServlet
 void setFixedMode(int val)
          This method does nothing and is provided just for initialization signature completeness.
 void setLocalLaunch(boolean val)
          This method does nothing and is provided just for initialization signature completeness.
 void setNodeInstanceFactoryClassName(java.lang.String val)
          This method does nothing and is provided just for initialization signature completeness.
 void setOwnerNodeName(java.lang.String val)
          mutator for ownerNodeName
 void setSandUIFileName(java.lang.String name)
          This method does nothing and is provided just for initialization signature completeness.
 void setSingletonAccessor(org.sandev.basics.nodecommon.SingletonAccessor val)
          mutator for singletonAccessor
 void setUIFormAdaptorClassName(java.lang.String val)
          This method does nothing and is provided just for initialization signature completeness.
protected  void verifyRunning(org.sandev.basics.util.CommBridge cb)
          If the CommBridge is a node that is not currently running, then throw an exception after waiting for a few moments.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controlServlet

protected javax.servlet.http.HttpServlet controlServlet
The original servlet for this request. This is used to retrieve the servlet context for content retrieval and must be set by the controlling servlet.


ownerNodeName

protected java.lang.String ownerNodeName
The name of the local node instance implementing CommBridge.


singletonAccessor

protected org.sandev.basics.nodecommon.SingletonAccessor singletonAccessor
The SingletonAccessor we will use to bridge from here to the application processing.


commBridge

protected org.sandev.basics.util.CommBridge commBridge
A reference to our local CommBridge we use for work.

Constructor Detail

FastXMLWSServlet

public FastXMLWSServlet()
Default ctor does nothing.

Method Detail

getControlServlet

public javax.servlet.http.HttpServlet getControlServlet()
accessor for controlServlet


setControlServlet

public void setControlServlet(javax.servlet.http.HttpServlet val)
mutator for controlServlet

Specified by:
setControlServlet in interface GeneratedServletInterface

setSandUIFileName

public void setSandUIFileName(java.lang.String name)
This method does nothing and is provided just for initialization signature completeness.

Specified by:
setSandUIFileName in interface GeneratedServletInterface

setCharSerializerClassName

public void setCharSerializerClassName(java.lang.String val)
This method does nothing and is provided just for initialization signature completeness.

Specified by:
setCharSerializerClassName in interface GeneratedServletInterface

setUIFormAdaptorClassName

public void setUIFormAdaptorClassName(java.lang.String val)
This method does nothing and is provided just for initialization signature completeness.

Specified by:
setUIFormAdaptorClassName in interface GeneratedServletInterface

setNodeInstanceFactoryClassName

public void setNodeInstanceFactoryClassName(java.lang.String val)
This method does nothing and is provided just for initialization signature completeness.


setFixedMode

public void setFixedMode(int val)
This method does nothing and is provided just for initialization signature completeness. Fixed mode is assumed.

Specified by:
setFixedMode in interface GeneratedServletInterface

getOwnerNodeName

public java.lang.String getOwnerNodeName()
accessor for ownerNodeName


setOwnerNodeName

public void setOwnerNodeName(java.lang.String val)
mutator for ownerNodeName

Specified by:
setOwnerNodeName in interface GeneratedServletInterface

setLocalLaunch

public void setLocalLaunch(boolean val)
This method does nothing and is provided just for initialization signature completeness. Even if we are launching nodes from a servlet, we would presumably be driving this from the SandUI servlet, not the web service support servlet, so this is always assumed to be false.

Specified by:
setLocalLaunch in interface GeneratedServletInterface

getSingletonAccessor

public org.sandev.basics.nodecommon.SingletonAccessor getSingletonAccessor()
accessor for singletonAccessor


setSingletonAccessor

public void setSingletonAccessor(org.sandev.basics.nodecommon.SingletonAccessor val)
mutator for singletonAccessor

Specified by:
setSingletonAccessor in interface GeneratedServletInterface

getCommBridge

protected org.sandev.basics.util.CommBridge getCommBridge()
                                                   throws org.sandev.basics.structs.SandException
Initializing accessor for commBridge. If we can't find our bridge then it's most likely because we are in the process of starting up and it's not ready yet. So we wait for 20 seconds before we throw to avoid the situation where a client is in a permanent retry loop that starts to look like a DOS attack in the log.

Throws:
org.sandev.basics.structs.SandException

findSandRoot

protected org.sandev.basics.nodecommon.SandRoot findSandRoot()
                                                      throws org.sandev.basics.structs.SandException
Locate the SandRoot or throw if it can't be found. Check the configured SingletonAccessor first, then the default, then die. This method assumes that the root has been set up and all we have to do is return it.

Throws:
org.sandev.basics.structs.SandException

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
Pass HTTP 'GET' request over to handleRequest method.

Overrides:
doGet in class javax.servlet.http.HttpServlet

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
Pass HTTP 'POST' request over to handleRequest method.

Overrides:
doPost in class javax.servlet.http.HttpServlet

handleRequest

protected void handleRequest(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse res)
Use our CommBridge to process the request.


returnText

protected void returnText(org.sandev.basics.sandmessages.AuthWrapper aw,
                          javax.servlet.http.HttpServletResponse res)
Write the XML for the given message as the response.


verifyRunning

protected void verifyRunning(org.sandev.basics.util.CommBridge cb)
                      throws org.sandev.basics.structs.SandException
If the CommBridge is a node that is not currently running, then throw an exception after waiting for a few moments. The wait is to prevent lots of clients from continually retrying and thereby causing a barrage of requests that prevents us from getting any work done, especially whn starting up.

Throws:
org.sandev.basics.structs.SandException

debug

protected void debug(java.lang.String text)
Dump out the given text to the debug log. Just calls system out for now.


dumpTraceIfUseful

protected void dumpTraceIfUseful(java.lang.Throwable e)
Print a stack trace for the given exception unless it is due to the app not being ready where this is just log noise. When an application is just starting up, it's possible that the commBridge won't be available yet. That's easy to see from the error text, and we don't want to clutter up the startup log with a bunch of stack traces since it tends to make things very difficult to read. All other errors we probably want the full information though.