PageMixer API - 3.1

jp.ne.dti.lares.foozy.pagemixer.servlet
Class ServletConsumerContext

java.lang.Object
  |
  +--jp.ne.dti.lares.foozy.pagemixer.servlet.ServletConsumerContext
All Implemented Interfaces:
ConsumerContext
Direct Known Subclasses:
StrutsConsumerContext

public class ServletConsumerContext
extends java.lang.Object
implements ConsumerContext

Consumer conetxt implementation for Servlet environment.

This is consumer context implementation for Servlet environment.

But almost all processings are delegated to ServletConsumerContext.KeyCommand implementation classes.

You can use ServletConsumerContext.KeyCommand implementation classes as key to identify value with HashMapConsumerContext as same as with ServletConsumerContext, because those override hasCode() and equals(Object) for ordinal use.

Since:
PageMixer 3.0(as one in this package)

Inner Class Summary
static class ServletConsumerContext.ApplicationKey
          Deprecated. by non inner ApplicationKey class
static class ServletConsumerContext.ContextInitKey
          Deprecated. by non inner ContextInitKey class
static class ServletConsumerContext.CookieKey
          Deprecated. by non inner CookieKey class
static interface ServletConsumerContext.KeyCommand
          This provides abstraction of attribute/parameter accessing.
static class ServletConsumerContext.ParameterKey
          Deprecated. by non inner ParameterKey class
static class ServletConsumerContext.ReqHeaderKey
          Deprecated. by non inner ReqHeaderKey class
static class ServletConsumerContext.RequestKey
          Deprecated. by non inner RequestKey class
static class ServletConsumerContext.ResHeaderKey
          Deprecated. by non inner ResHeaderKey class
static class ServletConsumerContext.ServletInitKey
          Deprecated. by non inner ServletInitKey class
static class ServletConsumerContext.SessionKey
          Deprecated. by non inner SessionKey class
 
Field Summary
static RequestKey BASE_HREF_KEY
          Key to access string as href value of "base" tag.
static java.lang.Object CONTEXT_PATH_KEY
          Deprecated. by RequestMethodKey.CONTEXT_PATH
static RequestKey XHTML_KEY
          Key to store/access result of XHTML-ness examination.
 
Constructor Summary
ServletConsumerContext(javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Construct consumer context for specified servlet environment.
 
Method Summary
 java.lang.String encode(java.lang.String url)
          Get encoded URL string to include the session ID.
 javax.servlet.ServletContext getContext()
          Get ServletContext.
 javax.servlet.http.HttpServletRequest getRequest()
          Get HttpServletRequest.
 javax.servlet.http.HttpServletResponse getResponse()
          Get HttpServletResponse.
 javax.servlet.http.HttpServlet getServlet()
          Get HttpServlet.
 java.lang.Object getValue(java.lang.Object key)
          Get value identified by key.
 void setValue(java.lang.Object key, java.lang.Object value)
          Set value identified by key.
 void unsetValue(java.lang.Object key)
          Un-set value identified by key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_HREF_KEY

public static final RequestKey BASE_HREF_KEY
Key to access string as href value of "base" tag.

This value is PageMixer specific one.

You can get java.lang.String, which can be used as "href" value of "base" tag for "servlet context root" of current request.

This value is composed by ServletUtil#getBaseHref(context, true, true). This value is ensured not to be "null".

Since:
PageMixer 3.1(as static field of this class)

CONTEXT_PATH_KEY

public static final java.lang.Object CONTEXT_PATH_KEY
Deprecated. by RequestMethodKey.CONTEXT_PATH

Key to access Servlet context path of request URI.

This is equivalent to RequestMethodKey.CONTEXT_PATH

Since:
PageMixer 3.1(as static field of this class)

XHTML_KEY

public static final RequestKey XHTML_KEY
Key to store/access result of XHTML-ness examination.

This value is PageMixer specific one.

This is defined as the key object for XHTMLDetectFilter.

The value identified by this key object is not created automatically, because this value depends not on ConsumerContext but on target HTML page. So, you should apply XHTMLDetectFilter before your custom filter, which depends on this key object.

Since:
PageMixer 3.1
Constructor Detail

ServletConsumerContext

public ServletConsumerContext(javax.servlet.http.HttpServlet servlet,
                              javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
Construct consumer context for specified servlet environment.

In this consrructor, values identified below keys are stored into context.

Parameters:
servlet - of current request
request - of current request to Servlet
response - of current request to Servlet
Method Detail

getServlet

public final javax.servlet.http.HttpServlet getServlet()
Get HttpServlet.
Returns:
HttpServlet on which this context depends.

getContext

public final javax.servlet.ServletContext getContext()
Get ServletContext.
Returns:
ServletContext on which this context depends.

getRequest

public final javax.servlet.http.HttpServletRequest getRequest()
Get HttpServletRequest.
Returns:
HttpServletRequest on which this context depends.

getResponse

public final javax.servlet.http.HttpServletResponse getResponse()
Get HttpServletResponse.
Returns:
HttpServletResponse on which this context depends.

getValue

public java.lang.Object getValue(java.lang.Object key)
Get value identified by key.

This treat key parameter as instance of ServletConsumerContext.KeyCommand implemenation class, and delegate value getting to it.

Specified by:
getValue in interface ConsumerContext
Parameters:
key - key to identify value
Returns:
value identified by key(may be null)

setValue

public void setValue(java.lang.Object key,
                     java.lang.Object value)
Set value identified by key.

This treat key parameter as instance of ServletConsumerContext.KeyCommand implemenation class, and delegate value setting to it.

Specified by:
setValue in interface ConsumerContext
Parameters:
key - key to identify value
value - value identified by key

unsetValue

public void unsetValue(java.lang.Object key)
Un-set value identified by key.

This treat key parameter as instance of ServletConsumerContext.KeyCommand implemenation class, and delegate value setting to it.

Specified by:
unsetValue in interface ConsumerContext
Parameters:
key - key to identify value

encode

public java.lang.String encode(java.lang.String url)
Get encoded URL string to include the session ID.

This invokes encodeURL(String) of HttpServletResponse.

Specified by:
encode in interface ConsumerContext
Parameters:
url - URL to encode
Returns:
encoded URL string

PageMixer API - 3.1