View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.view.facelets.el;
20  
21  import java.io.Serializable;
22  
23  import javax.el.ELException;
24  import javax.el.MethodExpression;
25  import javax.faces.context.FacesContext;
26  import javax.faces.el.EvaluationException;
27  import javax.faces.el.MethodBinding;
28  import javax.faces.el.MethodNotFoundException;
29  
30  /**
31   * For legacy ActionSources
32   * 
33   * @author Jacob Hookom
34   * @version $Id$
35   * @deprecated
36   */
37  public final class LegacyMethodBinding extends MethodBinding implements
38          Serializable
39  {
40  
41      private static final long serialVersionUID = 1L;
42  
43      private final MethodExpression m;
44  
45      public LegacyMethodBinding(MethodExpression m)
46      {
47          this.m = m;
48      }
49  
50      /*
51       * (non-Javadoc)
52       * 
53       * @see javax.faces.el.MethodBinding#getType(javax.faces.context.FacesContext)
54       */
55      public Class getType(FacesContext context) throws MethodNotFoundException
56      {
57          try
58          {
59              return m.getMethodInfo(context.getELContext()).getReturnType();
60          }
61          catch (javax.el.MethodNotFoundException e)
62          {
63              throw new MethodNotFoundException(e.getMessage(), e.getCause());
64          }
65          catch (ELException e)
66          {
67              throw new EvaluationException(e.getMessage(), e.getCause());
68          }
69      }
70  
71      /*
72       * (non-Javadoc)
73       * 
74       * @see javax.faces.el.MethodBinding#invoke(javax.faces.context.FacesContext,
75       *      java.lang.Object[])
76       */
77      public Object invoke(FacesContext context, Object[] params)
78              throws EvaluationException, MethodNotFoundException
79      {
80          try
81          {
82              return m.invoke(context.getELContext(), params);
83          }
84          catch (javax.el.MethodNotFoundException e)
85          {
86              throw new MethodNotFoundException(e.getMessage(), e.getCause());
87          }
88          catch (ELException e)
89          {
90              throw new EvaluationException(e.getMessage(), e.getCause());
91          }
92      }
93  
94      public String getExpressionString()
95      {
96          return m.getExpressionString();
97      }
98  }