Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractPlugin |
|
| 1.0;1 |
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.LinkedHashSet; | |
19 | import java.util.Set; | |
20 | ||
21 | import javax.servlet.ServletContext; | |
22 | ||
23 | import org.seasar.cubby.action.ActionResult; | |
24 | import org.seasar.cubby.routing.PathInfo; | |
25 | import org.seasar.cubby.spi.Provider; | |
26 | ||
27 | /** | |
28 | * プラグインの抽象的な実装です。 | |
29 | * | |
30 | * @author baba | |
31 | */ | |
32 | 137 | public abstract class AbstractPlugin implements Plugin { |
33 | ||
34 | /** プラグインがサポートするサービスのセット。 */ | |
35 | 137 | private final Set<Class<? extends Provider>> supportedServices = new LinkedHashSet<Class<? extends Provider>>(); |
36 | ||
37 | /** | |
38 | * プラグインがサポートするサービスを追加します。 | |
39 | * | |
40 | * @param service | |
41 | * サービス | |
42 | */ | |
43 | protected void support(final Class<? extends Provider> service) { | |
44 | 1 | supportedServices.add(service); |
45 | 1 | } |
46 | ||
47 | /** | |
48 | * このプラグインが指定されたサービスをサポートするかを示します。 | |
49 | * | |
50 | * @param service | |
51 | * サービス | |
52 | * @return このプラグインが指定されたサービスをサポートする場合は <code>true</code>、そうでない場合は | |
53 | * <code>false</code> | |
54 | */ | |
55 | protected boolean isSupport(final Class<? extends Provider> service) { | |
56 | 0 | return supportedServices.contains(service); |
57 | } | |
58 | ||
59 | /** | |
60 | * {@inheritDoc} | |
61 | */ | |
62 | public void initialize(final ServletContext servletContext) | |
63 | throws Exception { | |
64 | 1 | } |
65 | ||
66 | /** | |
67 | * {@inheritDoc} | |
68 | */ | |
69 | public Set<Class<? extends Provider>> getSupportedServices() { | |
70 | 1 | return supportedServices; |
71 | } | |
72 | ||
73 | /** | |
74 | * {@inheritDoc} | |
75 | */ | |
76 | public <S extends Provider> S getProvider(final Class<S> service) { | |
77 | 0 | return null; |
78 | } | |
79 | ||
80 | /** | |
81 | * {@inheritDoc} | |
82 | */ | |
83 | public void ready() throws Exception { | |
84 | 1 | } |
85 | ||
86 | /** | |
87 | * {@inheritDoc} | |
88 | */ | |
89 | public void destroy() { | |
90 | 1 | } |
91 | ||
92 | /** | |
93 | * {@inheritDoc} | |
94 | */ | |
95 | public PathInfo invokeRouting(final RoutingInvocation invocation) | |
96 | throws Exception { | |
97 | 1 | return invocation.proceed(); |
98 | } | |
99 | ||
100 | /** | |
101 | * {@inheritDoc} | |
102 | */ | |
103 | public void invokeRequestProcessing( | |
104 | final RequestProcessingInvocation invocation) throws Exception { | |
105 | 1 | invocation.proceed(); |
106 | 1 | } |
107 | ||
108 | /** | |
109 | * {@inheritDoc} | |
110 | */ | |
111 | public ActionResult invokeAction(final ActionInvocation invocation) | |
112 | throws Exception { | |
113 | 1 | return invocation.proceed(); |
114 | } | |
115 | ||
116 | /** | |
117 | * {@inheritDoc} | |
118 | */ | |
119 | public void invokeActionResult(final ActionResultInvocation invocation) | |
120 | throws Exception { | |
121 | 1 | invocation.proceed(); |
122 | 1 | } |
123 | ||
124 | } |