001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.startup;
019:
020: import org.apache.catalina.Engine;
021: import org.apache.catalina.Lifecycle;
022: import org.apache.catalina.LifecycleEvent;
023: import org.apache.catalina.LifecycleListener;
024: import org.apache.catalina.util.StringManager;
025:
026: /**
027: * Startup event listener for a <b>Engine</b> that configures the properties
028: * of that Engine, and the associated defined contexts.
029: *
030: * @author Craig R. McClanahan
031: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
032: */
033:
034: public class EngineConfig implements LifecycleListener {
035:
036: protected static org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory
037: .getLog(EngineConfig.class);
038:
039: // ----------------------------------------------------- Instance Variables
040:
041: /**
042: * The Engine we are associated with.
043: */
044: protected Engine engine = null;
045:
046: /**
047: * The string resources for this package.
048: */
049: protected static final StringManager sm = StringManager
050: .getManager(Constants.Package);
051:
052: // --------------------------------------------------------- Public Methods
053:
054: /**
055: * Process the START event for an associated Engine.
056: *
057: * @param event The lifecycle event that has occurred
058: */
059: public void lifecycleEvent(LifecycleEvent event) {
060:
061: // Identify the engine we are associated with
062: try {
063: engine = (Engine) event.getLifecycle();
064: } catch (ClassCastException e) {
065: log.error(sm.getString("engineConfig.cce", event
066: .getLifecycle()), e);
067: return;
068: }
069:
070: // Process the event that has occurred
071: if (event.getType().equals(Lifecycle.START_EVENT))
072: start();
073: else if (event.getType().equals(Lifecycle.STOP_EVENT))
074: stop();
075:
076: }
077:
078: // -------------------------------------------------------- Protected Methods
079:
080: /**
081: * Process a "start" event for this Engine.
082: */
083: protected void start() {
084:
085: if (engine.getLogger().isDebugEnabled())
086: engine.getLogger()
087: .debug(sm.getString("engineConfig.start"));
088:
089: }
090:
091: /**
092: * Process a "stop" event for this Engine.
093: */
094: protected void stop() {
095:
096: if (engine.getLogger().isDebugEnabled())
097: engine.getLogger().debug(sm.getString("engineConfig.stop"));
098:
099: }
100:
101: }
|