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.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  public abstract class AbstractPlugin implements Plugin {
34  
35  	/** プラグインがサポートするサービスのセット。 */
36  	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  		supportedServices.add(service);
46  	}
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  		return supportedServices.contains(service);
58  	}
59  
60  	/**
61  	 * {@inheritDoc}
62  	 */
63  	public void initialize(final ServletContext servletContext)
64  			throws Exception {
65  	}
66  
67  	/**
68  	 * {@inheritDoc}
69  	 */
70  	public Set<Class<? extends Provider>> getSupportedServices() {
71  		return supportedServices;
72  	}
73  
74  	/**
75  	 * {@inheritDoc}
76  	 */
77  	public <S extends Provider> S getProvider(final Class<S> service) {
78  		return null;
79  	}
80  
81  	/**
82  	 * {@inheritDoc}
83  	 */
84  	public void ready() throws Exception {
85  	}
86  
87  	/**
88  	 * {@inheritDoc}
89  	 */
90  	public void destroy() {
91  	}
92  
93  	/**
94  	 * {@inheritDoc}
95  	 */
96  	public PathInfo invokeRouting(final RoutingInvocation invocation)
97  			throws Exception {
98  		return invocation.proceed();
99  	}
100 
101 	/**
102 	 * {@inheritDoc}
103 	 */
104 	public void invokeRequestProcessing(
105 			final RequestProcessingInvocation invocation) throws Exception {
106 		invocation.proceed();
107 	}
108 
109 	/**
110 	 * {@inheritDoc}
111 	 */
112 	public ActionResult invokeAction(final ActionInvocation invocation)
113 			throws Exception {
114 		return invocation.proceed();
115 	}
116 
117 	/**
118 	 * {@inheritDoc}
119 	 */
120 	public ActionResult invokeValidation(final ValidationInvocation invocation)
121 			throws Exception {
122 		return invocation.proceed();
123 	}
124 
125 	/**
126 	 * {@inheritDoc}
127 	 */
128 	public void invokeActionResult(final ActionResultInvocation invocation)
129 			throws Exception {
130 		invocation.proceed();
131 	}
132 
133 }