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;
20:
21: import java.util.Iterator;
22:
23: import javax.faces.FactoryFinder;
24: import javax.faces.event.PhaseEvent;
25: import javax.faces.event.PhaseId;
26: import javax.faces.event.PhaseListener;
27: import javax.faces.lifecycle.LifecycleFactory;
28:
29: import org.apache.myfaces.el.unified.ELResolverBuilder;
30:
31: /**
32: * The class will initialize the resolver for JSP
33: *
34: * @author Mathias Broekelmann (latest modification by $Author: mbr $)
35: * @version $Revision: 527076 $ $Date: 2007-04-10 12:01:32 +0200 (Di, 10 Apr 2007) $
36: */
37: public class ResolverForJSPInitializer implements PhaseListener {
38: private final ELResolverBuilder _resolverBuilder;
39: private boolean initialized;
40: private final javax.el.CompositeELResolver _resolverForJSP;
41:
42: public ResolverForJSPInitializer(ELResolverBuilder resolverBuilder,
43: javax.el.CompositeELResolver resolverForJSP) {
44: _resolverBuilder = resolverBuilder;
45: _resolverForJSP = resolverForJSP;
46: }
47:
48: public void beforePhase(PhaseEvent event) {
49: if (!initialized) {
50: initialized = true;
51: _resolverBuilder.build(_resolverForJSP);
52:
53: LifecycleFactory factory = (LifecycleFactory) FactoryFinder
54: .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
55: for (Iterator<String> iter = factory.getLifecycleIds(); iter
56: .hasNext();) {
57: factory.getLifecycle(iter.next()).removePhaseListener(
58: this );
59: }
60: }
61: }
62:
63: public void afterPhase(PhaseEvent event) {
64: }
65:
66: public PhaseId getPhaseId() {
67: return PhaseId.ANY_PHASE;
68: }
69:
70: }
|