Coverage Report - org.seasar.cubby.controller.impl.CubbyConfigurationImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CubbyConfigurationImpl
100%
14/14
67%
4/6
2.5
 
 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.framework.container.ComponentDef;
 22  
 import org.seasar.framework.container.S2Container;
 23  
 import org.seasar.framework.log.Logger;
 24  
 
 25  
 /**
 26  
  * Cubby の全体的な設定情報の実装です。
 27  
  * 
 28  
  * @author baba
 29  
  * @since 1.0.0
 30  
  */
 31  
 public class CubbyConfigurationImpl implements CubbyConfiguration {
 32  
 
 33  
         /** ロガー。 */
 34  1
         private static final Logger logger = Logger
 35  
                         .getLogger(CubbyConfiguration.class);
 36  
 
 37  
         /** フォーマットパターン。 */
 38  
         private final FormatPattern formatPattern;
 39  
 
 40  
         /**
 41  
          * {@inheritDoc}
 42  
          */
 43  
         public FormatPattern getFormatPattern() {
 44  78
                 return formatPattern;
 45  
         }
 46  
 
 47  
         /**
 48  
          * インスタンス化します。
 49  
          * <p>
 50  
          * 指定されたコンテナのルートから設定情報のインスタンスを取得します。
 51  
          * </p>
 52  
          * 
 53  
          * @param container
 54  
          *            コンテナ
 55  
          */
 56  79
         public CubbyConfigurationImpl(final S2Container container) {
 57  79
                 final S2Container root = container.getRoot();
 58  
 
 59  78
                 if (root.hasComponentDef(FormatPattern.class)) {
 60  16
                         final ComponentDef componentDef = root
 61  
                                         .getComponentDef(FormatPattern.class);
 62  16
                         this.formatPattern = (FormatPattern) componentDef.getComponent();
 63  16
                         if (logger.isDebugEnabled()) {
 64  16
                                 logger.log("DCUB0009", new Object[] { FormatPattern.class,
 65  
                                                 this.formatPattern });
 66  
                         }
 67  16
                 } else {
 68  62
                         this.formatPattern = new FormatPatternImpl();
 69  62
                         if (logger.isDebugEnabled()) {
 70  62
                                 logger.log("DCUB0008", new Object[] { FormatPattern.class,
 71  
                                                 this.formatPattern });
 72  
                         }
 73  
                 }
 74  
 
 75  78
         }
 76  
 
 77  
 }