Coverage Report - org.seasar.teeda.core.config.faces.impl.ConfigFilesFacesConfigurator
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigFilesFacesConfigurator
90%
19/21
67%
4/6
2.333
 
 1  
 /*
 2  
  * Copyright 2004-2011 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.teeda.core.config.faces.impl;
 17  
 
 18  
 import java.io.InputStream;
 19  
 import java.util.LinkedList;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.faces.internal.FacesConfigOptions;
 23  
 
 24  
 import org.seasar.framework.container.factory.WebResourceResolver;
 25  
 import org.seasar.framework.log.Logger;
 26  
 import org.seasar.framework.util.InputStreamUtil;
 27  
 import org.seasar.framework.util.StringUtil;
 28  
 import org.seasar.framework.xml.SaxHandlerParser;
 29  
 import org.seasar.teeda.core.config.faces.AbstractFacesConfigurator;
 30  
 import org.seasar.teeda.core.config.faces.element.FacesConfig;
 31  
 
 32  
 /**
 33  
  * @author shot
 34  
  */
 35  
 public class ConfigFilesFacesConfigurator extends AbstractFacesConfigurator {
 36  
 
 37  1
     private static final Logger logger_ = Logger
 38  1
             .getLogger(ConfigFilesFacesConfigurator.class);
 39  
 
 40  
     private static final String FACES_CONFIG_DELIMETER = ",";
 41  
 
 42  1
     public ConfigFilesFacesConfigurator() {
 43  1
         setResourceResolver(new WebResourceResolver());
 44  1
     }
 45  
 
 46  
     public FacesConfig configure() {
 47  1
         List configs = new LinkedList();
 48  1
         String path = getPath();
 49  1
         if (logger_.isDebugEnabled()) {
 50  0
             logger_.debug("target file path = " + path);
 51  
         }
 52  1
         if (path == null) {
 53  0
             return null;
 54  
         }
 55  1
         String[] paths = StringUtil.split(path, FACES_CONFIG_DELIMETER);
 56  
 
 57  3
         for (int i = 0; i < paths.length; i++) {
 58  2
             final String targetPath = paths[i];
 59  2
             final SaxHandlerParser parser = createSaxHandlerParser();
 60  2
             InputStream is = resourceResolver_
 61  
                     .getInputStream(targetPath.trim());
 62  
             try {
 63  2
                 configs.add(parser.parse(is, targetPath));
 64  
             } finally {
 65  2
                 InputStreamUtil.close(is);
 66  2
             }
 67  
         }
 68  1
         return FacesConfigUtil.collectAllFacesConfig(configs);
 69  
     }
 70  
 
 71  
     public String getPath() {
 72  1
         return FacesConfigOptions.getConfigFiles();
 73  
     }
 74  
 }