Coverage Report - org.apache.myfaces.lifecycle.LifecycleFactoryImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
LifecycleFactoryImpl
0%
0/20
0%
0/4
0
 
 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.lifecycle;
 20  
 
 21  
 import javax.faces.FacesException;
 22  
 import javax.faces.lifecycle.Lifecycle;
 23  
 import javax.faces.lifecycle.LifecycleFactory;
 24  
 import java.util.HashMap;
 25  
 import java.util.Iterator;
 26  
 import java.util.Map;
 27  
 
 28  
 /**
 29  
  * @author Manfred Geiler (latest modification by $Author: mmarinschek $)
 30  
  * @author Anton Koinov
 31  
  * @version $Revision: 580395 $ $Date: 2007-09-28 10:51:56 -0500 (Fri, 28 Sep 2007) $
 32  
  */
 33  
 public class LifecycleFactoryImpl
 34  
         extends LifecycleFactory
 35  
 {
 36  0
     private final Map<String, Lifecycle> _lifecycles = new HashMap<String, Lifecycle>();
 37  
 
 38  
     public LifecycleFactoryImpl()
 39  0
     {
 40  0
         addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, new LifecycleImpl());
 41  0
     }
 42  
 
 43  
     public void purgeLifecycle()
 44  
     {        
 45  0
         _lifecycles.clear();
 46  0
         addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, new LifecycleImpl());
 47  0
     }
 48  
 
 49  
     public void addLifecycle(String id, Lifecycle lifecycle)
 50  
     {
 51  0
         synchronized (_lifecycles)
 52  
         {
 53  0
             if (_lifecycles.get(id) != null)
 54  
             {
 55  0
                 throw new IllegalArgumentException("Lifecycle with id '" + id + "' already exists.");
 56  
             }
 57  0
             _lifecycles.put(id, lifecycle);
 58  0
         }
 59  0
     }
 60  
 
 61  
     public Lifecycle getLifecycle(String id)
 62  
             throws FacesException
 63  
     {
 64  0
         synchronized (_lifecycles)
 65  
         {
 66  0
             Lifecycle lifecycle = _lifecycles.get(id);
 67  0
             if (lifecycle == null)
 68  
             {
 69  0
                 throw new IllegalArgumentException("Unknown lifecycle '" + id + "'.");
 70  
             }
 71  0
             return lifecycle;
 72  0
         }
 73  
     }
 74  
 
 75  
     public Iterator<String> getLifecycleIds()
 76  
     {
 77  0
         return _lifecycles.keySet().iterator();
 78  
     }
 79  
 }