Coverage Report - org.seasar.cubby.controller.impl.CubbyConfigurationImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CubbyConfigurationImpl
100%
25/25
67%
8/12
3
 
 1  
 /*
 2  
  * Copyright 2004-2008 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.controller.impl;
 17  
 
 18  
 import org.seasar.cubby.action.FormatPattern;
 19  
 import org.seasar.cubby.action.impl.FormatPatternImpl;
 20  
 import org.seasar.cubby.controller.CubbyConfiguration;
 21  
 import org.seasar.cubby.controller.RequestParser;
 22  
 import org.seasar.framework.container.ComponentDef;
 23  
 import org.seasar.framework.container.S2Container;
 24  
 import org.seasar.framework.log.Logger;
 25  
 
 26  
 /**
 27  
  * 
 28  
  * @author baba
 29  
  * 
 30  
  */
 31  
 public class CubbyConfigurationImpl implements CubbyConfiguration {
 32  
 
 33  1
         private static final Logger logger = Logger
 34  
                         .getLogger(CubbyConfiguration.class);
 35  
 
 36  1
         private static final RequestParser DEFAULT_REQUEST_PARSER = new DefaultRequestParserImpl();
 37  
 
 38  
         private final RequestParser requestParser;
 39  
 
 40  
         private final FormatPattern formatPattern;
 41  
 
 42  
         public RequestParser getRequestParser() {
 43  8
                 return requestParser;
 44  
         }
 45  
 
 46  
         public FormatPattern getFormatPattern() {
 47  78
                 return formatPattern;
 48  
         }
 49  
 
 50  42
         public CubbyConfigurationImpl(final S2Container container) {
 51  42
                 final S2Container root = container.getRoot();
 52  
 
 53  41
                 if (root.hasComponentDef(RequestParser.class)) {
 54  12
                         final ComponentDef componentDef = root
 55  
                                         .getComponentDef(RequestParser.class);
 56  12
                         this.requestParser = (RequestParser) componentDef.getComponent();
 57  12
                         if (logger.isDebugEnabled()) {
 58  12
                                 logger.log("DCUB0009", new Object[] { RequestParser.class,
 59  
                                                 this.requestParser });
 60  
                         }
 61  12
                 } else {
 62  29
                         this.requestParser = DEFAULT_REQUEST_PARSER;
 63  29
                         if (logger.isDebugEnabled()) {
 64  29
                                 logger.log("DCUB0008", new Object[] { RequestParser.class,
 65  
                                                 this.requestParser });
 66  
                         }
 67  
                 }
 68  
 
 69  41
                 if (root.hasComponentDef(FormatPattern.class)) {
 70  12
                         final ComponentDef componentDef = root
 71  
                                         .getComponentDef(FormatPattern.class);
 72  12
                         this.formatPattern = (FormatPattern) componentDef.getComponent();
 73  12
                         if (logger.isDebugEnabled()) {
 74  12
                                 logger.log("DCUB0009", new Object[] { FormatPattern.class,
 75  
                                                 this.formatPattern });
 76  
                         }
 77  12
                 } else {
 78  29
                         this.formatPattern = new FormatPatternImpl();
 79  29
                         if (logger.isDebugEnabled()) {
 80  29
                                 logger.log("DCUB0008", new Object[] { FormatPattern.class,
 81  
                                                 this.formatPattern });
 82  
                         }
 83  
                 }
 84  
 
 85  41
         }
 86  
 
 87  
 }