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;
019:
020: /**
021: * Common interface for component life cycle methods. Catalina components
022: * may, but are not required to, implement this interface (as well as the
023: * appropriate interface(s) for the functionality they support) in order to
024: * provide a consistent mechanism to start and stop the component.
025: *
026: * @author Craig R. McClanahan
027: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
028: */
029:
030: public interface Lifecycle {
031:
032: // ----------------------------------------------------- Manifest Constants
033:
034: /**
035: * The LifecycleEvent type for the "component init" event.
036: */
037: public static final String INIT_EVENT = "init";
038:
039: /**
040: * The LifecycleEvent type for the "component start" event.
041: */
042: public static final String START_EVENT = "start";
043:
044: /**
045: * The LifecycleEvent type for the "component before start" event.
046: */
047: public static final String BEFORE_START_EVENT = "before_start";
048:
049: /**
050: * The LifecycleEvent type for the "component after start" event.
051: */
052: public static final String AFTER_START_EVENT = "after_start";
053:
054: /**
055: * The LifecycleEvent type for the "component stop" event.
056: */
057: public static final String STOP_EVENT = "stop";
058:
059: /**
060: * The LifecycleEvent type for the "component before stop" event.
061: */
062: public static final String BEFORE_STOP_EVENT = "before_stop";
063:
064: /**
065: * The LifecycleEvent type for the "component after stop" event.
066: */
067: public static final String AFTER_STOP_EVENT = "after_stop";
068:
069: /**
070: * The LifecycleEvent type for the "component destroy" event.
071: */
072: public static final String DESTROY_EVENT = "destroy";
073:
074: /**
075: * The LifecycleEvent type for the "periodic" event.
076: */
077: public static final String PERIODIC_EVENT = "periodic";
078:
079: // --------------------------------------------------------- Public Methods
080:
081: /**
082: * Add a LifecycleEvent listener to this component.
083: *
084: * @param listener The listener to add
085: */
086: public void addLifecycleListener(LifecycleListener listener);
087:
088: /**
089: * Get the lifecycle listeners associated with this lifecycle. If this
090: * Lifecycle has no listeners registered, a zero-length array is returned.
091: */
092: public LifecycleListener[] findLifecycleListeners();
093:
094: /**
095: * Remove a LifecycleEvent listener from this component.
096: *
097: * @param listener The listener to remove
098: */
099: public void removeLifecycleListener(LifecycleListener listener);
100:
101: /**
102: * Prepare for the beginning of active use of the public methods of this
103: * component. This method should be called before any of the public
104: * methods of this component are utilized. It should also send a
105: * LifecycleEvent of type START_EVENT to any registered listeners.
106: *
107: * @exception LifecycleException if this component detects a fatal error
108: * that prevents this component from being used
109: */
110: public void start() throws LifecycleException;
111:
112: /**
113: * Gracefully terminate the active use of the public methods of this
114: * component. This method should be the last one called on a given
115: * instance of this component. It should also send a LifecycleEvent
116: * of type STOP_EVENT to any registered listeners.
117: *
118: * @exception LifecycleException if this component detects a fatal error
119: * that needs to be reported
120: */
121: public void stop() throws LifecycleException;
122:
123: }
|