org.talika.tarsis.servlets
Class ControllerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.talika.tarsis.servlets.AbstractServlet
              extended by org.talika.tarsis.servlets.ControllerServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public final class ControllerServlet
extends AbstractServlet

Implementation of controller servlet of Tarsis MVC Framework.

Version:
$Revision: 126 $
Author:
Jose M. Palomar
See Also:
Serialized Form

Constructor Summary
ControllerServlet()
           
 
Method Summary
 void destroy()
          Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
protected  Command findCommand(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Obtains command from client's request.
 void init(javax.servlet.ServletConfig config)
          Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
protected  void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Processes requests for both HTTP GET and POST methods.
protected  View processCommand(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Command command)
          Process given command.
protected  void processView(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, View view)
          Process given view.
 
Methods inherited from class org.talika.tarsis.servlets.AbstractServlet
doGet, doPost, getContext, getLogger, getServletInfo
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
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
 

Constructor Detail

ControllerServlet

public ControllerServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Called by the servlet container to indicate to a servlet that the servlet is being placed into service.

Initialization consits in calling super init method and storing in a local variable command factory instance for further use.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class AbstractServlet
Parameters:
config - ServletConfig the ServletConfig object that contains configutation information for this servlet.
Throws:
javax.servlet.ServletException - if an exception occurs that interrupts the servlet's normal operation.
See Also:
Servlet.init(javax.servlet.ServletConfig)

destroy

public void destroy()
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class AbstractServlet
See Also:
Servlet.destroy()

process

protected void process(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)
                throws javax.servlet.ServletException,
                       java.io.IOException
Processes requests for both HTTP GET and POST methods.

Controller process requests this way:
  1. Obtains command from request.
  2. Process command action by calling execute method.
  3. Process command view by forwarding or redirecting to it.

Specified by:
process in class AbstractServlet
Parameters:
request - servlet object that contains the request the client has made of the servlet.
response - servlet object that contains the response the servlet sends to the client.
Throws:
javax.servlet.ServletException - if the request could not be handled.
java.io.IOException - if an input or output error is detected when the servlet handles request.

findCommand

protected Command findCommand(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws SystemException
Obtains command from client's request.

Parameters:
request - HttpServletRequest client's request.
response - HttpServletResponse client's response.
Returns:
Command command obtained from client's request.
Throws:
SystemException - if no command is found.

processCommand

protected View processCommand(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              Command command)
                       throws ActionException,
                              SystemException
Process given command.

Parameters:
request - HttpServletRequest client's request.
response - HttpServletResponse client's reponse.
command - Command command to be processed.
Returns:
View view result of processing command.
Throws:
ActionException - if there is a problem executing action.
SystemException - if no view is found.

processView

protected void processView(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           View view)
                    throws SystemException,
                           javax.servlet.ServletException,
                           java.io.IOException
Process given view.

Parameters:
request - HttpServletRequest client's request.
response - HttpServletResponse client's reponse.
view - View view to be processed.
Throws:
SystemException - if view's type is unkown.
javax.servlet.ServletException - if the request could not be handled.
java.io.IOException - if an input or output error is detected when the servlet handles request.


Copyright © 2002-2012 Talika Open Source Group. All Rights Reserved.