org.openamf
Class DefaultGateway

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byorg.openamf.DefaultGateway
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
AdvancedGateway

public class DefaultGateway
extends javax.servlet.http.HttpServlet

This is the Default entry for all amf requests When a request is recieved it will be deserialized, processed, and then the response wil be serialized and sent to the client.

Version:
$Revision: 1.65 $, $Date: 2005/07/05 22:04:06 $
Author:
Jason Calabrese , Sean C. Sullivan
See Also:
Serialized Form

Field Summary
protected static org.apache.commons.logging.Log log
           
protected static org.apache.commons.logging.Log requestLog
           
protected static org.apache.commons.logging.Log responseLog
           
 
Constructor Summary
DefaultGateway()
           
 
Method Summary
protected  void clearRequestContext()
           
protected  AMFMessage deserializeAMFMessage(javax.servlet.http.HttpServletRequest req)
          Uses the AMFDeserializer to deserialize the request
protected  ServiceInvoker getServiceInvoker(AMFBody requestBody, javax.servlet.http.HttpServletRequest httpServletRequest)
          This method is used to find the correct invoker for the request.
 java.lang.String getServletInfo()
           
 void init()
           
protected  void initializeRequestContext(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
protected  java.lang.Object invokeBody(javax.servlet.http.HttpServletRequest req, AMFBody requestBody)
           
protected  void logRequestException(java.lang.Exception e, java.lang.Object detail)
           
protected  java.lang.Object postInvokeService(javax.servlet.http.HttpServletRequest httpServletRequest, ServiceInvoker serviceInvoker, java.lang.Object serviceResult)
          Called after the body is invoked, if the selected invoker is a persistant service it's persistent service object will be stored in the session
protected  void preInvokeService(javax.servlet.http.HttpServletRequest httpServletRequest, ServiceInvoker serviceInvoker)
          Called before a body is invoked, if the selected invoker is a persistent service it's persistent service object will be looked up in the session
protected  AMFMessage processMessage(javax.servlet.http.HttpServletRequest req, AMFMessage message)
          Iterates through the request message's bodies, invokes each body and then, builds a message to send as the results
protected  OpenAMFConfig reloadConfig()
          Loads/Reloads OpenAMF COnfiguration from the openamf-config.xml file
protected  void serializeAMFMessage(javax.servlet.http.HttpServletResponse resp, AMFMessage message)
          Uses the AMFSerializer to serialize the request
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Main entry point for the servlet
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

requestLog

protected static org.apache.commons.logging.Log requestLog

responseLog

protected static org.apache.commons.logging.Log responseLog
Constructor Detail

DefaultGateway

public DefaultGateway()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

initializeRequestContext

protected void initializeRequestContext(javax.servlet.http.HttpServletRequest req,
                                        javax.servlet.http.HttpServletResponse resp)

clearRequestContext

protected void clearRequestContext()

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse resp)
             throws javax.servlet.ServletException,
                    java.io.IOException
Main entry point for the servlet

Throws:
javax.servlet.ServletException
java.io.IOException

logRequestException

protected void logRequestException(java.lang.Exception e,
                                   java.lang.Object detail)

deserializeAMFMessage

protected AMFMessage deserializeAMFMessage(javax.servlet.http.HttpServletRequest req)
                                    throws java.io.IOException
Uses the AMFDeserializer to deserialize the request

Throws:
java.io.IOException
See Also:
AMFDeserializer

serializeAMFMessage

protected void serializeAMFMessage(javax.servlet.http.HttpServletResponse resp,
                                   AMFMessage message)
                            throws java.io.IOException
Uses the AMFSerializer to serialize the request

Throws:
java.io.IOException
See Also:
AMFSerializer

processMessage

protected AMFMessage processMessage(javax.servlet.http.HttpServletRequest req,
                                    AMFMessage message)
Iterates through the request message's bodies, invokes each body and then, builds a message to send as the results


invokeBody

protected java.lang.Object invokeBody(javax.servlet.http.HttpServletRequest req,
                                      AMFBody requestBody)

preInvokeService

protected void preInvokeService(javax.servlet.http.HttpServletRequest httpServletRequest,
                                ServiceInvoker serviceInvoker)
                         throws ServiceInvocationException
Called before a body is invoked, if the selected invoker is a persistent service it's persistent service object will be looked up in the session

Throws:
ServiceInvocationException

postInvokeService

protected java.lang.Object postInvokeService(javax.servlet.http.HttpServletRequest httpServletRequest,
                                             ServiceInvoker serviceInvoker,
                                             java.lang.Object serviceResult)
                                      throws ServiceInvocationException
Called after the body is invoked, if the selected invoker is a persistant service it's persistent service object will be stored in the session

Throws:
ServiceInvocationException

getServiceInvoker

protected ServiceInvoker getServiceInvoker(AMFBody requestBody,
                                           javax.servlet.http.HttpServletRequest httpServletRequest)
                                    throws ServiceInvocationException
This method is used to find the correct invoker for the request. By default it just iterates over the service invokers defined in openamf-config.xml and calls it's supports method.

Throws:
ServiceInvocationException
See Also:
org.openamf.invoker.ServiceInvoker#supports(org.openamf.invoker.ServiceInvoker)

reloadConfig

protected OpenAMFConfig reloadConfig()
Loads/Reloads OpenAMF COnfiguration from the openamf-config.xml file

Returns:

getServletInfo

public java.lang.String getServletInfo()