KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > core > JasperListener


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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
21 import org.apache.catalina.Lifecycle;
22 import org.apache.catalina.LifecycleEvent;
23 import org.apache.catalina.LifecycleListener;
24 import org.apache.catalina.util.StringManager;
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28
29 /**
30  * This listener is designed to initialize Jasper before any web applications are
31  * started.
32  *
33  * @author Remy Maucherat
34  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
35  * @since 4.1
36  */

37
38 public class JasperListener
39     implements LifecycleListener {
40
41     private static Log log = LogFactory.getLog(JasperListener.class);
42
43     /**
44      * The string manager for this package.
45      */

46     protected StringManager sm =
47         StringManager.getManager(Constants.Package);
48
49     
50     // ---------------------------------------------- LifecycleListener Methods
51

52
53     /**
54      * Primary entry point for startup and shutdown events.
55      *
56      * @param event The event that has occurred
57      */

58     public void lifecycleEvent(LifecycleEvent event) {
59
60         if (Lifecycle.INIT_EVENT.equals(event.getType())) {
61             try {
62                 // Set JSP factory
63
this.getClass().getClassLoader().loadClass
64                     ("org.apache.jasper.compiler.JspRuntimeContext");
65             } catch (Throwable JavaDoc t) {
66                 // Should not occur, obviously
67
log.warn("Couldn't initialize Jasper", t);
68             }
69             // Another possibility is to do directly:
70
// JspFactory.setDefaultFactory(new JspFactoryImpl());
71
}
72
73     }
74
75
76 }
77
Popular Tags