Coverage Report - org.apache.myfaces.config.annotation.LifecycleProviderFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
LifecycleProviderFactory
0%
0/22
0%
0/6
2
LifecycleProviderFactory$1
0%
0/2
N/A
2
 
 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.config.annotation;
 20  
 
 21  
 import java.security.AccessController;
 22  
 import java.security.PrivilegedActionException;
 23  
 import java.util.Map;
 24  
 
 25  
 import javax.faces.FacesException;
 26  
 import javax.faces.context.ExternalContext;
 27  
 import javax.faces.context.FacesContext;
 28  
 
 29  
 import org.apache.myfaces.spi.impl.SpiUtils;
 30  
 
 31  
 
 32  
 
 33  0
 public abstract class LifecycleProviderFactory
 34  
 {
 35  0
     protected static final String FACTORY_DEFAULT = DefaultLifecycleProviderFactory.class.getName();
 36  
 
 37  0
     private static final String FACTORY_KEY = LifecycleProviderFactory.class.getName();
 38  
 
 39  
     public static LifecycleProviderFactory getLifecycleProviderFactory()
 40  
     {
 41  
         // Since we always provide a StartupFacesContext on initialization time, this is safe:
 42  0
         return getLifecycleProviderFactory(FacesContext.getCurrentInstance().getExternalContext());
 43  
     }
 44  
     
 45  
     public static LifecycleProviderFactory getLifecycleProviderFactory(ExternalContext ctx)
 46  
     {
 47  0
         Map<String, Object> applicationMap = ctx.getApplicationMap();
 48  0
         LifecycleProviderFactory instance = (LifecycleProviderFactory) applicationMap.get(FACTORY_KEY);
 49  0
         if (instance != null)
 50  
         {
 51  0
             return instance;
 52  
         }
 53  0
         LifecycleProviderFactory lpf = null;
 54  
         try
 55  
         {
 56  
 
 57  0
             if (System.getSecurityManager() != null)
 58  
             {
 59  0
                 final ExternalContext ectx = ctx; 
 60  0
                 lpf = (LifecycleProviderFactory)
 61  
                         AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Object>()
 62  0
                         {
 63  
                             public Object run() throws PrivilegedActionException
 64  
                             {
 65  0
                                 return SpiUtils.build(ectx,
 66  
                                         LifecycleProviderFactory.class,
 67  
                                         FACTORY_DEFAULT);
 68  
                             }
 69  
                         });
 70  0
             }
 71  
             else
 72  
             {
 73  0
                 lpf = (LifecycleProviderFactory) SpiUtils.build(ctx, LifecycleProviderFactory.class, FACTORY_DEFAULT);
 74  
             }
 75  
         }
 76  0
         catch (PrivilegedActionException pae)
 77  
         {
 78  0
             throw new FacesException(pae);
 79  0
         }
 80  0
         if (lpf != null)
 81  
         {
 82  0
             applicationMap.put(FACTORY_KEY, lpf);
 83  
         }
 84  0
         return lpf;
 85  
     }
 86  
 
 87  
 
 88  
     public static void setLifecycleProviderFactory(LifecycleProviderFactory instance)
 89  
     {
 90  0
         FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().put(FACTORY_KEY, instance);
 91  0
     }
 92  
 
 93  
     public abstract LifecycleProvider getLifecycleProvider(ExternalContext externalContext);
 94  
 
 95  
     public abstract void release();
 96  
 
 97  
 }