KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > startup > EngineConfig


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
19 package org.apache.catalina.startup;
20
21
22 import org.apache.catalina.Engine;
23 import org.apache.catalina.Lifecycle;
24 import org.apache.catalina.LifecycleEvent;
25 import org.apache.catalina.LifecycleListener;
26 import org.apache.catalina.util.StringManager;
27
28
29 /**
30  * Startup event listener for a <b>Engine</b> that configures the properties
31  * of that Engine, and the associated defined contexts.
32  *
33  * @author Craig R. McClanahan
34  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
35  */

36
37 public class EngineConfig
38     implements LifecycleListener {
39
40
41     protected static org.apache.commons.logging.Log log=
42         org.apache.commons.logging.LogFactory.getLog( EngineConfig.class );
43
44     // ----------------------------------------------------- Instance Variables
45

46
47     /**
48      * The Engine we are associated with.
49      */

50     protected Engine engine = null;
51
52
53     /**
54      * The string resources for this package.
55      */

56     protected static final StringManager sm =
57         StringManager.getManager(Constants.Package);
58
59
60     // --------------------------------------------------------- Public Methods
61

62
63     /**
64      * Process the START event for an associated Engine.
65      *
66      * @param event The lifecycle event that has occurred
67      */

68     public void lifecycleEvent(LifecycleEvent event) {
69
70         // Identify the engine we are associated with
71
try {
72             engine = (Engine) event.getLifecycle();
73         } catch (ClassCastException JavaDoc e) {
74             log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
75             return;
76         }
77
78         // Process the event that has occurred
79
if (event.getType().equals(Lifecycle.START_EVENT))
80             start();
81         else if (event.getType().equals(Lifecycle.STOP_EVENT))
82             stop();
83
84     }
85
86
87     // -------------------------------------------------------- Protected Methods
88

89
90     /**
91      * Process a "start" event for this Engine.
92      */

93     protected void start() {
94
95         if (engine.getLogger().isDebugEnabled())
96             engine.getLogger().debug(sm.getString("engineConfig.start"));
97
98     }
99
100
101     /**
102      * Process a "stop" event for this Engine.
103      */

104     protected void stop() {
105
106         if (engine.getLogger().isDebugEnabled())
107             engine.getLogger().debug(sm.getString("engineConfig.stop"));
108
109     }
110
111
112 }
113
Popular Tags