nu.staldal.lsp.framework
Class ServiceBase

java.lang.Object
  extended by nu.staldal.lsp.framework.ServiceBase
All Implemented Interfaces:
Service

Deprecated.

@Deprecated
public abstract class ServiceBase
extends java.lang.Object
implements Service

Abstract base class for Service. See Service.


Field Summary
protected  javax.servlet.ServletContext context
          Deprecated. The ServletContext.
protected  javax.sql.DataSource mainDB
          Deprecated. The DataSource to main database, or null if no database is setup.
 
Fields inherited from interface nu.staldal.lsp.framework.Service
INCLUDE_ATTR_PREFIX, REQUEST_DELETE, REQUEST_GET, REQUEST_INCLUDE, REQUEST_POST, REQUEST_PUT
 
Constructor Summary
ServiceBase()
          Deprecated.  
 
Method Summary
 void destroy()
          Deprecated. Invoked once by the Servlet.destroy() method.
 void dumpRequestParameters(javax.servlet.http.HttpServletRequest request)
          Deprecated. Dump all request parameters to the Servlet log.
 java.lang.String execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map<java.lang.String,java.lang.Object> pageParams, int requestType)
          Deprecated. Invoked for each request to this Service.
abstract  java.lang.String execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map<java.lang.String,java.lang.Object> pageParams, int requestType, DBConnection dbConn)
          Deprecated. Invoked for each request to this Service.
 javax.servlet.ServletContext getServletContext()
          Deprecated. Get the ServletContext.
 void init(DBConnection dbConn)
          Deprecated. Invoked once directly after instantiation, before first use.
 void init(javax.servlet.ServletContext context)
          Deprecated. Invoked once directly after instantiation, before first use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected javax.servlet.ServletContext context
Deprecated. 
The ServletContext.


mainDB

protected javax.sql.DataSource mainDB
Deprecated. 
The DataSource to main database, or null if no database is setup.

Constructor Detail

ServiceBase

public ServiceBase()
Deprecated. 
Method Detail

getServletContext

public javax.servlet.ServletContext getServletContext()
Deprecated. 
Get the ServletContext.

Returns:
the ServletContext

init

public void init(DBConnection dbConn)
          throws java.lang.Exception
Deprecated. 
Invoked once directly after instantiation, before first use.

Parameters:
dbConn - database connection, or null if no database has been setup
Throws:
java.lang.Exception - may throw any Exception

init

public final void init(javax.servlet.ServletContext context)
                throws javax.servlet.ServletException
Deprecated. 
Description copied from interface: Service
Invoked once directly after instantiation, before first use.

The init method should not invoke DispatcherServlet.lookupService(String), DispatcherServlet.doGet(HttpServletRequest, HttpServletResponse), DispatcherServlet.doPost(HttpServletRequest, HttpServletResponse) or ServletExtLib.handleElement(String, org.xml.sax.Attributes, org.xml.sax.ContentHandler).

Specified by:
init in interface Service
Parameters:
context - the ServletContext
Throws:
javax.servlet.ServletException - may throw ServletException

dumpRequestParameters

public void dumpRequestParameters(javax.servlet.http.HttpServletRequest request)
Deprecated. 
Dump all request parameters to the Servlet log. Useful for debugging.

Parameters:
request - the HttpServletRequest

execute

public abstract java.lang.String execute(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         java.util.Map<java.lang.String,java.lang.Object> pageParams,
                                         int requestType,
                                         DBConnection dbConn)
                                  throws java.lang.Exception
Deprecated. 
Invoked for each request to this Service. See Service.execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Map, int).

Parameters:
request - the HttpServletRequest
response - the HttpServletResponse
pageParams - map for page parameters
requestType - the type of request: Service.REQUEST_GET, Service.REQUEST_POST, Service.REQUEST_PUT, Service.REQUEST_DELETE or Service.REQUEST_INCLUDE
dbConn - database connection to use for this request, or null if no database has been setup
Returns:
name of the page to view, or null to not use any page, or the name of an other service to forward to prefixed by "*"
Throws:
java.lang.Exception - may throw any Exception

execute

public final java.lang.String execute(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.util.Map<java.lang.String,java.lang.Object> pageParams,
                                      int requestType)
                               throws javax.servlet.ServletException,
                                      java.io.IOException
Deprecated. 
Description copied from interface: Service
Invoked for each request to this Service.

May be invoked concurrently by several threads.

Is invoked for GET, POST, PUT, DELETE and HEAD requests. You should not treat HEAD requests differently than GET requests, the framework will automatically discard the body and only send the headers. The requestType parameter indicate the type of request. See the HTTP specification for differences between GET, POST, PUT and DELETE requests.

There are three choices to create the response:

  1. Return the name of a page to display, and fill pageParams with parameters to this page. In this case, response should only be used to set headers.
  2. Send the whole response by using response and return null. In this case the framework will not touch response after this method returns, and will not use pageParams. This can be used if you want to use sendError or sendRedirect.
  3. Return the name of an other service to forward the request to, prefixed by "*". Any parameters added to pageParams are retained. You may add attributes to request in order to comnunicate with the other service.

If requestType is Service.REQUEST_INCLUDE, choice 2 and 3 may not be used, and response may not be modified in any way. You may either return the name of page, or use the SAX2 ContentHandler passed as a request attribute with name "org.xml.sax.ContentHandler" and return null. startDocument and endDocument must not be invoked on the ContentHandler, use ContentHandlerStartEndDocumentFilter if this is a problem.

Specified by:
execute in interface Service
Parameters:
request - the HttpServletRequest
response - the HttpServletResponse
pageParams - map for page parameters
requestType - the type of request: Service.REQUEST_GET, Service.REQUEST_POST, Service.REQUEST_PUT, Service.REQUEST_DELETE or Service.REQUEST_INCLUDE
Returns:
name of the page to view, or null to not use any page, or the name of an other service to forward to prefixed by "*"
Throws:
javax.servlet.ServletException - may throw ServletException
java.io.IOException - may throw IOException

destroy

public void destroy()
Deprecated. 
Invoked once by the Servlet.destroy() method.

Specified by:
destroy in interface Service