Coverage Report - org.apache.myfaces.view.facelets.compiler.DefaultFaceletConfigResourceProvider
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultFaceletConfigResourceProvider
0%
0/18
0%
0/14
3.333
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.view.facelets.compiler;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.net.URL;
 23  
 import java.util.ArrayList;
 24  
 import java.util.Collection;
 25  
 import java.util.List;
 26  
 
 27  
 import javax.faces.context.ExternalContext;
 28  
 import org.apache.myfaces.shared.config.MyfacesConfig;
 29  
 
 30  
 import org.apache.myfaces.shared.util.ClassUtils;
 31  
 import org.apache.myfaces.spi.FaceletConfigResourceProvider;
 32  
 import org.apache.myfaces.util.ContainerUtils;
 33  
 import org.apache.myfaces.config.util.GAEUtils;
 34  
 import org.apache.myfaces.view.facelets.util.Classpath;
 35  
 
 36  
 /**
 37  
  * 
 38  
  * @since 2.0.2
 39  
  * @author Leonardo Uribe
 40  
  */
 41  
 public class DefaultFaceletConfigResourceProvider extends FaceletConfigResourceProvider
 42  
 {
 43  
     private static final String META_INF_PREFIX = "META-INF/";
 44  
 
 45  
     private static final String FACELET_TAGLIB_SUFFIX = ".taglib.xml";
 46  
 
 47  
     public DefaultFaceletConfigResourceProvider()
 48  
     {
 49  0
         super();
 50  0
     }
 51  
 
 52  
     @Override
 53  
     public Collection<URL> getFaceletTagLibConfigurationResources(
 54  
             ExternalContext context) throws IOException
 55  
     {
 56  0
         List<URL> urlSet = new ArrayList<URL>();
 57  
         
 58  0
         String jarFilesToScanParam = MyfacesConfig.getCurrentInstance(context).getGaeJsfJarFiles();
 59  0
         jarFilesToScanParam = jarFilesToScanParam != null ? jarFilesToScanParam.trim() : null;
 60  0
         if (ContainerUtils.isRunningOnGoogleAppEngine(context) && 
 61  
             jarFilesToScanParam != null &&
 62  
             jarFilesToScanParam.length() > 0)
 63  
         {
 64  0
             Collection<URL> urlsGAE = GAEUtils.searchInWebLib(
 65  
                     context, getClassLoader(), jarFilesToScanParam, META_INF_PREFIX, FACELET_TAGLIB_SUFFIX);
 66  0
             if (urlsGAE != null)
 67  
             {
 68  0
                 urlSet.addAll(urlsGAE);
 69  
             }
 70  0
         }
 71  
         else
 72  
         {
 73  
             //Scan files inside META-INF ending with .faces-config.xml
 74  0
             URL[] urls = Classpath.search(getClassLoader(), META_INF_PREFIX, FACELET_TAGLIB_SUFFIX);
 75  0
             for (int i = 0; i < urls.length; i++)
 76  
             {
 77  0
                 urlSet.add(urls[i]);
 78  
             }
 79  
         }
 80  0
         return urlSet;
 81  
     }
 82  
 
 83  
     private ClassLoader getClassLoader()
 84  
     {
 85  0
         ClassLoader loader = ClassUtils.getContextClassLoader();
 86  0
         if (loader == null)
 87  
         {
 88  0
             loader = this.getClass().getClassLoader();
 89  
         }
 90  0
         return loader;
 91  
     }
 92  
 }