View Javadoc

1   package org.seasar.cubby.action;
2   
3   import java.lang.annotation.ElementType;
4   import java.lang.annotation.Retention;
5   import java.lang.annotation.RetentionPolicy;
6   import java.lang.annotation.Target;
7   
8   /**
9    * アクションメソッドの URL。
10   * <p>
11   * アクションメソッドを起動するための URL を指定するアノテーションです。
12   * </p>
13   * <p>
14   * 使用例
15   * 
16   * <pre>
17   * &#64;Url(&quot;fuga&quot;)
18   * public class HogeAction {
19   * 	// -&gt; &quot;/fuga/m1&quot;
20   * 	public ActionResult m1() {
21   * 	}
22   * 
23   * 	&#64;Url(&quot;list&quot;)
24   * 	// -&gt; &quot;/fuga/list&quot;
25   * 	public ActionResult m2() {
26   * 	}
27   * 
28   * 	&#64;Url(&quot;/xxx/yyy&quot;)
29   * 	// -&gt; &quot;/xxx/yyy&quot;
30   * 	public ActionResult m3() {
31   * 	}
32   * 
33   * 	&#64;Url(&quot;/{id}/edit&quot;)
34   * 	// {id}部分をリクエストパラメータに追加
35   * 	public ActionResult m4() {
36   * 	}
37   * 
38   * 	&#64;Url(&quot;/{userId,a-z}/edit&quot;)
39   * 	// {userId}部分をリクエストパラメータに追加。ユーザID部分は小文字アルファベットのみ。
40   * 	public ActionResult m5() {
41   * 	}
42   * }
43   * </pre>
44   * 
45   * </p>
46   * 
47   * @author agata
48   * @since 1.0
49   */
50  @Retention(RetentionPolicy.RUNTIME)
51  @Target( { ElementType.METHOD, ElementType.TYPE })
52  public @interface Url {
53  
54  	/**
55  	 * アクションメソッドを起動する対象となる HTTP メソッド。
56  	 * 
57  	 * @author agata
58  	 * @since 1.0
59  	 */
60  	enum Method {
61  		/** HTTP GET */
62  		GET,
63  		/** HTTP POST */
64  		POST,
65  		/** HTTP GET、HTTP POST 両方 */
66  		ALL
67  	}
68  
69  	/**
70  	 * アクションメソッドのバインディング用URLを指定します。
71  	 * <p>
72  	 * URLはアクションクラスのURL+アクションメソッドのURLで決定されます。
73  	 * ただし、先頭が『/』の場合コンテキストルートからの絶対パスとして解釈されます。
74  	 * </p>
75  	 * <p>
76  	 * {パラメータ名,正規表現}でプレースホルダーの指定ができます。
77  	 * </p>
78  	 * <p>
79  	 * 正規表現にマッチした場合、マッチした箇所が指定されたパラメータ名に追加され、アクションメソッドが実行されます。
80  	 * 正規表現は省略可能です。省略した場合「0-9a-zA-Z」と同じ意味になります。
81  	 * </p>
82  	 * 
83  	 * @return アクションメソッドのバインディング用URL
84  	 */
85  	String value() default "";
86  
87  	/**
88  	 * アクションメソッドが対応するHTTPのメソッドを指定します。
89  	 * <p>
90  	 * {@link Method#GET}、{@link Method#POST}、{@link Method#ALL}
91  	 * の3種類を指定できます。
92  	 * </p>
93  	 * <p>
94  	 * <strong> この設定はcubby0.8では未実装。0.8までアクションメソッドはGET、POSTを意識せずに実行されます。 つまり、常に
95  	 * RequestMethod.ALLです。 </strong>
96  	 * </p>
97  	 * 
98  	 * @return アクションメソッドが対応するHTTPのメソッド
99  	 */
100 	Method method() default Url.Method.ALL;
101 }