01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
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.el.unified;
20:
21: import org.apache.myfaces.config.RuntimeConfig;
22: import org.apache.myfaces.el.convert.PropertyResolverToELResolver;
23: import org.apache.myfaces.el.convert.VariableResolverToELResolver;
24:
25: import javax.el.CompositeELResolver;
26: import javax.el.ELResolver;
27: import javax.faces.application.Application;
28: import javax.faces.el.PropertyResolver;
29: import javax.faces.el.VariableResolver;
30:
31: /**
32: * @author Mathias Broekelmann (latest modification by $Author: mbr $)
33: * @version $Revision: 511514 $ $Date: 2007-02-25 14:47:48 +0100 (So, 25 Feb 2007) $
34: */
35: @SuppressWarnings("deprecation")
36: public class ResolverBuilderBase {
37: private final RuntimeConfig _config;
38:
39: public ResolverBuilderBase(RuntimeConfig config) {
40: _config = config;
41: }
42:
43: /**
44: * add the el resolvers from the faces config, the el resolver wrapper for variable resolver, the el resolver
45: * wrapper for the property resolver and the el resolvers added by {@link Application#addELResolver(ELResolver)}.
46: * The resolvers where only added if they are not null
47: *
48: * @param elResolver
49: * the composite el resolver to which the resolvers where added
50: */
51: protected void addFromRuntimeConfig(CompositeELResolver elResolver) {
52: if (_config.getFacesConfigElResolvers() != null) {
53: elResolver.add(_config.getFacesConfigElResolvers());
54: }
55:
56: if (_config.getVariableResolver() != null) {
57: elResolver.add(createELResolver(_config
58: .getVariableResolver()));
59: } else if (_config.getVariableResolverChainHead() != null) {
60: elResolver.add(createELResolver(_config
61: .getVariableResolverChainHead()));
62: }
63:
64: if (_config.getPropertyResolver() != null) {
65: elResolver.add(createELResolver(_config
66: .getPropertyResolver()));
67: } else if (_config.getPropertyResolverChainHead() != null) {
68: elResolver.add(createELResolver(_config
69: .getPropertyResolverChainHead()));
70: }
71:
72: if (_config.getApplicationElResolvers() != null) {
73: elResolver.add(_config.getApplicationElResolvers());
74: }
75: }
76:
77: protected ELResolver createELResolver(VariableResolver resolver) {
78: return new VariableResolverToELResolver(resolver);
79: }
80:
81: protected ELResolver createELResolver(PropertyResolver resolver) {
82: return new PropertyResolverToELResolver(resolver);
83: }
84:
85: }
|