edu.uoc.pfc.j2ee.jalonsod.mtp.helper
Class ContextFactory

java.lang.Object
  extended by edu.uoc.pfc.j2ee.jalonsod.mtp.helper.ContextFactory

public class ContextFactory
extends java.lang.Object

File: ContextFactory.java Created: 2012-04-28 Creates requestData object from a request. This factory creates requestData according to request type. The session is created in this step if request has no previous session.

Author:
José Alonso de Motta
See Also:
RequestData, RequestDataPrivate

Field Summary
private static java.util.logging.Logger logger
           
 
Constructor Summary
ContextFactory()
           
 
Method Summary
static RequestDataPrivate getContext(javax.servlet.ServletRequest request)
          Main method for creating requestData context object based on the type of the request object.
private static HttpRequestData getHttpContext(javax.servlet.http.HttpServletRequest request)
          Creates requestData objects for httpServletRequest request type.
static RequestData getRequestData(java.lang.Object request)
          Returns the requestData stored as an attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
Constructor Detail

ContextFactory

public ContextFactory()
Method Detail

getContext

public static RequestDataPrivate getContext(javax.servlet.ServletRequest request)
                                     throws MTPException
Main method for creating requestData context object based on the type of the request object. Only HttpServletRequest is implemented, but framework is open to new types.

Parameters:
request - the request object received from the user.
Returns:
the MTP requestData of the current request.
Throws:
MTPException - throws when request is not of the expected types.

getHttpContext

private static HttpRequestData getHttpContext(javax.servlet.http.HttpServletRequest request)
                                       throws MTPException
Creates requestData objects for httpServletRequest request type.

Parameters:
request - the request object received from the user.
Returns:
the MTP requestData of the current request of http type.
Throws:
MTPException - throws when there is an error creating the requestData object.
See Also:
getRequestData(Object)

getRequestData

public static RequestData getRequestData(java.lang.Object request)
Returns the requestData stored as an attribute. Request types are the same types as declared in getContext.

Parameters:
request - the request object received from user.
Returns:
the MTP requestData of the current request.
See Also:
getContext(ServletRequest)