001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina;
018:
019: /**
020: * Common interface for component life cycle methods. Catalina components
021: * may, but are not required to, implement this interface (as well as the
022: * appropriate interface(s) for the functionality they support) in order to
023: * provide a consistent mechanism to start and stop the component.
024: *
025: * @author Craig R. McClanahan
026: * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:38 $
027: */
028:
029: public interface Lifecycle {
030:
031: // ----------------------------------------------------- Manifest Constants
032:
033: /**
034: * The LifecycleEvent type for the "component start" event.
035: */
036: public static final String START_EVENT = "start";
037:
038: /**
039: * The LifecycleEvent type for the "component before start" event.
040: */
041: public static final String BEFORE_START_EVENT = "before_start";
042:
043: /**
044: * The LifecycleEvent type for the "component after start" event.
045: */
046: public static final String AFTER_START_EVENT = "after_start";
047:
048: /**
049: * The LifecycleEvent type for the "component stop" event.
050: */
051: public static final String STOP_EVENT = "stop";
052:
053: /**
054: * The LifecycleEvent type for the "component before stop" event.
055: */
056: public static final String BEFORE_STOP_EVENT = "before_stop";
057:
058: /**
059: * The LifecycleEvent type for the "component after stop" event.
060: */
061: public static final String AFTER_STOP_EVENT = "after_stop";
062:
063: // --------------------------------------------------------- Public Methods
064:
065: /**
066: * Add a LifecycleEvent listener to this component.
067: *
068: * @param listener The listener to add
069: */
070: public void addLifecycleListener(LifecycleListener listener);
071:
072: /**
073: * Get the lifecycle listeners associated with this lifecycle. If this
074: * Lifecycle has no listeners registered, a zero-length array is returned.
075: */
076: public LifecycleListener[] findLifecycleListeners();
077:
078: /**
079: * Remove a LifecycleEvent listener from this component.
080: *
081: * @param listener The listener to remove
082: */
083: public void removeLifecycleListener(LifecycleListener listener);
084:
085: /**
086: * Prepare for the beginning of active use of the public methods of this
087: * component. This method should be called before any of the public
088: * methods of this component are utilized. It should also send a
089: * LifecycleEvent of type START_EVENT to any registered listeners.
090: *
091: * @exception LifecycleException if this component detects a fatal error
092: * that prevents this component from being used
093: */
094: public void start() throws LifecycleException;
095:
096: /**
097: * Gracefully terminate the active use of the public methods of this
098: * component. This method should be the last one called on a given
099: * instance of this component. It should also send a LifecycleEvent
100: * of type STOP_EVENT to any registered listeners.
101: *
102: * @exception LifecycleException if this component detects a fatal error
103: * that needs to be reported
104: */
105: public void stop() throws LifecycleException;
106:
107: }
|