Coverage Report - org.apache.myfaces.spi.ServiceProviderFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceProviderFinder
0%
0/5
N/A
1
 
 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.spi;
 20  
 
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 import java.util.ServiceLoader;
 24  
 import javax.faces.FactoryFinder;
 25  
 import javax.faces.context.ExternalContext;
 26  
 
 27  
 /**
 28  
  * This class provides an interface to override SPI handling done by
 29  
  * MyFaces.
 30  
  * 
 31  
  * This is useful on environments like in OSGi, because it allows to
 32  
  * put custom code to find SPI interfaces under META-INF/services/
 33  
  * 
 34  
  * @author Leonardo Uribe
 35  
  * @since 2.0.3
 36  
  *
 37  
  */
 38  0
 public abstract class ServiceProviderFinder
 39  
 {
 40  0
     public static final String[] KNOWN_SERVICES = 
 41  
     {
 42  
         FactoryFinder.APPLICATION_FACTORY,
 43  
         FactoryFinder.CLIENT_WINDOW_FACTORY,
 44  
         FactoryFinder.EXCEPTION_HANDLER_FACTORY,
 45  
         FactoryFinder.EXTERNAL_CONTEXT_FACTORY,
 46  
         FactoryFinder.FACELET_CACHE_FACTORY,
 47  
         FactoryFinder.FACES_CONTEXT_FACTORY,
 48  
         FactoryFinder.FLASH_FACTORY,
 49  
         FactoryFinder.FLOW_HANDLER_FACTORY,
 50  
         FactoryFinder.LIFECYCLE_FACTORY,
 51  
         FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY,
 52  
         FactoryFinder.RENDER_KIT_FACTORY,
 53  
         FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY,
 54  
         FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
 55  
         FactoryFinder.VISIT_CONTEXT_FACTORY,
 56  
         "org.apache.myfaces.spi.AnnotationProvider",
 57  
         "org.apache.myfaces.spi.AnnotationProviderFactory",
 58  
         "org.apache.myfaces.spi.FaceletConfigResourceProvider",
 59  
         "org.apache.myfaces.spi.FaceletConfigResourceProviderFactory",
 60  
         "org.apache.myfaces.spi.FacesConfigResourceProvider",
 61  
         "org.apache.myfaces.spi.FacesConfigResourceProviderFactory",
 62  
         "org.apache.myfaces.spi.FacesConfigurationMerger",
 63  
         "org.apache.myfaces.spi.FacesConfigurationMergerFactory",
 64  
         "org.apache.myfaces.spi.FacesConfigurationProvider",
 65  
         "org.apache.myfaces.spi.FacesConfigurationProviderFactory",
 66  
         "org.apache.myfaces.spi.FacesFlowProvider",
 67  
         "org.apache.myfaces.spi.FacesFlowProviderFactory",
 68  
         "org.apache.myfaces.spi.FactoryFinderProvider",
 69  
         "org.apache.myfaces.spi.FactoryFinderProviderFactory",
 70  
         "org.apache.myfaces.spi.InjectionProvider",
 71  
         "org.apache.myfaces.spi.InjectionProviderFactory",
 72  
         "org.apache.myfaces.spi.ResourceLibraryContractsProvider",
 73  
         "org.apache.myfaces.spi.ResourceLibraryContractsProviderFactory",
 74  
         "org.apache.myfaces.spi.ViewScopeProvider",
 75  
         "org.apache.myfaces.spi.ViewScopeProviderFactory",
 76  
         "org.apache.myfaces.spi.WebConfigProvider",
 77  
         "org.apache.myfaces.spi.WebConfigProviderFactory",
 78  
         "org.apache.myfaces.config.annotation.LifecycleProvider",
 79  
         "org.apache.myfaces.config.annotation.LifecycleProviderFactory",
 80  
     };
 81  
     
 82  
     /**
 83  
      * Gets the list of classes bound to the spiClass key, looking
 84  
      * for entries under META-INF/services/[spiClass]
 85  
      * 
 86  
      * @param spiClass
 87  
      * @return
 88  
      */
 89  
     public abstract List<String> getServiceProviderList(String spiClass);
 90  
     
 91  
     public <S> ServiceLoader<S> load(Class<S> spiClass)
 92  
     {
 93  0
         return ServiceLoader.load(spiClass);
 94  
     }
 95  
     
 96  
     /**
 97  
      * If ServiceProviderFinderFactory knows beforehand or has stored somewhere the
 98  
      * known locations of the SPI interfaces, this method helps to set this config
 99  
      * information so the implementation of this interface can use it. The idea is
 100  
      * MyFaces initialization algorithm will call getKnownServiceProviderMapInfo
 101  
      * method and if the value is not null it will call this method to pass the
 102  
      * map back to the ServiceProviderFinder, so it can take it.
 103  
      * 
 104  
      * @param map 
 105  
      */
 106  
     public void initKnownServiceProviderMapInfo(ExternalContext ectx, Map<String, List<String>> map)
 107  
     {
 108  0
     }
 109  
 
 110  
     public Map<String, List<String>> calculateKnownServiceProviderMapInfo(ExternalContext ectx, 
 111  
         String[] knownServices)
 112  
     {
 113  
         //Map<String, List<String>> map = new HashMap<String, List<String>>();
 114  
         //for (String service : knownServices)
 115  
         //{
 116  
         //    map.put(service, this.getServiceProviderList(service));
 117  
         //}
 118  
         //return map;
 119  0
         return null;
 120  
     }
 121  
 }