Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CubbyServlet |
|
| 1.4;1.4 |
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.servlet; | |
18 | ||
19 | import java.io.IOException; | |
20 | ||
21 | import javax.servlet.GenericServlet; | |
22 | import javax.servlet.ServletConfig; | |
23 | import javax.servlet.ServletException; | |
24 | import javax.servlet.ServletRequest; | |
25 | import javax.servlet.ServletResponse; | |
26 | ||
27 | import org.seasar.cubby.internal.plugin.PluginManager; | |
28 | import org.seasar.cubby.plugin.PluginRegistry; | |
29 | ||
30 | /** | |
31 | * プラグインの初期化などを行う <code>Servlet</code> です。 | |
32 | * | |
33 | * @author baba | |
34 | */ | |
35 | public class CubbyServlet extends GenericServlet { | |
36 | ||
37 | /** シリアルバージョン UID。 */ | |
38 | private static final long serialVersionUID = 1L; | |
39 | ||
40 | /** プラグインマネージャ。 */ | |
41 | private transient PluginManager pluginManager; | |
42 | ||
43 | /** | |
44 | * サーブレットをインスタンス化します。 | |
45 | */ | |
46 | public CubbyServlet() { | |
47 | 1 | super(); |
48 | 1 | } |
49 | ||
50 | /** | |
51 | * {@inheritDoc} | |
52 | * <p> | |
53 | * プラグインの初期化とレジストリへの登録を行います。 | |
54 | * </p> | |
55 | */ | |
56 | @Override | |
57 | public void init(final ServletConfig config) throws ServletException { | |
58 | 1 | super.init(config); |
59 | 1 | pluginManager = buildPluginManager(); |
60 | try { | |
61 | 1 | pluginManager.init(config.getServletContext()); |
62 | 0 | } catch (final Exception e) { |
63 | 0 | throw new ServletException(e); |
64 | 1 | } |
65 | 1 | } |
66 | ||
67 | /** | |
68 | * {@inheritDoc} | |
69 | * <p> | |
70 | * プラグインの破棄を行います。 | |
71 | * </p> | |
72 | * | |
73 | * @see PluginManager#destroy() | |
74 | */ | |
75 | @Override | |
76 | public void destroy() { | |
77 | 1 | super.destroy(); |
78 | 1 | pluginManager.destroy(); |
79 | 1 | } |
80 | ||
81 | /** | |
82 | * {@inheritDoc} | |
83 | */ | |
84 | @Override | |
85 | public void service(final ServletRequest req, final ServletResponse res) | |
86 | throws ServletException, IOException { | |
87 | // do nothing | |
88 | 0 | } |
89 | ||
90 | /** | |
91 | * プラグインマネージャを構築します。 | |
92 | * | |
93 | * @return プラグインマネージャ | |
94 | */ | |
95 | protected PluginManager buildPluginManager() { | |
96 | 0 | return new PluginManager(PluginRegistry.getInstance()); |
97 | } | |
98 | ||
99 | } |