Coverage Report - org.apache.myfaces.spi.FacesConfigResourceProviderFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
FacesConfigResourceProviderFactory
0%
0/20
0%
0/6
2.5
FacesConfigResourceProviderFactory$1
0%
0/2
N/A
2.5
 
 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.security.AccessController;
 22  
 import java.security.PrivilegedActionException;
 23  
 import java.security.PrivilegedExceptionAction;
 24  
 
 25  
 import javax.faces.FacesException;
 26  
 import javax.faces.context.ExternalContext;
 27  
 
 28  
 import org.apache.myfaces.spi.impl.DefaultFacesConfigResourceProviderFactory;
 29  
 import org.apache.myfaces.spi.impl.SpiUtils;
 30  
 
 31  
 /**
 32  
  * Factory that provide FacesConfigResourceProvider instances
 33  
  * 
 34  
  * @since 2.0.2
 35  
  * @author Leonardo Uribe
 36  
  */
 37  0
 public abstract class FacesConfigResourceProviderFactory
 38  
 {
 39  0
     protected static final String FACTORY_DEFAULT = DefaultFacesConfigResourceProviderFactory.class.getName();
 40  
 
 41  0
     private static final String FACTORY_KEY = FacesConfigResourceProviderFactory.class.getName();
 42  
 
 43  
     public static FacesConfigResourceProviderFactory getFacesConfigResourceProviderFactory(ExternalContext ctx)
 44  
     {
 45  0
         FacesConfigResourceProviderFactory instance
 46  
                 = (FacesConfigResourceProviderFactory) ctx.getApplicationMap().get(FACTORY_KEY);
 47  0
         if (instance != null)
 48  
         {
 49  0
             return instance;
 50  
         }
 51  0
         FacesConfigResourceProviderFactory lpf = null;
 52  
         try
 53  
         {
 54  
 
 55  0
             if (System.getSecurityManager() != null)
 56  
             {
 57  0
                 final ExternalContext ectx = ctx;
 58  0
                 lpf = (FacesConfigResourceProviderFactory)
 59  
                         AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
 60  0
                         {
 61  
                             public Object run() throws PrivilegedActionException
 62  
                             {
 63  0
                                 return SpiUtils.build(ectx,
 64  
                                         FacesConfigResourceProviderFactory.class,
 65  
                                         FACTORY_DEFAULT);
 66  
                             }
 67  
                         });
 68  0
             }
 69  
             else
 70  
             {
 71  0
                 lpf = (FacesConfigResourceProviderFactory)
 72  
                         SpiUtils.build(ctx, FacesConfigResourceProviderFactory.class, FACTORY_DEFAULT);
 73  
             }
 74  
         }
 75  0
         catch (PrivilegedActionException pae)
 76  
         {
 77  0
             throw new FacesException(pae);
 78  0
         }
 79  0
         if (lpf != null)
 80  
         {
 81  0
             setFacesConfigResourceProviderFactory(ctx, lpf);
 82  
         }
 83  0
         return lpf;
 84  
     }
 85  
 
 86  
     public static void setFacesConfigResourceProviderFactory(ExternalContext ctx,
 87  
                                                              FacesConfigResourceProviderFactory instance)
 88  
     {
 89  0
         ctx.getApplicationMap().put(FACTORY_KEY, instance);
 90  0
     }
 91  
 
 92  
     public abstract FacesConfigResourceProvider createFacesConfigResourceProvider(ExternalContext externalContext);
 93  
 }