KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > Lifecycle


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;
20
21
22 /**
23  * Common interface for component life cycle methods. Catalina components
24  * may, but are not required to, implement this interface (as well as the
25  * appropriate interface(s) for the functionality they support) in order to
26  * provide a consistent mechanism to start and stop the component.
27  *
28  * @author Craig R. McClanahan
29  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
30  */

31
32 public interface Lifecycle {
33
34
35     // ----------------------------------------------------- Manifest Constants
36

37
38     /**
39      * The LifecycleEvent type for the "component init" event.
40      */

41     public static final String JavaDoc INIT_EVENT = "init";
42
43
44     /**
45      * The LifecycleEvent type for the "component start" event.
46      */

47     public static final String JavaDoc START_EVENT = "start";
48
49
50     /**
51      * The LifecycleEvent type for the "component before start" event.
52      */

53     public static final String JavaDoc BEFORE_START_EVENT = "before_start";
54
55
56     /**
57      * The LifecycleEvent type for the "component after start" event.
58      */

59     public static final String JavaDoc AFTER_START_EVENT = "after_start";
60
61
62     /**
63      * The LifecycleEvent type for the "component stop" event.
64      */

65     public static final String JavaDoc STOP_EVENT = "stop";
66
67
68     /**
69      * The LifecycleEvent type for the "component before stop" event.
70      */

71     public static final String JavaDoc BEFORE_STOP_EVENT = "before_stop";
72
73
74     /**
75      * The LifecycleEvent type for the "component after stop" event.
76      */

77     public static final String JavaDoc AFTER_STOP_EVENT = "after_stop";
78
79
80     /**
81      * The LifecycleEvent type for the "component destroy" event.
82      */

83     public static final String JavaDoc DESTROY_EVENT = "destroy";
84
85
86     /**
87      * The LifecycleEvent type for the "periodic" event.
88      */

89     public static final String JavaDoc PERIODIC_EVENT = "periodic";
90
91
92     // --------------------------------------------------------- Public Methods
93

94
95     /**
96      * Add a LifecycleEvent listener to this component.
97      *
98      * @param listener The listener to add
99      */

100     public void addLifecycleListener(LifecycleListener listener);
101
102
103     /**
104      * Get the lifecycle listeners associated with this lifecycle. If this
105      * Lifecycle has no listeners registered, a zero-length array is returned.
106      */

107     public LifecycleListener[] findLifecycleListeners();
108
109
110     /**
111      * Remove a LifecycleEvent listener from this component.
112      *
113      * @param listener The listener to remove
114      */

115     public void removeLifecycleListener(LifecycleListener listener);
116
117
118     /**
119      * Prepare for the beginning of active use of the public methods of this
120      * component. This method should be called before any of the public
121      * methods of this component are utilized. It should also send a
122      * LifecycleEvent of type START_EVENT to any registered listeners.
123      *
124      * @exception LifecycleException if this component detects a fatal error
125      * that prevents this component from being used
126      */

127     public void start() throws LifecycleException;
128
129
130     /**
131      * Gracefully terminate the active use of the public methods of this
132      * component. This method should be the last one called on a given
133      * instance of this component. It should also send a LifecycleEvent
134      * of type STOP_EVENT to any registered listeners.
135      *
136      * @exception LifecycleException if this component detects a fatal error
137      * that needs to be reported
138      */

139     public void stop() throws LifecycleException;
140
141
142 }
143
Popular Tags