1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.view.facelets.el;
20
21 import java.io.Externalizable;
22 import java.io.IOException;
23 import java.io.ObjectInput;
24 import java.io.ObjectOutput;
25
26 import javax.el.ELContext;
27 import javax.el.MethodExpression;
28 import javax.el.MethodInfo;
29 import javax.el.ValueExpression;
30 import javax.faces.FacesWrapper;
31 import javax.faces.context.FacesContext;
32 import javax.faces.view.Location;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 public class LocationMethodExpression extends MethodExpression
50 implements FacesWrapper<MethodExpression>, Externalizable, LocationAware
51 {
52
53 private static final long serialVersionUID = 1634644578979226893L;
54
55 private Location location;
56 private MethodExpression delegate;
57
58 public LocationMethodExpression()
59 {
60 super();
61 }
62
63 public LocationMethodExpression(Location location, MethodExpression delegate)
64 {
65 this.location = location;
66 this.delegate = delegate;
67 }
68
69 public Location getLocation()
70 {
71 return location;
72 }
73
74 @Override
75 public MethodInfo getMethodInfo(ELContext context)
76 {
77 FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
78 CompositeComponentELUtils.saveCompositeComponentForResolver(facesContext, location);
79 try
80 {
81 return delegate.getMethodInfo(context);
82 }
83 finally
84 {
85 CompositeComponentELUtils.removeCompositeComponentForResolver(facesContext);
86 }
87 }
88
89 @Override
90 public Object invoke(ELContext context, Object[] params)
91 {
92 FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
93 CompositeComponentELUtils.saveCompositeComponentForResolver(facesContext, location);
94 try
95 {
96 return delegate.invoke(context, params);
97 }
98 finally
99 {
100 CompositeComponentELUtils.removeCompositeComponentForResolver(facesContext);
101 }
102 }
103
104 @Override
105 public boolean equals(Object obj)
106 {
107 return delegate.equals(obj);
108 }
109
110 @Override
111 public String getExpressionString()
112 {
113 return delegate.getExpressionString();
114 }
115
116 @Override
117 public int hashCode()
118 {
119 return delegate.hashCode();
120 }
121
122 @Override
123 public boolean isLiteralText()
124 {
125 return delegate.isLiteralText();
126 }
127
128 public MethodExpression getWrapped()
129 {
130 return delegate;
131 }
132
133 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
134 {
135 this.delegate = (MethodExpression) in.readObject();
136 this.location = (Location) in.readObject();
137 }
138
139 public void writeExternal(ObjectOutput out) throws IOException
140 {
141 out.writeObject(this.delegate);
142 out.writeObject(this.location);
143 }
144
145 }