View Javadoc

1   /*
2    * Copyright 2004-2010 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  
17  package org.seasar.cubby.action;
18  
19  import java.lang.annotation.ElementType;
20  import java.lang.annotation.Retention;
21  import java.lang.annotation.RetentionPolicy;
22  import java.lang.annotation.Target;
23  
24  /**
25   * アクションメソッドのパス。
26   * <p>
27   * アクションメソッドを起動するためのパスを指定するアノテーションです。
28   * </p>
29   * <p>
30   * 使用例
31   * 
32   * <pre>
33   * &#064;Path(&quot;fuga&quot;)
34   * public class HogeAction {
35   * 	// -&gt; &quot;/fuga/index&quot;
36   * 	public ActionResult index() {
37   * 	}
38   * 
39   * 	// -&gt; &quot;/fuga/m1&quot;
40   * 	public ActionResult m1() {
41   * 	}
42   * 
43   * 	&#064;Path(&quot;list&quot;)
44   * 	// -&gt; &quot;/fuga/list&quot;
45   * 	public ActionResult m2() {
46   * 	}
47   * 
48   * 	&#064;Path(&quot;/xxx/yyy&quot;)
49   * 	// -&gt; &quot;/xxx/yyy&quot;
50   * 	public ActionResult m3() {
51   * 	}
52   * 
53   * 	&#064;Path(&quot;/{id}/edit&quot;)
54   * 	// {id}部分を要求パラメータに追加。
55   *  // {id}部分の正規表現は省略されているためデフォルトの「[0-9a-zA-Z]+」。
56   *  // priority(優先度)はデフォルト値の「Integer.MAX_VALUE」。
57   * 	public ActionResult m4() {
58   * 	}
59   * 
60   * 	&#064;Path(&quot;/{userId,[a-z]+}/edit&quot;, priprity=0)
61   * 	// {userId}部分を要求パラメータに追加。
62   *  // {userId}部分の正規表現は「[a-z]+」のため小文字アルファベットのみ。
63   *  // priority(優先度)は「0」のため、m4メソッドよりも先に適用される。
64   * 	public ActionResult m5() {
65   * 	}
66   * }
67   * 
68   * &#064;Path(&quot;/&quot;)
69   * public class RootAction {
70   * 	// -&gt; &quot;/&quot;
71   * 	public ActionResult index() {
72   * 	}
73   * 
74   * 	// -&gt; &quot;/m1&quot;
75   * 	public ActionResult m1() {
76   * 	}
77   * 
78   * 	&#064;Path(&quot;list&quot;)
79   * 	// -&gt; &quot;/list&quot;
80   * 	public ActionResult m2() {
81   * 	}
82   * 
83   * 	&#064;Path(&quot;/xxx/yyy&quot;)
84   * 	// -&gt; &quot;/xxx/yyy&quot;
85   * 	public ActionResult m3() {
86   * 	}
87   * }
88   * </pre>
89   * 
90   * </p>
91   * 
92   * @author agata
93   * @author baba
94   */
95  @Retention(RetentionPolicy.RUNTIME)
96  @Target( { ElementType.METHOD, ElementType.TYPE })
97  public @interface Path {
98  
99  	/**
100 	 * アクションメソッドのバインディング用パスを指定します。
101 	 * <p>
102 	 * URLはアクションクラスのパス+アクションメソッドのパスで決定されます。
103 	 * ただし、先頭が『/』の場合コンテキストルートからの絶対パスとして解釈されます。
104 	 * </p>
105 	 * <p>
106 	 * {パラメータ名,正規表現}でプレースホルダーの指定ができます。
107 	 * </p>
108 	 * <p>
109 	 * 正規表現にマッチした場合、マッチした箇所が指定されたパラメータ名に追加され、アクションメソッドが実行されます。
110 	 * 正規表現は省略可能です。省略した場合「[a-zA-Z0-9]+」と同じ意味になります。
111 	 * </p>
112 	 * <p>
113 	 * アクションメソッドのパスは「パスの正規表現+{@link Accept 要求メソッド}」で一意に特定できなければいけません。
114 	 * 実行時に重複が発見されると例外が発生します。
115 	 * </p>
116 	 * 
117 	 * @return アクションメソッドのバインディング用パス
118 	 * @see Accept
119 	 */
120 	String value() default "";
121 
122 	/**
123 	 * アクションメソッドのバインディング時の優先度を設定します。
124 	 * <p>
125 	 * この値が小さいほど、優先度が高く先に適用されます。デフォルト値は{@link Integer#MAX_VALUE}です。
126 	 * </p>
127 	 * <p>
128 	 * 手動でバインディングの設定が追加された場合、優先度は0から順番に振られます。手動追加よりも自動設定の優先度を上げたい場合は、
129 	 * 負の値を設定してください。
130 	 * </p>
131 	 * 
132 	 * @return アクションメソッドのバインディング時の優先度
133 	 */
134 	int priority() default Integer.MAX_VALUE;
135 
136 }