2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.test.mock;
19
20 import javax.el.ELContext;
21 import javax.el.ELContextEvent;
22 import javax.el.ELContextListener;
23 import javax.faces.context.ExternalContext;
24 import javax.faces.context.FacesContext;
25 import javax.faces.lifecycle.Lifecycle;
26 import org.apache.shale.test.el.MockELContext;
27
28 /***
29 * <p>Mock implementation of <code>FacesContext</code> that includes the semantics
30 * added by JavaServer Faces 1.2.</p>
31 *
32 * $Id: MockFacesContext12.java 464373 2006-10-16 04:21:54Z rahul $
33 *
34 * @since 1.0.4
35 */
36
37 public class MockFacesContext12 extends MockFacesContext {
38
39
40
41
42
43 public MockFacesContext12() {
44 super();
45 setCurrentInstance(this);
46 }
47
48
49 public MockFacesContext12(ExternalContext externalContext) {
50 super(externalContext);
51 }
52
53
54 public MockFacesContext12(ExternalContext externalContext, Lifecycle lifecycle) {
55 super(externalContext, lifecycle);
56 }
57
58
59
60
61
62 /***
63 * <p>Set the <code>ELContext</code> instance for this instance.</p>
64 *
65 * @param elContext The new ELContext
66 */
67 public void setELContext(ELContext elContext) {
68
69 this.elContext = elContext;
70
71 }
72
73
74
75
76
77 private ELContext elContext = null;
78
79
80
81
82
83 /*** {@inheritDoc} */
84 public ELContext getELContext() {
85
86 if (this.elContext == null) {
87
88
89 this.elContext = new MockELContext();
90 this.elContext.putContext(FacesContext.class, this);
91
92
93 ELContextListener[] listeners = getApplication().getELContextListeners();
94 if ((listeners != null) && (listeners.length > 0)) {
95 ELContextEvent event = new ELContextEvent(this.elContext);
96 for (int i = 0; i < listeners.length; i++) {
97 listeners[i].contextCreated(event);
98 }
99 }
100
101 }
102 return this.elContext;
103
104 }
105
106
107 /*** {@inheritDoc} */
108 public void release() {
109 super.release();
110 this.elContext = null;
111 }
112
113
114 }