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.custom.validatebeanbehavior;
20  
21  import javax.el.ELContext;
22  import javax.el.ELResolver;
23  import javax.el.FunctionMapper;
24  import javax.el.VariableMapper;
25  import java.util.Locale;
26  
27  /**
28   * This ELContext is used to hook into the EL handling, by decorating the
29   * ELResolver chain with a custom ELResolver.
30   *
31   * Note: Copy from MyFaces Core 2.0.
32   *
33   * @author Jan-Kees van Andel
34   */
35  final class ELContextDecorator extends ELContext {
36      private final ELContext ctx;
37      private final ELResolver interceptingResolver;
38  
39      /**
40       * Only used by ValueExpressionResolver.
41       *
42       * @param elContext            The standard ELContext. All method calls, except getELResolver, are delegated to it.
43       * @param interceptingResolver The ELResolver to be returned by getELResolver.
44       */
45      ELContextDecorator(final ELContext elContext, final ELResolver interceptingResolver) {
46          this.ctx = elContext;
47          this.interceptingResolver = interceptingResolver;
48      }
49  
50      /**
51       * This is the important one, it returns the passed ELResolver.
52       *
53       * @return The ELResolver passed into the constructor.
54       */
55      @Override
56      public final ELResolver getELResolver() {
57          return interceptingResolver;
58      }
59  
60      // ############################ Standard delegating implementations ############################
61  
62      public final FunctionMapper getFunctionMapper() {
63          return ctx.getFunctionMapper();
64      }
65  
66      public final VariableMapper getVariableMapper() {
67          return ctx.getVariableMapper();
68      }
69  
70      public final void setPropertyResolved(final boolean resolved) {
71          ctx.setPropertyResolved(resolved);
72      }
73  
74      public final boolean isPropertyResolved() {
75          return ctx.isPropertyResolved();
76      }
77  
78      public final void putContext(final Class key, Object contextObject) {
79          ctx.putContext(key, contextObject);
80      }
81  
82      public final Object getContext(final Class key) {
83          return ctx.getContext(key);
84      }
85  
86      public final Locale getLocale() {
87          return ctx.getLocale();
88      }
89  
90      public final void setLocale(final Locale locale) {
91          ctx.setLocale(locale);
92      }
93  }