nu.staldal.lsp.framework
Class DispatcherServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by nu.staldal.lsp.framework.DispatcherServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
RestfulDispatcherServlet

public class DispatcherServlet
extends javax.servlet.http.HttpServlet

Dispatcher Servlet for LSP framework. Will be available in ServletContext under the key nu.staldal.lsp.framework.DispatcherServlet.

See Also:
Serialized Form

Constructor Summary
DispatcherServlet()
           
 
Method Summary
 void destroy()
           
 java.lang.String dispatchService(javax.servlet.http.HttpServletRequest request)
          Strip leading '/' and extension, apply defaultService.
 void doDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doPut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 java.lang.String executeService(java.lang.Object service, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map<java.lang.String,java.lang.Object> pageParams, int requestType)
          Execute a service
 void init()
           
 java.lang.Object lookupService(java.lang.String serviceName)
          Lookup a service.
protected  boolean useTemplateIfServiceIsNotFound()
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, doOptions, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispatcherServlet

public DispatcherServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doPut

public void doPut(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Overrides:
doPut in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doDelete

public void doDelete(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Overrides:
doDelete in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

useTemplateIfServiceIsNotFound

protected boolean useTemplateIfServiceIsNotFound()

executeService

public java.lang.String executeService(java.lang.Object service,
                                       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
Execute a service

Parameters:
service - the Service
request - the HttpServletRequest
response - the HttpServletResponse
pageParams - page parameters
requestType - request type
Returns:
same as service
Throws:
javax.servlet.ServletException - if the service throws it
java.io.IOException - if the service throws it

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

dispatchService

public java.lang.String dispatchService(javax.servlet.http.HttpServletRequest request)
Strip leading '/' and extension, apply defaultService.

Parameters:
request - the HtthServletRequest
Returns:
never return null

lookupService

public java.lang.Object lookupService(java.lang.String serviceName)
                               throws java.lang.InstantiationException,
                                      java.lang.IllegalAccessException,
                                      javax.servlet.ServletException
Lookup a service.

Parameters:
serviceName - service name
Returns:
null if not found
Throws:
java.lang.InstantiationException - if the service cannot be instantiated
java.lang.IllegalAccessException - if the service cannot be instantiated
javax.servlet.ServletException - if the service fails to initialize