1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package javax.faces.event; |
20 | |
|
21 | |
import java.util.Collections; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.List; |
24 | |
import java.util.Map; |
25 | |
|
26 | |
import javax.faces.component.UIComponent; |
27 | |
import javax.faces.context.FacesContext; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class ExceptionQueuedEventContext implements SystemEventListenerHolder |
33 | |
{ |
34 | |
|
35 | |
|
36 | 0 | public static final String IN_AFTER_PHASE_KEY = ExceptionQueuedEventContext.class.getName() + ".IN_AFTER_PHASE"; |
37 | 0 | public static final String IN_BEFORE_PHASE_KEY = ExceptionQueuedEventContext.class.getName() + ".IN_BEFORE_PHASE"; |
38 | |
|
39 | |
private Map<Object, Object> _attributes; |
40 | |
private UIComponent _component; |
41 | |
private FacesContext _context; |
42 | |
private PhaseId _phase; |
43 | |
private Throwable _thrown; |
44 | |
|
45 | |
public ExceptionQueuedEventContext(FacesContext context, Throwable thrown) |
46 | |
{ |
47 | 0 | this(context, thrown, null); |
48 | 0 | } |
49 | |
|
50 | |
public ExceptionQueuedEventContext(FacesContext context, Throwable thrown, UIComponent component) |
51 | |
{ |
52 | 0 | this(context, thrown, component, null); |
53 | 0 | } |
54 | |
|
55 | |
public ExceptionQueuedEventContext(FacesContext context, Throwable thrown, UIComponent component, PhaseId phaseId) |
56 | 0 | { |
57 | 0 | _context = context; |
58 | 0 | _thrown = thrown; |
59 | 0 | _component = component; |
60 | 0 | _phase = (phaseId == null ? context.getCurrentPhaseId() : phaseId); |
61 | 0 | } |
62 | |
|
63 | |
public Map<Object,Object> getAttributes() |
64 | |
{ |
65 | 0 | if (_attributes == null) |
66 | |
{ |
67 | 0 | _attributes = new HashMap<Object, Object>(); |
68 | |
} |
69 | |
|
70 | 0 | return _attributes; |
71 | |
} |
72 | |
|
73 | |
public UIComponent getComponent() |
74 | |
{ |
75 | 0 | return _component; |
76 | |
} |
77 | |
|
78 | |
public FacesContext getContext() |
79 | |
{ |
80 | 0 | return _context; |
81 | |
} |
82 | |
|
83 | |
public Throwable getException() |
84 | |
{ |
85 | 0 | return _thrown; |
86 | |
} |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public List<SystemEventListener> getListenersForEventClass(Class<? extends SystemEvent> facesEventClass) |
92 | |
{ |
93 | 0 | return Collections.singletonList((SystemEventListener)getContext().getExceptionHandler()); |
94 | |
} |
95 | |
|
96 | |
public PhaseId getPhaseId() |
97 | |
{ |
98 | 0 | return _phase; |
99 | |
} |
100 | |
|
101 | |
public boolean inAfterPhase() |
102 | |
{ |
103 | 0 | return (_attributes != null && _attributes.containsKey(IN_AFTER_PHASE_KEY)); |
104 | |
} |
105 | |
|
106 | |
public boolean inBeforePhase() |
107 | |
{ |
108 | 0 | return (_attributes != null && _attributes.containsKey(IN_BEFORE_PHASE_KEY)); |
109 | |
} |
110 | |
} |