1 16 package org.apache.myfaces.lifecycle; 17 18 import javax.faces.FacesException; 19 import javax.faces.lifecycle.Lifecycle; 20 import javax.faces.lifecycle.LifecycleFactory; 21 import java.util.HashMap ; 22 import java.util.Iterator ; 23 import java.util.Map ; 24 25 30 public class LifecycleFactoryImpl 31 extends LifecycleFactory 32 { 33 private final Map _lifecycles = new HashMap (); 34 35 public LifecycleFactoryImpl() 36 { 37 addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, new LifecycleImpl()); 38 } 39 40 public void addLifecycle(String id, Lifecycle lifecycle) 41 { 42 synchronized (_lifecycles) 43 { 44 if (_lifecycles.get(id) != null) 45 { 46 throw new IllegalArgumentException ("Lifecycle with id '" + id + "' already exists."); 47 } 48 _lifecycles.put(id, lifecycle); 49 } 50 } 51 52 public Lifecycle getLifecycle(String id) 53 throws FacesException 54 { 55 synchronized (_lifecycles) 56 { 57 Lifecycle lifecycle = (Lifecycle)_lifecycles.get(id); 58 if (lifecycle == null) 59 { 60 throw new IllegalArgumentException ("Unknown lifecycle '" + id + "'."); 61 } 62 return lifecycle; 63 } 64 } 65 66 public Iterator getLifecycleIds() 67 { 68 return _lifecycles.keySet().iterator(); 69 } 70 } 71 | Popular Tags |