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.spring;
19
20 import javax.faces.context.FacesContext;
21 import javax.faces.el.EvaluationException;
22 import javax.faces.el.VariableResolver;
23
24 import org.springframework.web.jsf.FacesContextUtils;
25
26 /***
27 * <p>Extended <code>VariableResolver</code> that exposes the Spring
28 * <code>WebApplicationContext</code> instance under a variable named
29 * with the specified manifest constant.</p>
30 *
31 * $Id: WebApplicationContextVariableResolver.java 464373 2006-10-16 04:21:54Z rahul $
32 */
33 public class WebApplicationContextVariableResolver extends VariableResolver {
34
35
36
37
38
39 /***
40 * <p>Construct a new {@link WebApplicationContextVariableResolver}
41 * instance.</p>
42 *
43 * @param original Original resolver to delegate to.
44 */
45 public WebApplicationContextVariableResolver(VariableResolver original) {
46
47 this.original = original;
48
49 }
50
51
52
53
54
55 /***
56 * <p>The original <code>VariableResolver</code> passed to our constructor.</p>
57 */
58 private VariableResolver original = null;
59
60
61
62
63
64 /***
65 * <p>Variable name to be resoved to our web application context.</p>
66 */
67 private static final String WEB_APPLICATION_CONTEXT_VARIABLE_NAME =
68 "webApplicationContext";
69
70
71
72
73
74
75
76 /***
77 * <p>Resolve variable names known to this resolver; otherwise, delegate to
78 * the original resolver passed to our constructor.</p>
79 *
80 * @param context FacesContext for the current request
81 * @param name Variable name to be resolved
82 *
83 * @exception EvaluationException if an evaluation error occurs
84 */
85 public Object resolveVariable(FacesContext context, String name)
86 throws EvaluationException {
87
88 if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(name)) {
89 return FacesContextUtils.getWebApplicationContext(context);
90 } else {
91 return original.resolveVariable(context, name);
92 }
93
94 }
95
96
97 }