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