atg.userprofiling.email
Class TemplateInvoker.TemplateSession

java.lang.Object
  extended by atg.userprofiling.email.TemplateInvoker.TemplateSession
Enclosing class:
TemplateInvoker

public class TemplateInvoker.TemplateSession
extends java.lang.Object

Represents a template rendering session. An instance is created via TempalteInvoker.createSession(), renderTemplate() can then be called multiple times, followed by endSession().


Constructor Summary
TemplateInvoker.TemplateSession(java.util.Map pParameterMap, atg.userprofiling.email.RequestResponseInitializer pReqResInitializer)
          Create a TemplateSession...
 
Method Summary
protected  void beforeRender(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method provides a final opportunity to modify the request and response before rendering.
protected  void createCurrentRequestAndResponse(java.lang.String pTemplateURL)
          Create and initialize the current request and response.
protected  DynamoHttpServletRequest createRequestAndSetCurrent(DynamoHttpServletResponse pResponse, java.lang.String pTemplateURL)
          Create a request DynamoHttpServletRequest and set as the value of our currentRequest property.
 void endSession()
          End the session...
 DynamoHttpServletRequest getCurrentRequest()
          Get the request associated with the session.
 DynamoHttpServletResponse getCurrentResponse()
          Get the response associated with the session.
 java.lang.String getSessionId()
          Get the session id for the current session.
 java.lang.String getSiteId()
           
 java.lang.String renderTemplate(java.lang.String pTemplateURL, java.lang.Object pReqResInitArgument)
          Render the specified template.
 void setParameter(java.lang.String pName, java.lang.Object pValue)
          Set/update a parameter.
 void setSiteId(java.lang.String pSiteId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateInvoker.TemplateSession

public TemplateInvoker.TemplateSession(java.util.Map pParameterMap,
                                       atg.userprofiling.email.RequestResponseInitializer pReqResInitializer)
                                throws TemplateEmailException
Create a TemplateSession... should only be called by TemplateInvoker itself.

Parameters:
pParameterMap - the map of Parameters to go into the session.
pReqResInitializer - The request/response initializer.
Throws:
TemplateEmailException
Method Detail

getSessionId

public java.lang.String getSessionId()
Get the session id for the current session.


getCurrentRequest

public DynamoHttpServletRequest getCurrentRequest()
Get the request associated with the session.


getCurrentResponse

public DynamoHttpServletResponse getCurrentResponse()
Get the response associated with the session.


getSiteId

public java.lang.String getSiteId()

setSiteId

public void setSiteId(java.lang.String pSiteId)

createRequestAndSetCurrent

protected DynamoHttpServletRequest createRequestAndSetCurrent(DynamoHttpServletResponse pResponse,
                                                              java.lang.String pTemplateURL)
                                                       throws TemplateEmailException
Create a request DynamoHttpServletRequest and set as the value of our currentRequest property.

Parameters:
pResponse - the response to use. Created by createResponse()
pTemplateURL - the URL of the template to render.
Returns:
the newly created request.
Throws:
TemplateEmailException

endSession

public void endSession()
End the session... restores the current request for the thread, and removes the session from the app-server.


createCurrentRequestAndResponse

protected void createCurrentRequestAndResponse(java.lang.String pTemplateURL)
                                        throws TemplateEmailException
Create and initialize the current request and response. Invokes createResponse() and createRequestAndSetCurrent().

Parameters:
pTemplateURL - the URL of the template to render.
Throws:
TemplateEmailException

renderTemplate

public java.lang.String renderTemplate(java.lang.String pTemplateURL,
                                       java.lang.Object pReqResInitArgument)
                                throws TemplateEmailException
Render the specified template.

This default implementation simply calls the templateRendererServlet's service method, and captures and returns the response's output. The renderer servlet can access the template URL by calling getPathInfo on the request.

Subclasses may override this method to implement other schemes for rendering the template.

Parameters:
pTemplateURL - the template URL
pReqResInitializer - The argument passed to the request/response initializer.
Returns:
The rendered content.
Throws:
TemplateEmailException - if an error occurred while rendering the template

beforeRender

protected void beforeRender(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
This method provides a final opportunity to modify the request and response before rendering.

Parameters:
pRequest -

setParameter

public void setParameter(java.lang.String pName,
                         java.lang.Object pValue)
Set/update a parameter.

Parameters:
pName - the name of the parameter
pValue - the new value for the parameter.