Source code: com/sun/facelets/el/LegacyMethodBinding.java
1 /**
2 * Licensed under the Common Development and Distribution License,
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.sun.com/cddl/
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11 * implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15 package com.sun.facelets.el;
16
17 import java.io.Serializable;
18
19 import javax.el.ELException;
20 import javax.el.MethodExpression;
21 import javax.faces.context.FacesContext;
22 import javax.faces.el.EvaluationException;
23 import javax.faces.el.MethodBinding;
24 import javax.faces.el.MethodNotFoundException;
25
26 /**
27 * For legacy ActionSources
28 *
29 * @author Jacob Hookom
30 * @version $Id: LegacyMethodBinding.java,v 1.6 2005/09/02 03:30:03 adamwiner Exp $
31 * @deprecated
32 */
33 public final class LegacyMethodBinding extends
34 MethodBinding implements Serializable {
35
36 private static final long serialVersionUID = 1L;
37
38 private final MethodExpression m;
39
40 public LegacyMethodBinding(MethodExpression m) {
41 this.m = m;
42 }
43
44 /*
45 * (non-Javadoc)
46 *
47 * @see javax.faces.el.MethodBinding#getType(javax.faces.context.FacesContext)
48 */
49 public Class getType(FacesContext context)
50 throws MethodNotFoundException {
51 try {
52 return m.getMethodInfo(ELAdaptor.getELContext(context)).getReturnType();
53 } catch (javax.el.MethodNotFoundException e) {
54 throw new MethodNotFoundException(e.getMessage(), e.getCause());
55 } catch (ELException e) {
56 throw new EvaluationException(e.getMessage(), e.getCause());
57 }
58 }
59
60 /*
61 * (non-Javadoc)
62 *
63 * @see javax.faces.el.MethodBinding#invoke(javax.faces.context.FacesContext,
64 * java.lang.Object[])
65 */
66 public Object invoke(FacesContext context, Object[] params)
67 throws EvaluationException, MethodNotFoundException {
68 try {
69 return m.invoke(ELAdaptor.getELContext(context), params);
70 } catch (javax.el.MethodNotFoundException e) {
71 throw new MethodNotFoundException(e.getMessage(), e.getCause());
72 } catch (ELException e) {
73 throw new EvaluationException(e.getMessage(), e.getCause());
74 }
75 }
76
77 public String getExpressionString() {
78 return m.getExpressionString();
79 }
80 }