Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Plugin |
|
| 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.plugin; | |
17 | ||
18 | import java.util.Set; | |
19 | ||
20 | import javax.servlet.ServletContext; | |
21 | ||
22 | import org.seasar.cubby.action.ActionResult; | |
23 | import org.seasar.cubby.spi.Provider; | |
24 | ||
25 | /** | |
26 | * プラグインを表すインターフェイスです。 | |
27 | * <p> | |
28 | * プラグインは所属する Web アプリケーションのサーブレットに対する変更の通知を受け取ることができます。 | |
29 | * </p> | |
30 | * | |
31 | * @author baba | |
32 | */ | |
33 | public interface Plugin { | |
34 | ||
35 | // プラグインのライフサイクル | |
36 | ||
37 | /** | |
38 | * <code>CubbyFilter</code> がサービスを提供できるようになった時に実行されます。 | |
39 | * | |
40 | * @param servletContext | |
41 | * 呼び出し元が現在実行している {@link ServletContext} への参照 | |
42 | * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) | |
43 | */ | |
44 | void initialize(ServletContext servletContext); | |
45 | ||
46 | /** | |
47 | * このプラグインが提供するサービスプロバイダを取得します。 | |
48 | * <p> | |
49 | * このプラグインが指定されたサービスを提供しない場合は <code>null</code> を返します。 | |
50 | * </p> | |
51 | * | |
52 | * @param <S> | |
53 | * サービスの型 | |
54 | * @param service | |
55 | * サービス | |
56 | * @return サービスプロバイダ | |
57 | */ | |
58 | <S extends Provider> S getProvider(Class<S> service); | |
59 | ||
60 | /** | |
61 | * このプラグインが提供するサービスプロバイダのセットを返します。 | |
62 | * | |
63 | * @return このプラグインが提供するサービスプロバイダのセット | |
64 | */ | |
65 | Set<Class<? extends Provider>> getSupportedServices(); | |
66 | ||
67 | /** | |
68 | * プラグインの準備が完了した時に実行されます。 | |
69 | */ | |
70 | void ready(); | |
71 | ||
72 | /** | |
73 | * <code>CubbyFilter</code> がサービス提供を 停止するときに実行されます。 | |
74 | * | |
75 | * @see javax.servlet.Filter#destroy() | |
76 | */ | |
77 | void destroy(); | |
78 | ||
79 | // サーブレット要求の処理 | |
80 | ||
81 | /** | |
82 | * 要求に対する処理を実行します。 | |
83 | * <p> | |
84 | * このメソッドをオーバーライドすることで、要求に対する処理の実行をインターセプトすることができます。 | |
85 | * </p> | |
86 | * <p> | |
87 | * このメソッド内で {@link RequestProcessingInvocation#proceed()} | |
88 | * メソッドを実行することで、別のプラグインの | |
89 | * {@link #invokeRequestProcessing(RequestProcessingInvocation)} | |
90 | * または要求に対する処理が実行されます。 | |
91 | * </p> | |
92 | * | |
93 | * @param invocation | |
94 | * 要求に対する処理の実行情報 | |
95 | * @throws Exception | |
96 | * 要求に対する処理の実行時に例外が発生した場合 | |
97 | */ | |
98 | void invokeRequestProcessing(RequestProcessingInvocation invocation) | |
99 | throws Exception; | |
100 | ||
101 | /** | |
102 | * アクションメソッドを実行します。 | |
103 | * <p> | |
104 | * このメソッドをオーバーライドすることで、アクションメソッドの実行をインターセプトすることができます。 | |
105 | * </p> | |
106 | * <p> | |
107 | * このメソッド内で {@link ActionInvocation#proceed()} メソッドを実行することで、別のプラグインの | |
108 | * {@link #invokeAction(ActionInvocation)} またはアクションメソッドが実行されます。 | |
109 | * </p> | |
110 | * | |
111 | * @param invocation | |
112 | * アクションメソッドの実行情報 | |
113 | * @return アクションの実行結果 | |
114 | * @throws Exception | |
115 | * アクションメソッドの実行時に例外が発生した場合 | |
116 | */ | |
117 | ActionResult invokeAction(ActionInvocation invocation) throws Exception; | |
118 | ||
119 | /** | |
120 | * アクションの実行結果を実行します。 | |
121 | * <p> | |
122 | * このメソッドをオーバーライドすることで、アクションの実行結果の実行をインターセプトすることができます。 | |
123 | * </p> | |
124 | * <p> | |
125 | * このメソッド内で {@link ActionResultInvocation#proceed()} メソッドを実行することで、別のプラグインの | |
126 | * {@link #invokeActionResult(ActionResultInvocation)} またはアクションの実行結果が実行されます。 | |
127 | * </p> | |
128 | * | |
129 | * @param invocation | |
130 | * アクションの実行結果の実行情報 | |
131 | * @throws Exception | |
132 | * アクションの実行結果の実行時に例外が発生した場合 | |
133 | */ | |
134 | void invokeActionResult(ActionResultInvocation invocation) throws Exception; | |
135 | ||
136 | } |