1 28 29 package com.caucho.jsf.lifecycle; 30 31 import java.util.*; 32 33 import javax.faces.*; 34 import javax.faces.application.*; 35 import javax.faces.context.*; 36 import javax.faces.event.*; 37 import javax.faces.lifecycle.*; 38 39 42 public class LifecycleImpl extends Lifecycle 43 { 44 private ArrayList<PhaseListener> _phaseList = new ArrayList<PhaseListener>(); 45 private PhaseListener []_phaseListeners = new PhaseListener[0]; 46 47 public LifecycleImpl() 48 { 49 } 50 51 public void addPhaseListener(PhaseListener listener) 52 { 53 if (listener == null) 54 throw new NullPointerException (); 55 56 synchronized (_phaseList) { 57 _phaseList.add(listener); 58 _phaseListeners = new PhaseListener[_phaseList.size()]; 59 _phaseList.toArray(_phaseListeners); 60 } 61 } 62 63 public PhaseListener []getPhaseListeners() 64 { 65 return _phaseListeners; 66 } 67 68 public void removePhaseListener(PhaseListener listener) 69 { 70 if (listener == null) 71 throw new NullPointerException (); 72 73 synchronized (_phaseList) { 74 _phaseList.remove(listener); 75 _phaseListeners = new PhaseListener[_phaseList.size()]; 76 _phaseList.toArray(_phaseListeners); 77 } 78 } 79 80 public void execute(FacesContext context) 81 throws FacesException 82 { 83 if (context.getResponseComplete() || context.getRenderResponse()) 84 return; 85 } 86 87 public void render(FacesContext context) 88 throws FacesException 89 { 90 if (context.getResponseComplete()) 91 return; 92 93 Application app = context.getApplication(); 94 ViewHandler view = app.getViewHandler(); 95 96 try { 97 view.renderView(context, context.getViewRoot()); 98 } catch (java.io.IOException e) { 99 throw new FacesException(e); 100 } 101 } 102 103 public String toString() 104 { 105 return "DefaultLifecycleImpl[]"; 106 } 107 } 108 | Popular Tags |