jet.servlet
Class JetContext

java.lang.Object
  extended by jet.servlet.JetContext
All Implemented Interfaces:
java.lang.Cloneable, Identifiable, Poolable, Resetable

public class JetContext
extends java.lang.Object
implements Poolable

Class providing new context object

Author:
Markus.Meisters@web.de

Field Summary
private  JetAction action
          Holds the current jetAction
private  java.util.TreeMap attributes
          Holds the attributes set on this context
private  boolean contentTypeSet
           
private  JetData data
          Holds the current JetData
private  JetForm form
          Holds the current jet action form
static java.lang.String KEY
          Provids key for session context
private  JetRenderer renderer
          renderer to use
private  JetRequest request
          Holds the http request
private  JetResponse response
          Holds the http response object
private  JetServlet servlet
          Holds the servlet wrapper object
 
Constructor Summary
JetContext()
          Constrcutor()
JetContext(JetServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Constructor(identifier)
 
Method Summary
 java.lang.Object clone()
          Method to support cloning
 void dispatch(java.lang.String url)
           
 JetAction getActionByUrl(java.lang.String url)
          returns action for the given url
 java.lang.Object getAttribute(java.lang.String key)
          Returns a JetContext attribute
 java.util.Iterator getAttributeNames()
          Returns the attribute names as Iteration
 java.util.TreeMap getAttributes()
          Returns all attributes of this context
 java.lang.String getContextPath()
          Returns the context path
 JetForm getFormByID(java.lang.String formId)
          Returns the JetForm object to the url
 JetForm getFormByUrl(java.lang.String jetActionUrl)
          Returns the JetForm object to the url
 java.lang.String getIdentifier()
          Returns the identifier
 JetAction getJetAction()
          Returns the JetAction
 JetData getJetData()
          Returns the JetData
 JetForm getJetForm()
          Returns the form for the action called
 JetRenderer getRenderer()
          Method to get Renderer to use
 JetRequest getRequest()
          Returns the servlet request object
 JetResponse getResponse()
          Returns the response object
 JetServlet getServlet()
          Returns the JetServlet object
 javax.servlet.ServletConfig getServletConfig()
          Returns the servlet config
 javax.servlet.ServletContext getServletContext()
          Returns the Servlet context object
 javax.servlet.http.HttpSession getSession()
          Returns the session object
 javax.servlet.http.HttpSession getSession(boolean create)
          Returns http session and if no one exists, creates one
 freemarker.template.Configuration getTemplateEngine()
          returns the servlet template engine
 void init(JetServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          init method to set all necessary objects
protected  boolean isContentTypeSet()
           
protected  boolean isSessionDebug()
          indocates if the servlet context is in debug modus
protected  void pushBackAction(Poolable p)
          Method to return used actions
 void pushBackForm(Poolable p)
          Method to return use forms
 void redirect(java.lang.String url)
           
 void render(byte[] bytes)
          Method to render byte array
 void render(byte[] bytes, java.lang.String conntentType)
          Method to render byte array
 void render(JetData data, java.lang.String templatename)
          Method to render a template to response
 void render(JetData data, java.lang.String templatename, java.lang.String contentType)
          Method to render a template to response
 void reset()
          Method to reset the context
 void sendError(int i)
           
 void sendError(int i, java.lang.String x)
           
 void sendRedirect(java.lang.String url)
           
 void setAttribute(java.lang.String key, java.lang.Object value)
          Set an attribute with the given value to the given key
 void setAttributes(java.util.TreeMap attrs)
          Set attributes this context
protected  void setContentTypeSet(boolean contentTypeSet)
           
 void setJetAction(JetAction action)
          Set the action
 void setJetData(JetData data)
          Set the data structure
 void setJetForm(JetForm form)
          Set the action form
private  void setRequest(JetRequest request)
          Set the request object
private  void setResponse(JetResponse response)
          Set the reponse object
 void setServlet(JetServlet servlet)
          Set the servlet
protected  void setSessionDebug(boolean debug)
          Set the debug flag
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static final java.lang.String KEY
Provids key for session context

See Also:
Constant Field Values

contentTypeSet

private boolean contentTypeSet

servlet

private JetServlet servlet
Holds the servlet wrapper object


action

private JetAction action
Holds the current jetAction


form

private JetForm form
Holds the current jet action form


renderer

private JetRenderer renderer
renderer to use


data

private JetData data
Holds the current JetData


request

private JetRequest request
Holds the http request


response

private JetResponse response
Holds the http response object


attributes

private java.util.TreeMap attributes
Holds the attributes set on this context

Constructor Detail

JetContext

public JetContext()
Constrcutor()


JetContext

public JetContext(JetServlet servlet,
                  javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException
Constructor(identifier)

Parameters:
servlet - servlet
request - request object
response - response object
Throws:
java.io.IOException
Method Detail

init

public void init(JetServlet servlet,
                 javax.servlet.http.HttpServletRequest request,
                 javax.servlet.http.HttpServletResponse response)
          throws java.io.IOException
init method to set all necessary objects

Parameters:
servlet - servlet
request - request object
response - response object
Throws:
java.io.IOException

getServlet

public JetServlet getServlet()
Returns the JetServlet object

Returns:
JetServlet servlet object

getJetAction

public JetAction getJetAction()
Returns the JetAction

Returns:
JetAction jet action

getJetData

public JetData getJetData()
Returns the JetData

Returns:
JetData data

getJetForm

public JetForm getJetForm()
Returns the form for the action called

Returns:
JetForm form

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns the Servlet context object

Returns:
ServletContext servlet context

getServletConfig

public javax.servlet.ServletConfig getServletConfig()
Returns the servlet config

Returns:
ServletConfig servlet config

setServlet

public void setServlet(JetServlet servlet)
Set the servlet

Parameters:
servlet - servlet

setJetAction

public void setJetAction(JetAction action)
Set the action

Parameters:
action - action

setJetForm

public void setJetForm(JetForm form)
Set the action form

Parameters:
form -

setJetData

public void setJetData(JetData data)
Set the data structure

Parameters:
data - data

getRequest

public JetRequest getRequest()
Returns the servlet request object

Returns:
HttpServletRequest

getSession

public javax.servlet.http.HttpSession getSession()
Returns the session object

See Also:
HttpServletRequest.getSession(boolean)

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
Returns http session and if no one exists, creates one

See Also:
HttpServletRequest.getSession(boolean)

getTemplateEngine

public freemarker.template.Configuration getTemplateEngine()
returns the servlet template engine

Returns:
Configuration

getContextPath

public java.lang.String getContextPath()
Returns the context path

See Also:
HttpServletRequest.getContextPath()

setRequest

private void setRequest(JetRequest request)
Set the request object

Parameters:
request - request

getResponse

public JetResponse getResponse()
Returns the response object

Returns:
HttpServletResponse reponse

setResponse

private void setResponse(JetResponse response)
Set the reponse object

Parameters:
response - reponse

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Returns a JetContext attribute

Parameters:
key - key
Returns:
Object attribute

getAttributes

public java.util.TreeMap getAttributes()
Returns all attributes of this context

Returns:
TreeMap all attributes

setAttributes

public void setAttributes(java.util.TreeMap attrs)
Set attributes this context

Parameters:
attrs - attribute

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Set an attribute with the given value to the given key

Parameters:
key - key
value - value

getAttributeNames

public java.util.Iterator getAttributeNames()
Returns the attribute names as Iteration

Returns:
Iterator iteration

isSessionDebug

protected boolean isSessionDebug()
indocates if the servlet context is in debug modus

Returns:
boolean debug flag

setSessionDebug

protected void setSessionDebug(boolean debug)
Set the debug flag

Parameters:
debug - debug flag

getIdentifier

public java.lang.String getIdentifier()
Returns the identifier

Specified by:
getIdentifier in interface Identifiable
Returns:
String identifier

clone

public java.lang.Object clone()
Method to support cloning

Overrides:
clone in class java.lang.Object
Returns:
Object cloned object

reset

public void reset()
Method to reset the context

Specified by:
reset in interface Resetable

render

public final void render(JetData data,
                         java.lang.String templatename)
                  throws JetActionException,
                         java.io.IOException
Method to render a template to response

Parameters:
data - the TreeMap with data structure to use
templatename - the name of the template to render
Throws:
JetActionException,IOException
JetActionException
java.io.IOException

render

public final void render(JetData data,
                         java.lang.String templatename,
                         java.lang.String contentType)
                  throws JetActionException,
                         java.io.IOException
Method to render a template to response

Parameters:
data - the TreeMap with data structure to use
templatename - the name of the template to render
Throws:
JetActionException,IOException
JetActionException
java.io.IOException

render

public final void render(byte[] bytes)
                  throws java.io.IOException
Method to render byte array

Parameters:
bytes - the bytes to render
Throws:
java.io.IOException

render

public final void render(byte[] bytes,
                         java.lang.String conntentType)
                  throws java.io.IOException
Method to render byte array

Parameters:
bytes - the bytes to render
Throws:
java.io.IOException

getFormByUrl

public JetForm getFormByUrl(java.lang.String jetActionUrl)
                     throws NotFoundException
Returns the JetForm object to the url

Parameters:
jetActionUrl - url
Returns:
JetForm the form object for the specified url
Throws:
NotFoundException

getFormByID

public JetForm getFormByID(java.lang.String formId)
                    throws NotFoundException
Returns the JetForm object to the url

Parameters:
formId - identifier
Returns:
JetForm the form object for the specified identifier
Throws:
NotFoundException

getActionByUrl

public JetAction getActionByUrl(java.lang.String url)
                         throws JetActionException
returns action for the given url

Parameters:
url - teh url
Returns:
JetAction teh action for the url
Throws:
JetActionException

pushBackAction

protected void pushBackAction(Poolable p)
Method to return used actions


pushBackForm

public void pushBackForm(Poolable p)
Method to return use forms


getRenderer

public JetRenderer getRenderer()
Method to get Renderer to use


isContentTypeSet

protected boolean isContentTypeSet()

setContentTypeSet

protected void setContentTypeSet(boolean contentTypeSet)

sendRedirect

public void sendRedirect(java.lang.String url)
                  throws java.io.IOException
Throws:
java.io.IOException

sendError

public void sendError(int i,
                      java.lang.String x)
               throws java.io.IOException
Throws:
java.io.IOException

sendError

public void sendError(int i)
               throws java.io.IOException
Throws:
java.io.IOException

redirect

public void redirect(java.lang.String url)
              throws javax.servlet.ServletException,
                     java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException

dispatch

public void dispatch(java.lang.String url)
              throws javax.servlet.ServletException,
                     java.io.IOException
Throws:
javax.servlet.ServletException
java.io.IOException