org.seasar.cubby.filter
クラス CubbyFilter

java.lang.Object
  上位を拡張 org.seasar.cubby.filter.CubbyFilter
すべての実装されたインタフェース:
Filter

public class CubbyFilter
extends Object
implements Filter

Cubby フィルター。

要求を解析し、対応するアクションが登録されている場合はアクションを実行します。

作成者:
agata, baba

フィールドの概要
static String IGNORE_PATH_PATTERN
          ルーティングの対象外とするパスの初期パラメータ名。
 
コンストラクタの概要
CubbyFilter()
           
 
メソッドの概要
protected  ActionProcessor createActionProcessor()
          ActionProcessor を生成します。
protected  MessagesBehaviour createMessagesBehaviour()
          MessagesBehaviour を生成します。
protected  PathResolver createPathResolver()
          PathResolver を生成します。
 void destroy()
          
 void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
          フィルター処理を行います。
protected  PathInfo findPathInfo(HttpServletRequest request, HttpServletResponse response, String path, List<Pattern> ignorePathPatterns)
          PathInfo を検索します。
 void init(FilterConfig config)
          このフィルタを初期化します。
protected  PathInfo invokeRouting(HttpServletRequest request, HttpServletResponse response, String path, PathResolver pathResolver)
          指定されたパスに対応するアクションを決定し、 PathInfo を返します。
protected  Map<String,Object[]> parseRequest(HttpServletRequest request)
          指定された要求のパラメータをパースして Map に変換します。
protected  void processRequest(HttpServletRequest request, HttpServletResponse response, PathInfo pathInfo)
          指定された PathInfo に対する処理を行います。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

IGNORE_PATH_PATTERN

public static final String IGNORE_PATH_PATTERN
ルーティングの対象外とするパスの初期パラメータ名。

関連項目:
定数フィールド値
コンストラクタの詳細

CubbyFilter

public CubbyFilter()
メソッドの詳細

init

public void init(FilterConfig config)
          throws ServletException
このフィルタを初期化します。

使用可能な初期化パラメータ

定義:
インタフェース Filter 内の init
パラメータ:
config - フィルタ設定のためのオブジェクト
例外:
ServletException - 初期化処理で例外が発生した場合

destroy

public void destroy()

定義:
インタフェース Filter 内の destroy

doFilter

public void doFilter(ServletRequest req,
                     ServletResponse res,
                     FilterChain chain)
              throws IOException,
                     ServletException
フィルター処理を行います。

要求された URI に対応する情報が #routing(HttpServletRequest, HttpServletResponse, List) から取得できた場合は、 processRequest(HttpServletRequest, HttpServletResponse, PathInfo) によって要求を処理します。URI に対応する情報が取得できなかった場合はフィルタチェインで次のフィルタに処理を委譲します。

定義:
インタフェース Filter 内の doFilter
パラメータ:
req - 要求
res - 応答
chain - フィルターチェーン
例外:
IOException - 要求の転送や要求のチェーンがこの例外をスローする場合
ServletException - 要求の転送や要求のチェーンがこの例外をスローする場合

findPathInfo

protected PathInfo findPathInfo(HttpServletRequest request,
                                HttpServletResponse response,
                                String path,
                                List<Pattern> ignorePathPatterns)
PathInfo を検索します。

  • リクエストの属性 CubbyConstants.ATTR_ROUTING に値(Routing のインスタンス)が設定されている(= アクション間のフォワード)場合はその値をもとにした PathInfo
  • 指定されたパスが処理対象外(isIgnorePath(String, List) == true)の場合は null
  • 上記以外の場合は #routing(HttpServletRequest, HttpServletResponse, String) の戻り値を
それぞれ返します。

パラメータ:
request - 要求
response - 応答
path - パス
ignorePathPatterns - 除外するパスのパターンのリスト
戻り値:
検索した PathInfo

invokeRouting

protected PathInfo invokeRouting(HttpServletRequest request,
                                 HttpServletResponse response,
                                 String path,
                                 PathResolver pathResolver)
指定されたパスに対応するアクションを決定し、 PathInfo を返します。

パラメータ:
request - 要求
response - 応答
path - パス
pathResolver - パスのリゾルバ
戻り値:
要求に対応する内部フォワード情報、URI と要求メソッドに対応する内部フォワード情報がない場合や URI が対象外とするパスのパターンにマッチする場合は null

processRequest

protected void processRequest(HttpServletRequest request,
                              HttpServletResponse response,
                              PathInfo pathInfo)
                       throws Exception
指定された PathInfo に対する処理を行います。

パラメータ:
request - 要求
response - 応答
pathInfo - パスの情報
例外:
Exception - 要求の処理で例外が発生した場合

parseRequest

protected Map<String,Object[]> parseRequest(HttpServletRequest request)
指定された要求のパラメータをパースして Map に変換します。

パラメータ:
request - 要求
戻り値:
パース結果の Map

createPathResolver

protected PathResolver createPathResolver()
PathResolver を生成します。

戻り値:
PathResolver

createActionProcessor

protected ActionProcessor createActionProcessor()
ActionProcessor を生成します。

戻り値:
ActionProcessor

createMessagesBehaviour

protected MessagesBehaviour createMessagesBehaviour()
MessagesBehaviour を生成します。

戻り値:
MessagesBehaviour

初期化パラメータ名 初期化パラメータの値
IGNORE_PATH_PATTERN ルーティングの対象外とするパスの正規表現をカンマ区切りで指定します。 HotDeploy 時のパフォーマンスにも影響するので、画像やスクリプトを特定のディレクトリに 格納していてアクションを実行するパスと明確に区別できる場合はできる限り指定するようにしてください。
 <param-name>ignorePathPattern&lt/param-name>
 <param-value>/img/.*,/js/.*<param-name>
 
この例では /img と /js 以下のパスをルーティングの対象外にします。

Copyright © 2006-2010 The Seasar Foundation. All Rights Reserved.