Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 88 |  | Methods: | 6
| NCLOC: | 62 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
S2ContainerLoader.java | - | 0% | 0% | 0% |

1 |  |
     /*
2 |  |
      * brownies and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      *
5 |  |
      * Created on 2004/04/09 14:33:40
6 |  |
      */
7 |  |
     package org.asyrinx.brownie.seasar.servlet;
8 |  |
9 |  |
     import java.io.IOException;
10 |  |
     import java.io.InputStream;
11 |  |
12 |  |
     import javax.servlet.ServletContext;
13 |  |
     import javax.xml.parsers.SAXParser;
14 |  |
     import javax.xml.parsers.SAXParserFactory;
15 |  |
16 |  |
     import org.asyrinx.brownie.core.io.sf.StreamFactoryFacade;
17 |  |
     import org.asyrinx.brownie.servlet.FileNameResolver;
18 |  |
     import org.asyrinx.brownie.servlet.ServletContextRuntimeException;
19 |  |
     import org.seasar.framework.container.S2Container;
20 |  |
     import org.seasar.framework.container.factory.S2ContainerFactory;
21 |  |
     import org.seasar.framework.container.factory.S2ContainerTagHandlerRule;
22 |  |
     import org.seasar.framework.util.SAXParserFactoryUtil;
23 |  |
     import org.seasar.framework.xml.SaxHandler;
24 |  |
     import org.seasar.framework.xml.SaxHandlerParser;
25 |  |
26 |  |
     /**
27 |  |
      * @author akima
28 |  |
      */
29 |  |
     public class S2ContainerLoader {
30 |  |
31 |  |
         public static final String SERVLET_CONTEXT_PARAM_INITFILE = "s2config";
32 |  |
33 |  |
         public static final String SERVLET_CONTEXT_ATTRIBUTE_CONTAINER = S2ContainerLoader.class
34 |  |
                 .getName()
35 |  |
                 + ".container";
36 |  |
37 | 0 |
         public S2ContainerLoader(ServletContext context) {
38 | 0 |
             this.context = context;
39 | 0 |
             this.resolver = new FileNameResolver(this.context);
40 |  |
         }
41 |  |
42 |  |
         private final ServletContext context;
43 |  |
44 |  |
         private final FileNameResolver resolver;
45 |  |
46 | 0 |
         private SaxHandlerParser createSaxHandlerParser() {
47 | 0 |
             final SAXParserFactory factory = SAXParserFactoryUtil.newInstance();
48 | 0 |
             factory.setValidating(true);
49 | 0 |
             final SAXParser saxParser = SAXParserFactoryUtil.newSAXParser(factory);
50 | 0 |
             final SaxHandler handler = new SaxHandler(rule_);
51 | 0 |
             handler.registerDtdPath(S2ContainerFactory.PUBLIC_ID,
52 |  |
                     S2ContainerFactory.DTD_PATH);
53 | 0 |
             final SaxHandlerParser parser = new SaxHandlerParser(handler, saxParser);
54 | 0 |
             return parser;
55 |  |
         }
56 |  |
57 | 0 |
         public S2Container createContainer() throws IOException {
58 | 0 |
             final SaxHandlerParser parser = createSaxHandlerParser();
59 | 0 |
             final String webContextRealPath = resolver.getContextRootPath();
60 | 0 |
             final InputStream inputStream = StreamFactoryFacade.newFacade(
61 |  |
                     webContextRealPath).newInput(
62 |  |
                     context.getInitParameter(SERVLET_CONTEXT_PARAM_INITFILE));
63 | 0 |
             return (S2Container) parser.parse(inputStream);
64 |  |
         }
65 |  |
66 |  |
         private static S2ContainerTagHandlerRule rule_ = new S2ContainerTagHandlerRule();
67 |  |
68 |  |
         private S2Container container = null;
69 |  |
70 | 0 |
         public void initializeContainer() {
71 | 0 |
             try {
72 | 0 |
                 container = createContainer();
73 | 0 |
                 this.context.setAttribute(SERVLET_CONTEXT_ATTRIBUTE_CONTAINER,
74 |  |
                         container);
75 |  |
             } catch (IOException e) {
76 | 0 |
                 throw new ServletContextRuntimeException(e);
77 |  |
             }
78 |  |
         }
79 |  |
80 | 0 |
         public void finalizeContainer() {
81 | 0 |
             container.destroy();
82 |  |
         }
83 |  |
84 | 0 |
         public static S2Container getContainer(ServletContext context) {
85 | 0 |
             return (S2Container) context
86 |  |
                     .getAttribute(SERVLET_CONTEXT_ATTRIBUTE_CONTAINER);
87 |  |
         }
88 |  |
     }