jp.terasoluna.fw.web.thin
Class BlockageControlFilter

java.lang.Object
  extended by jp.terasoluna.fw.web.thin.AbstractControlFilter<BlockageController>
      extended by jp.terasoluna.fw.web.thin.BlockageControlFilter
All Implemented Interfaces:
javax.servlet.Filter

public class BlockageControlFilter
extends AbstractControlFilter<BlockageController>

Performs business blockage check.

This class calls any BlockageController instance which is specified in Bean definition file and transfers the business blockage check process of specified path. The BlockageController instance performs the filter process of request from the browser.

Business blockage check function

When the path which is accessed is in business blockage state, BlockageException is thrown.

How to use

To use this function, perform the following settings in deployment descriptor (web.xml) and Bean definition file. "Id" attribute which is defined in Bean definition file should be set as sampleBlockageController. In the "class"attribute of <bean>element, set the class that implements the BlockageController interface.
*To use this filter, the business should be identified from the request path.

Deployment descriptor(web.xml)
 <filter>
   <filter-name>
     blockageControlFilter]
   </filter-name>
   <filter-class>
       jp.terasoluna.fw.web.thin.BlockageControlFilter
   </filter-class>
   <init-param>
     <param-name>controller</param-name>
     <param-value>
       "sampleBlockageController"
     </param-value>
   </init-param>
 </filter>

 <filter-mapping>
   <filter-name>blockageControlFilter</filter-name>
   <url-pattern>/*</url-pattern>
 </filter-mapping>

 <error-page>
   <exception-type>
     jp.terasoluna.fw.web.thin.BlockageException
   </exception-type>
   <location>
     /blockageError.jsp
   </location>
 </error-page>
 
Bean definition file
 <bean id="sampleBlockageController"
       class="jp.terasoluna...SampleBlockageController" />
 
At the time of setting the id attribute of <bean> element which is defined in Bean definition file in the "blockageController" which is the default value, <init-param> element can be omitted from the <filter> element in deployment descriptor (web.xml).

See Also:
AuthenticationControlFilter, AuthenticationController, AuthorizationControlFilter, AuthorizationController, BlockageController, ServerBlockageControlFilter, ServerBlockageController

Field Summary
private static java.lang.Class BLOCKAGE_CONTROLLER_CLASS
          Controller class that transfers the business blockage process.
private static java.lang.String BLOCKAGE_CONTROLLER_ERROR
          Error code which indicates the failure in generating the business blockage controller.
static java.lang.String BLOCKAGE_THRU_KEY
          Key of "request" attribute which indicates that the request has passed through filter.
protected static BlockageController controller
          BlockageController instance.
static java.lang.String DEFAULT_BLOCKAGE_BEAN_ID
          Default id which is used in "id" attribute of <bean> element to fetch the implementation class of controller from DI container.
private static org.apache.commons.logging.Log log
          Log class.
 
Fields inherited from class jp.terasoluna.fw.web.thin.AbstractControlFilter
config
 
Constructor Summary
BlockageControlFilter()
           
 
Method Summary
 void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
          Performs business blockage check.
static BlockageController getBlockageController()
          Returns BlockageController instance.
protected  java.lang.Class getControllerClass()
          Returns the interface which should be implemented by the class that performs access control.
 java.lang.String getDefaultControllerBeanId()
          Returns default id at the time of fetching controller from DI container.
protected  java.lang.String getErrorCode()
          Returns error code that indicates the failure in generating the controller.
 void init(javax.servlet.FilterConfig config)
          This method is called by the container when filter changes to Service Start state. After creating an instance of the Filter, container calls init method only once.
In order to request the Filter to execute the filter process, init method should finish normally. Container cannot change the Filter to service state when the init method is any of the following.
ServletException is thrown. When it does not get recovered within the time defined by container. When the implementation class of the controller does not exist or settings are abnormal.
 
Methods inherited from class jp.terasoluna.fw.web.thin.AbstractControlFilter
destroy, getController, setConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCKAGE_THRU_KEY

public static final java.lang.String BLOCKAGE_THRU_KEY
Key of "request" attribute which indicates that the request has passed through filter.

See Also:
Constant Field Values

DEFAULT_BLOCKAGE_BEAN_ID

public static final java.lang.String DEFAULT_BLOCKAGE_BEAN_ID
Default id which is used in the "id" attribute of <bean> element to fetch the implementation class of controller from DI container.

See Also:
Constant Field Values

BLOCKAGE_CONTROLLER_ERROR

private static final java.lang.String BLOCKAGE_CONTROLLER_ERROR
Error code which indicates the failure in generating the business blockage controller.

See Also:
Constant Field Values

BLOCKAGE_CONTROLLER_CLASS

private static final java.lang.Class BLOCKAGE_CONTROLLER_CLASS
Controller class which transfers the business blockage process.


log

private static org.apache.commons.logging.Log log
Log class


controller

protected static BlockageController controller
BlockageController instance.

Constructor Detail

BlockageControlFilter

public BlockageControlFilter()
Method Detail

getBlockageController

public static BlockageController getBlockageController()
Returns BlockageController instance.

Returns:
BlockageController instance which is set in this filter.

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
This method is called by container when the filter changes to Service start state. After creating an instance of the filter, container calls init method only once.
In order to request the filter to execute the filter process, init method should finish normally. Container cannot change the Filter to service state when the init method is any of the following.

Specified by:
init in interface javax.servlet.Filter
Overrides:
init in class AbstractControlFilter<BlockageController>
Parameters:
config - FilterConfig instance.
Throws:
javax.servlet.ServletException - Exception which is thrown at the time of abnormal initialization.
See Also:
Filter.init(javax.servlet.FilterConfig), AbstractControlFilter

doFilter

public void doFilter(javax.servlet.ServletRequest req,
                     javax.servlet.ServletResponse res,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Performs business blockage check.

Specified by:
doFilter in interface javax.servlet.Filter
Specified by:
doFilter in class AbstractControlFilter<BlockageController>
Parameters:
req - HTTP request
res - HTTP response
chain - Filter chain
Throws:
java.io.IOException - I/O error
javax.servlet.ServletException - Servlet exception
See Also:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

getControllerClass

protected java.lang.Class getControllerClass()
Returns the interface which should be implemented by the class that performs access control.

Specified by:
getControllerClass in class AbstractControlFilter<BlockageController>
Returns:
Controller class which is used in this filter.

getErrorCode

protected java.lang.String getErrorCode()
Returns error code that indicates the failure in generating the controller.

Specified by:
getErrorCode in class AbstractControlFilter<BlockageController>
Returns:
Error code

getDefaultControllerBeanId

public java.lang.String getDefaultControllerBeanId()
Returns the default id at the time of fetching the controller from the DI container.

Specified by:
getDefaultControllerBeanId in class AbstractControlFilter<BlockageController>
Returns:
Default id attribute value