01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.catalina.core;
19:
20: import org.apache.catalina.Lifecycle;
21: import org.apache.catalina.LifecycleEvent;
22: import org.apache.catalina.LifecycleListener;
23: import org.apache.catalina.util.StringManager;
24: import org.apache.juli.logging.Log;
25: import org.apache.juli.logging.LogFactory;
26:
27: /**
28: * This listener is designed to initialize Jasper before any web applications are
29: * started.
30: *
31: * @author Remy Maucherat
32: * @version $Revision: 491990 $ $Date: 2007-01-03 01:36:57 +0100 (mer., 03 janv. 2007) $
33: * @since 4.1
34: */
35:
36: public class JasperListener implements LifecycleListener {
37:
38: private static Log log = LogFactory.getLog(JasperListener.class);
39:
40: /**
41: * The string manager for this package.
42: */
43: protected StringManager sm = StringManager
44: .getManager(Constants.Package);
45:
46: // ---------------------------------------------- LifecycleListener Methods
47:
48: /**
49: * Primary entry point for startup and shutdown events.
50: *
51: * @param event The event that has occurred
52: */
53: public void lifecycleEvent(LifecycleEvent event) {
54:
55: if (Lifecycle.INIT_EVENT.equals(event.getType())) {
56: try {
57: // Set JSP factory
58: Class.forName(
59: "org.apache.jasper.compiler.JspRuntimeContext",
60: true, this .getClass().getClassLoader());
61: } catch (Throwable t) {
62: // Should not occur, obviously
63: log.warn("Couldn't initialize Jasper", t);
64: }
65: // Another possibility is to do directly:
66: // JspFactory.setDefaultFactory(new JspFactoryImpl());
67: }
68:
69: }
70:
71: }
|