Coverage Report - org.seasar.teeda.core.config.faces.impl.MetaInfFacesConfigurator
 
Classes in this File Line Coverage Branch Coverage Complexity
MetaInfFacesConfigurator
96%
23/24
67%
4/6
1.75
 
 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.net.URL;
 20  
 import java.util.ArrayList;
 21  
 import java.util.Iterator;
 22  
 import java.util.List;
 23  
 
 24  
 import org.seasar.framework.log.Logger;
 25  
 import org.seasar.framework.util.ClassLoaderUtil;
 26  
 import org.seasar.framework.util.InputStreamUtil;
 27  
 import org.seasar.framework.util.URLUtil;
 28  
 import org.seasar.framework.xml.SaxHandlerParser;
 29  
 import org.seasar.teeda.core.JsfConstants;
 30  
 import org.seasar.teeda.core.config.faces.AbstractFacesConfigurator;
 31  
 import org.seasar.teeda.core.config.faces.element.FacesConfig;
 32  
 import org.seasar.teeda.core.util.IteratorUtil;
 33  
 
 34  
 /**
 35  
  * @author shot
 36  
  */
 37  
 public class MetaInfFacesConfigurator extends AbstractFacesConfigurator {
 38  
 
 39  1
     private static final Logger logger_ = Logger
 40  1
             .getLogger(MetaInfFacesConfigurator.class);
 41  
 
 42  1
     private String path_ = JsfConstants.WEB_INF_LIB;
 43  
 
 44  1
     public MetaInfFacesConfigurator() {
 45  1
     }
 46  
 
 47  
     public FacesConfig configure() {
 48  1
         String path = getPath();
 49  1
         if (logger_.isDebugEnabled()) {
 50  0
             logger_.debug("target file path = " + path);
 51  
         }
 52  1
         SaxHandlerParser parser = createSaxHandlerParser();
 53  1
         List list = new ArrayList();
 54  1
         ClassLoader loader = ClassLoaderUtil.getClassLoader(this.getClass());
 55  1
         for (Iterator itr = IteratorUtil.getResourcesIterator(loader,
 56  2
                 JsfConstants.FACES_CONFIG_RESOURCES); itr.hasNext();) {
 57  1
             URL url = (URL) itr.next();
 58  1
             if (url.toExternalForm().indexOf(path) != -1) {
 59  1
                 InputStream is = URLUtil.openStream(url);
 60  
                 try {
 61  1
                     FacesConfig config = (FacesConfig) parser.parse(is, url
 62  
                             .toExternalForm());
 63  1
                     list.add(config);
 64  
                 } finally {
 65  1
                     InputStreamUtil.close(is);
 66  1
                 }
 67  
             }
 68  
         }
 69  1
         return FacesConfigUtil.collectAllFacesConfig(list);
 70  
     }
 71  
 
 72  
     public String getPath() {
 73  1
         return path_;
 74  
     }
 75  
 
 76  
     public void setPath(String path) {
 77  1
         path_ = path;
 78  1
     }
 79  
 }