##### Coverage Report - org.seasar.cubby.servlet.CubbyServlet

Classes in this File | Line Coverage | Branch Coverage | Complexity
CubbyServlet |
71% | 10/14
N/A | N/A
| 1.4;1.4

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