Package nablarch.fw.web
Class HttpMethodBinding
- All Implemented Interfaces:
- Handler<HttpRequest,,- HttpResponse> - HandlerWrapper<HttpRequest,,- HttpResponse> - HttpRequestHandler
public class HttpMethodBinding
extends MethodBinding<HttpRequest,HttpResponse>
implements HttpRequestHandler 
HTTPメソッドベースディスパッチャ。
 
 HTTPリクエストのメソッド名とリクエストURIの値をもとに、
 動的に委譲先となるメソッド決定する。
  例:
    [HTTPリクエストライン]               [委譲先メソッド名]
    GET  /foo/baa/dynamic_page.jsp  ->  getDynamicPageJsp()
    POST /foo/baa/message           ->  postMessage()
  ディスパッチ処理の詳細仕様は、handle(HttpRequest, ExecutionContext) を参照。
 - 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classHttpMethodBindingのファクトリクラス
- 
Field SummaryFields inherited from class nablarch.fw.handler.MethodBindingSCOPE_VAR_NAME_BOUND_CLASS, SCOPE_VAR_NAME_BOUND_METHOD
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected MethodgetMethodBoundTo(HttpRequest req, ExecutionContext ctx) 入力データおよび実行コンテキストの内容に応じて、委譲対象のメソッドを決定する。handle(HttpRequest req, ExecutionContext ctx) getMethodBoundTo() で取得したメソッドに対して後続処理を委譲し、 その結果を返す。Methods inherited from class nablarch.fw.handler.MethodBindinggetDelegates, getHandleMethod, qualifiesAsHandler, saveBoundClassAndMethodToRequestScope
- 
Constructor Details- 
HttpMethodBinding指定されたオブジェクトに処理を委譲するディスパッチャを作成する。- Parameters:
- delegate- ディスパッチの対象となるオブジェクト
 
 
- 
- 
Method Details- 
getMethodBoundTo入力データおよび実行コンテキストの内容に応じて、委譲対象のメソッドを決定する。本クラスの実装では、コンストラクタで渡されたオブジェクトに対して、 HTTPリクエストのメソッド名とリクエストURIの値から 実行対象のメソッドを動的に決定して処理を委譲する。 委譲対象となるメソッドは、以下2つの条件に合致するものが選ばれる。 1. メソッドの戻り値の型がHttpResponseかつ、引数を2つもち、 それぞれの型がHttpRequest、ExecutionContextであること。 2. メソッドの名前が次の文字列に一致する。 (リクエストのHTTPメソッド名 もしくは "do") + (リクエストURIのリソース名) ただし、一致判定は以下の条件のもとで行われる。 - メソッド名の大文字小文字は区別しない。 - リクエストURIのリソース名に含まれる"."は無視される。 - 委譲先クラスのメソッド名に含まれる"_"は無視される。 例: ===================== =========================================================== HTTPリクエスト 委譲対象となるメソッドシグニチャの例 ===================== =========================================================== GET /app/index.html HttpResponse getIndexHtml(HttpRequest, ExecutionContext); HttpResponse getIndexhtml(HttpRequest, ExecutionContext); HttpResponse get_index_html(HttpRequest, ExecutionContext); HttpResponse do_index_html(HttpRequest, ExecutionContext); HttpResponse doIndexHtml(HttpRequest, ExecutionContext); --------------------- ----------------------------------------------------------- POST /app/message HttpResponse postMessage(HttpRequest, ExecutionContext); HttpResponse do_message (HttpRequest, ExecutionContext); ===================== =========================================================== 上記条件に該当するメソッドが存在しなかった場合、 下記のHTTPメッセージに相当するHttpResponseオブジェクトを返す。 HTTP/1.1 404 Not Found Content-Type: text/plain Not Found: /foo/bar/dynamic_page.jsp- Specified by:
- getMethodBoundToin class- MethodBinding<HttpRequest,- HttpResponse> 
- Parameters:
- req- HTTPリクエスト
- ctx- 実行コンテキスト
- Returns:
- 委譲先メソッド
 
- 
handleDescription copied from class:MethodBindinggetMethodBoundTo() で取得したメソッドに対して後続処理を委譲し、 その結果を返す。- Specified by:
- handlein interface- Handler<HttpRequest,- HttpResponse> 
- Specified by:
- handlein interface- HttpRequestHandler
- Overrides:
- handlein class- MethodBinding<HttpRequest,- HttpResponse> 
- Parameters:
- req- 入力オブジェクト
- ctx- 実行コンテキスト
- Returns:
- 処理結果オブジェクト
 
 
-