atg.rest.servlet
Class RestPipelineServlet

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.servlet.pipeline.PipelineableServletImpl
                  extended by atg.rest.servlet.RestPipelineServlet
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, PipelineableServlet, java.util.EventListener, javax.servlet.Servlet
Direct Known Subclasses:
HeadRestServlet

public class RestPipelineServlet
extends PipelineableServletImpl

Base class for a REST pipeline servlet. This servlet pipeline is intended to make ATG resources available in a "Representational State Transfer" format. See: http://www.ics.uci.edu/%7Efielding/pubs/dissertation/top.htm


Field Summary
static java.lang.String BEAN_SERVLET_PATH
           
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String PARSED_URI
           
static java.lang.String PATH_INFO
           
static java.lang.String REPOSITORY_SERVLET_PATH
           
static java.lang.String REST_CONTEXT_ROOT
           
static java.lang.String SERVLET_PATH
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RestPipelineServlet()
          Constructor
 
Method Summary
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 java.lang.String getMethod(DynamoHttpServletRequest pRequest)
          This method returns the http method type for the given request.
 java.lang.String getRequiredServletPrefix()
          Returns the required servlet prefix.
 RestProcessor getRestProcessor()
           
 javax.transaction.TransactionManager getTransactionManager()
           
 boolean isEnsureTransaction()
          Returns property EnsureTransaction, if false then no transaction management is performed
protected  boolean isTransactionMarkedAsRollback()
          Returns true if the transaction associated with the current thread is marked for rollback, false otherwise
protected  void postCommitTransaction(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method is called after the transaction is committed.
protected  void postCreateTransaction(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method is called after the transaction is created.
protected  void preCommitTransaction(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method is called before the transaction is committed.
protected  void preCreateTransaction(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method is called before the transaction is created.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Override the service() method and call serviceRESTRequest().
 void serviceRESTRequest(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This is the method which determines the type of request made and hands it off to one of the handle methods in the RestProcessor.
 void setEnsureTransaction(boolean pEnsureTransaction)
          Sets property EnsureTransaction
 void setRequiredServletPrefix(java.lang.String pRequiredServletPrefix)
          Sets the required servletPrefix string
 void setRestProcessor(RestProcessor pRestProcessor)
           
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
           
 
Methods inherited from class atg.servlet.pipeline.PipelineableServletImpl
createAdminServlet, destroy, getAdminServlet, getNextServlet, getServletConfig, getServletInfo, init, isUsePathInfo, passRequest, passRequest, service, service, setNextServlet, setServletInfo, setUsePathInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, doStopService, getAbsoluteName, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


REPOSITORY_SERVLET_PATH

public static final java.lang.String REPOSITORY_SERVLET_PATH
See Also:
Constant Field Values

BEAN_SERVLET_PATH

public static final java.lang.String BEAN_SERVLET_PATH
See Also:
Constant Field Values

REST_CONTEXT_ROOT

public static final java.lang.String REST_CONTEXT_ROOT
See Also:
Constant Field Values

PARSED_URI

public static final java.lang.String PARSED_URI
See Also:
Constant Field Values

SERVLET_PATH

public static final java.lang.String SERVLET_PATH
See Also:
Constant Field Values

PATH_INFO

public static final java.lang.String PATH_INFO
See Also:
Constant Field Values
Constructor Detail

RestPipelineServlet

public RestPipelineServlet()
Constructor

Method Detail

getRestProcessor

public RestProcessor getRestProcessor()
Returns:
the restProcessor. The restProcessor is a reference to a nucleus component which implements the RestProcessor interface for handling REST requests.
See Also:
RestProcessor

setRestProcessor

public void setRestProcessor(RestProcessor pRestProcessor)
Parameters:
pRestProcessor - the restProcessor to set. The restProcessor is a reference to a nucleus component which implements the RestProcessor interface for handling REST requests.
pRestProcessor - the instance of a RestProcessor to set
See Also:
RestProcessor

getRequiredServletPrefix

public java.lang.String getRequiredServletPrefix()
Returns the required servlet prefix. If not null or empty, the above string must be in the URI for this request to be passed to the request processor.

Returns:
the requiredServletPrefix string

setRequiredServletPrefix

public void setRequiredServletPrefix(java.lang.String pRequiredServletPrefix)
Sets the required servletPrefix string

Parameters:
pRequiredServletPrefix - the requiredServletPrefix to set

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns:
the value of transactionManager

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Parameters:
pTransactionManager - the transactionManager to set

setEnsureTransaction

public void setEnsureTransaction(boolean pEnsureTransaction)
Sets property EnsureTransaction


isEnsureTransaction

public boolean isEnsureTransaction()
Returns property EnsureTransaction, if false then no transaction management is performed


doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

preCreateTransaction

protected void preCreateTransaction(DynamoHttpServletRequest pRequest,
                                    DynamoHttpServletResponse pResponse)
                             throws RestException
This method is called before the transaction is created. Its purpose is to allow subclasses to override it to add any needed functionality.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs in the method

postCreateTransaction

protected void postCreateTransaction(DynamoHttpServletRequest pRequest,
                                     DynamoHttpServletResponse pResponse)
                              throws RestException,
                                     java.io.IOException
This method is called after the transaction is created. Its purpose is to allow subclasses to override it to add any needed functionality.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs in the method
java.io.IOException

preCommitTransaction

protected void preCommitTransaction(DynamoHttpServletRequest pRequest,
                                    DynamoHttpServletResponse pResponse)
This method is called before the transaction is committed. Its purpose is to allow subclasses to override it to add any needed functionality.

Parameters:
pRequest - the servlet request
pResponse - the servlet response

postCommitTransaction

protected void postCommitTransaction(DynamoHttpServletRequest pRequest,
                                     DynamoHttpServletResponse pResponse)
This method is called after the transaction is committed. Its purpose is to allow subclasses to override it to add any needed functionality.

Parameters:
pRequest - the servlet request
pResponse - the servlet response

service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws java.io.IOException,
                    javax.servlet.ServletException
Override the service() method and call serviceRESTRequest(). This method will handle calling passRequest(). Users should override serviceRESTRequest() rather than service().

Overrides:
service in class PipelineableServletImpl
Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
java.io.IOException - if an input or output stream exception occurs
javax.servlet.ServletException - if any other error occurs
See Also:
serviceRESTRequest(DynamoHttpServletRequest, DynamoHttpServletResponse)

isTransactionMarkedAsRollback

protected boolean isTransactionMarkedAsRollback()
Returns true if the transaction associated with the current thread is marked for rollback, false otherwise

Returns:
true if the transaction associated with the current thread is marked for rollback, false otherwise

serviceRESTRequest

public void serviceRESTRequest(DynamoHttpServletRequest pRequest,
                               DynamoHttpServletResponse pResponse)
                        throws RestException,
                               java.io.IOException,
                               javax.servlet.ServletException
This is the method which determines the type of request made and hands it off to one of the handle methods in the RestProcessor.

Parameters:
pRequest - the servlet request
pResponse - the servlet response
Throws:
RestException - if an error occurs processing the REST request
java.io.IOException - if an input or output stream exception occurs
javax.servlet.ServletException - if a general error occurs

getMethod

public java.lang.String getMethod(DynamoHttpServletRequest pRequest)
This method returns the http method type for the given request. Note that by passing in atg-rest-http-method as a parameter into a request it will override the method in the request object. This allows requests to be tunnelled through other methods.

Parameters:
pRequest - the servlet request
Returns:
the method used by the request