|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.servlet.GenericFilterService
public class GenericFilterService
Filter implementation with support for self-configuration, naming resolution, performance profiling and logging.
Derived class should override the following methods:
The filter may be configured from filter init parameters. specified in a web application deployment descriptor. Named init parameters are treated as properties of the filter. Parameters prefixed with cxt: are looked up using the filters name context.
The following example serves to demonstrate configuration of a generic filter service:
<filter> <filter-name>MyFilterService</filter-name> <filter-class>com.acme.filter.MyFilterService</filter-class> <init-param> <param-name>loggingDebug</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>loggingWarning</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>loggingError</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>loggingInfo</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>MyString</param-name> <param-value>foobar</param-value> </init-param> <param-name>Object</param-name> <param-value>ctx:dynamo:/com/Acme/MyFooObject</param-value> </init-param> </filter>
Derived filters may use the lookup method to lookup objects in the filters name context. The objects name context is accessable via the context property.
The filter may log information using the logging facilities provided. Support for info, warning, error and debug levels are provided by the service.
If a performance monitor is enabled the filter collects performance metrics about the handleDoFilter method.
Field Summary | |
---|---|
protected static java.lang.String |
ARRAY_DELIMITER
|
static java.lang.String |
CLASS_VERSION
Class version string |
protected static java.lang.String |
CONTEXT
|
protected static java.lang.String |
CONTEXT_DELIMITER
|
protected static java.lang.String |
ENVIRONMENT
|
protected static java.lang.String |
ENVIRONMENT_DELIMITER
|
protected javax.naming.Context |
mContext
|
protected javax.servlet.FilterConfig |
mFilterConfig
|
protected boolean |
mLoggingDebug
|
protected boolean |
mLoggingError
|
protected boolean |
mLoggingInfo
|
protected boolean |
mLoggingWarning
|
protected java.lang.String |
mName
|
protected javax.servlet.ServletContext |
mServletContext
|
protected static java.lang.String |
PERFOP_DOFILTERCHAIN
|
protected static java.lang.String |
PERFOP_FILTERREQUEST
|
protected static java.lang.String |
PERFOP_FILTERRESPONSE
|
protected static java.util.ResourceBundle |
sResourceBundle
|
protected static java.lang.String |
sResourceBundleName
|
Constructor Summary | |
---|---|
GenericFilterService()
Constructs an instanceof GenericFilterService |
Method Summary | |
---|---|
void |
destroy()
Called by the web container to indicate to a filter that it is being taken out of service |
void |
doFilter(javax.servlet.ServletRequest pServletRequest,
javax.servlet.ServletResponse pServletResponse,
javax.servlet.FilterChain pFilterChain)
Called by the web container to indicate that a filter should filter a request/response |
protected void |
doFilterChain(javax.servlet.ServletRequest pServletRequest,
javax.servlet.ServletResponse pServletResponse,
javax.servlet.FilterChain pFilterChain)
Called by the filter to indicate that a filter should process the remaining filter chain. |
protected boolean |
doFilterRequest(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
Called by the filter to indicate that a filter should filter a request (before the filter chain is called). |
protected boolean |
doFilterRequest(javax.servlet.ServletRequest pServletRequest,
javax.servlet.ServletResponse pServletResponse,
javax.servlet.FilterChain pFilterChain)
Called by the web continer to indicate that a filter should filter a request/response |
protected void |
doFilterResponse(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
|
protected void |
doFilterResponse(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
Called by the filter to indicate that a filter should filter a response (after the filter chain has been called). |
javax.naming.Context |
getContext()
Returns property Context |
javax.servlet.FilterConfig |
getFilterConfig()
Returns property FilterConfig |
java.lang.String |
getName()
Returns property Name |
javax.servlet.ServletContext |
getServletContext()
Returns property ServletContext |
protected void |
handleDoFilter(javax.servlet.ServletRequest pServletRequest,
javax.servlet.ServletResponse pServletResponse,
javax.servlet.FilterChain pFilterChain)
Deprecated. |
void |
init(javax.servlet.FilterConfig pFilterConfig)
Called by the web container to indicate to a filter that it is being placed into server. |
boolean |
isLoggingDebug()
Returns property LoggingDebug |
boolean |
isLoggingError()
Returns property LoggingError |
boolean |
isLoggingInfo()
Returns property LoggingInfo |
boolean |
isLoggingWarning()
Returns property LoggingWarning |
void |
logDebug(java.lang.String pMessage)
Logs an debug event with the specified message |
void |
logDebug(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an debug event with the specified message and Throwable |
void |
logDebug(java.lang.Throwable pThrowable)
Logs an debug event with the specified Throwable |
void |
logError(java.lang.String pMessage)
Logs an error event with the specified message |
void |
logError(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an error event with the specified message and Throwable |
void |
logError(java.lang.Throwable pThrowable)
Logs an error event with the specified Throwable |
void |
logInfo(java.lang.String pMessage)
Logs an info event with the specified message |
void |
logInfo(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an info event with the specified message and Throwable |
void |
logInfo(java.lang.Throwable pThrowable)
Logs an info event with the specified Throwable |
void |
logWarning(java.lang.String pMessage)
Logs an warning event with the specified message |
void |
logWarning(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an warning event with the specified message and Throwable |
void |
logWarning(java.lang.Throwable pThrowable)
Logs an warning event with the specified Throwable |
java.lang.Object |
lookup(java.lang.String pName)
Retreives the named object |
protected void |
setContext(javax.naming.Context pContext)
Sets property Context |
protected void |
setFilterConfig(javax.servlet.FilterConfig pFilterConfig)
Sets property FilterConfig |
void |
setLoggingDebug(boolean pLoggingDebug)
Sets property LoggingDebug |
void |
setLoggingError(boolean pLoggingError)
Sets property LoggingError |
void |
setLoggingInfo(boolean pLoggingInfo)
Sets property LoggingInfo |
void |
setLoggingWarning(boolean pLoggingWarning)
Sets property LoggingWarning |
protected void |
setName(java.lang.String pName)
Sets property Name |
protected void |
setServletContext(javax.servlet.ServletContext pServletContext)
Sets property ServletContext |
void |
startService(javax.servlet.FilterConfig pFilterConfig)
Called by the filter service after it has been initialzed. |
void |
stopService()
Called by the filter service after it has been destroyed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
protected static final java.lang.String sResourceBundleName
protected static final java.util.ResourceBundle sResourceBundle
protected static final java.lang.String ENVIRONMENT
protected static final java.lang.String ENVIRONMENT_DELIMITER
protected static final java.lang.String CONTEXT
protected static final java.lang.String CONTEXT_DELIMITER
protected static final java.lang.String ARRAY_DELIMITER
protected static final java.lang.String PERFOP_DOFILTERCHAIN
protected static final java.lang.String PERFOP_FILTERREQUEST
protected static final java.lang.String PERFOP_FILTERRESPONSE
protected javax.servlet.FilterConfig mFilterConfig
protected java.lang.String mName
protected javax.servlet.ServletContext mServletContext
protected javax.naming.Context mContext
protected boolean mLoggingInfo
protected boolean mLoggingWarning
protected boolean mLoggingError
protected boolean mLoggingDebug
Constructor Detail |
---|
public GenericFilterService()
Method Detail |
---|
protected void setFilterConfig(javax.servlet.FilterConfig pFilterConfig)
public javax.servlet.FilterConfig getFilterConfig()
protected void setName(java.lang.String pName)
public java.lang.String getName()
protected void setServletContext(javax.servlet.ServletContext pServletContext)
public javax.servlet.ServletContext getServletContext()
protected void setContext(javax.naming.Context pContext)
public javax.naming.Context getContext()
public void setLoggingInfo(boolean pLoggingInfo)
public boolean isLoggingInfo()
public void setLoggingWarning(boolean pLoggingWarning)
public boolean isLoggingWarning()
public void setLoggingError(boolean pLoggingError)
public boolean isLoggingError()
public void setLoggingDebug(boolean pLoggingDebug)
public boolean isLoggingDebug()
public void startService(javax.servlet.FilterConfig pFilterConfig) throws javax.servlet.ServletException
pFilterConfig
- filter configuration information.
javax.servlet.ServletException
- if an exception occurs when starting
this filter.public void init(javax.servlet.FilterConfig pFilterConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
pFilterConfig
- filter configuration information.
ServletsException
- if an exception occurs when initializing
this filter.
javax.servlet.ServletException
public void doFilter(javax.servlet.ServletRequest pServletRequest, javax.servlet.ServletResponse pServletResponse, javax.servlet.FilterChain pFilterChain) throws java.io.IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
pServletRequest
- the servlet requestpServletResponse
- the servlet responsepFilterChain
- the filter chain
java.io.IOException
- when an i/o error occurs
javax.servlet.ServletException
- when an error occurs when processing
this filterprotected void handleDoFilter(javax.servlet.ServletRequest pServletRequest, javax.servlet.ServletResponse pServletResponse, javax.servlet.FilterChain pFilterChain) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
protected boolean doFilterRequest(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException
servletRequest
- servletResponse
-
java.io.IOException
javax.servlet.ServletException
protected boolean doFilterRequest(javax.servlet.ServletRequest pServletRequest, javax.servlet.ServletResponse pServletResponse, javax.servlet.FilterChain pFilterChain) throws java.io.IOException, javax.servlet.ServletException
pServletRequest
- the servlet requestpServletResponse
- the servlet responsepFilterChain
- the filter chain
java.io.IOException
- if an i/o error occurs
javax.servlet.ServletException
- if an error occurs when processing
this filterprotected void doFilterResponse(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException
servletRequest
- servletResponse
-
java.io.IOException
javax.servlet.ServletException
protected void doFilterResponse(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
protected void doFilterChain(javax.servlet.ServletRequest pServletRequest, javax.servlet.ServletResponse pServletResponse, javax.servlet.FilterChain pFilterChain) throws java.io.IOException, javax.servlet.ServletException
pServletRequest
- the servlet requestpServletResponse
- the servlet responsepFilterChain
- the filter chain
java.io.IOException
- when an i/o error occurs
javax.servlet.ServletException
- when an error occurs when processing
this filterpublic void stopService()
public void destroy()
destroy
in interface javax.servlet.Filter
public java.lang.Object lookup(java.lang.String pName) throws javax.naming.NamingException
pName
- the name of the object
javax.naming.NamingException
- if an error occurspublic void logInfo(java.lang.String pMessage)
public void logInfo(java.lang.Throwable pThrowable)
public void logInfo(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logWarning(java.lang.String pMessage)
public void logWarning(java.lang.Throwable pThrowable)
public void logWarning(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logError(java.lang.String pMessage)
public void logError(java.lang.Throwable pThrowable)
public void logError(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logDebug(java.lang.String pMessage)
public void logDebug(java.lang.Throwable pThrowable)
public void logDebug(java.lang.String pMessage, java.lang.Throwable pThrowable)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |