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