Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Path |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright 2004-2009 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 | package org.seasar.cubby.action; | |
17 | ||
18 | import java.lang.annotation.ElementType; | |
19 | import java.lang.annotation.Retention; | |
20 | import java.lang.annotation.RetentionPolicy; | |
21 | import java.lang.annotation.Target; | |
22 | ||
23 | /** | |
24 | * アクションメソッドのパス。 | |
25 | * <p> | |
26 | * アクションメソッドを起動するためのパスを指定するアノテーションです。 | |
27 | * </p> | |
28 | * <p> | |
29 | * 使用例 | |
30 | * | |
31 | * <pre> | |
32 | * @Path("fuga") | |
33 | * public class HogeAction { | |
34 | * // -> "/fuga/index" | |
35 | * public ActionResult index() { | |
36 | * } | |
37 | * | |
38 | * // -> "/fuga/m1" | |
39 | * public ActionResult m1() { | |
40 | * } | |
41 | * | |
42 | * @Path("list") | |
43 | * // -> "/fuga/list" | |
44 | * public ActionResult m2() { | |
45 | * } | |
46 | * | |
47 | * @Path("/xxx/yyy") | |
48 | * // -> "/xxx/yyy" | |
49 | * public ActionResult m3() { | |
50 | * } | |
51 | * | |
52 | * @Path("/{id}/edit") | |
53 | * // {id}部分を要求パラメータに追加。 | |
54 | * // {id}部分の正規表現は省略されているためデフォルトの「[0-9a-zA-Z]+」。 | |
55 | * // priority(優先度)はデフォルト値の「Integer.MAX_VALUE」。 | |
56 | * public ActionResult m4() { | |
57 | * } | |
58 | * | |
59 | * @Path("/{userId,[a-z]+}/edit", priprity=0) | |
60 | * // {userId}部分を要求パラメータに追加。 | |
61 | * // {userId}部分の正規表現は「[a-z]+」のため小文字アルファベットのみ。 | |
62 | * // priority(優先度)は「0」のため、m4メソッドよりも先に適用される。 | |
63 | * public ActionResult m5() { | |
64 | * } | |
65 | * } | |
66 | * | |
67 | * @Path("/") | |
68 | * public class RootAction { | |
69 | * // -> "/" | |
70 | * public ActionResult index() { | |
71 | * } | |
72 | * | |
73 | * // -> "/m1" | |
74 | * public ActionResult m1() { | |
75 | * } | |
76 | * | |
77 | * @Path("list") | |
78 | * // -> "/list" | |
79 | * public ActionResult m2() { | |
80 | * } | |
81 | * | |
82 | * @Path("/xxx/yyy") | |
83 | * // -> "/xxx/yyy" | |
84 | * public ActionResult m3() { | |
85 | * } | |
86 | * } | |
87 | * </pre> | |
88 | * | |
89 | * </p> | |
90 | * | |
91 | * @author agata | |
92 | * @author baba | |
93 | */ | |
94 | @Retention(RetentionPolicy.RUNTIME) | |
95 | @Target( { ElementType.METHOD, ElementType.TYPE }) | |
96 | public @interface Path { | |
97 | ||
98 | /** | |
99 | * アクションメソッドのバインディング用パスを指定します。 | |
100 | * <p> | |
101 | * URLはアクションクラスのパス+アクションメソッドのパスで決定されます。 | |
102 | * ただし、先頭が『/』の場合コンテキストルートからの絶対パスとして解釈されます。 | |
103 | * </p> | |
104 | * <p> | |
105 | * {パラメータ名,正規表現}でプレースホルダーの指定ができます。 | |
106 | * </p> | |
107 | * <p> | |
108 | * 正規表現にマッチした場合、マッチした箇所が指定されたパラメータ名に追加され、アクションメソッドが実行されます。 | |
109 | * 正規表現は省略可能です。省略した場合「[a-zA-Z0-9]+」と同じ意味になります。 | |
110 | * </p> | |
111 | * <p> | |
112 | * アクションメソッドのパスは「パスの正規表現+{@link Accept 要求メソッド}」で一意に特定できなければいけません。 | |
113 | * 実行時に重複が発見されると例外が発生します。 | |
114 | * </p> | |
115 | * | |
116 | * @return アクションメソッドのバインディング用パス | |
117 | * @see Accept | |
118 | */ | |
119 | String value() default ""; | |
120 | ||
121 | /** | |
122 | * アクションメソッドのバインディング時の優先度を設定します。 | |
123 | * <p> | |
124 | * この値が小さいほど、優先度が高く先に適用されます。デフォルト値は{@link Integer#MAX_VALUE}です。 | |
125 | * </p> | |
126 | * <p> | |
127 | * 手動でバインディングの設定が追加された場合、優先度は0から順番に振られます。手動追加よりも自動設定の優先度を上げたい場合は、 | |
128 | * 負の値を設定してください。 | |
129 | * </p> | |
130 | * | |
131 | * @return アクションメソッドのバインディング時の優先度 | |
132 | */ | |
133 | int priority() default Integer.MAX_VALUE; | |
134 | ||
135 | } |