01: // ========================================================================
02: // Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
03: // ------------------------------------------------------------------------
04: // Licensed under the Apache License, Version 2.0 (the "License");
05: // you may not use this file except in compliance with the License.
06: // You may obtain a copy of the License at
07: // http://www.apache.org/licenses/LICENSE-2.0
08: // Unless required by applicable law or agreed to in writing, software
09: // distributed under the License is distributed on an "AS IS" BASIS,
10: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11: // See the License for the specific language governing permissions and
12: // limitations under the License.
13: // ========================================================================
14:
15: package org.mortbay.component;
16:
17: /* ------------------------------------------------------------ */
18: /**
19: * The lifecycle interface for generic components.
20: * <br />
21: * Classes implementing this interface have a defined life cycle
22: * defined by the methods of this interface.
23: *
24: * @author Greg Wilkins (gregw)
25: */
26: public interface LifeCycle {
27: /* ------------------------------------------------------------ */
28: /**
29: * Starts the component.
30: * @throws Exception If the component fails to start
31: * @see #isStarted()
32: * @see #stop()
33: * @see #isFailed()
34: */
35: public void start() throws Exception;
36:
37: /* ------------------------------------------------------------ */
38: /**
39: * Stops the component.
40: * The component may wait for current activities to complete
41: * normally, but it can be interrupted.
42: * @exception Exception If the component fails to stop
43: * @see #isStopped()
44: * @see #start()
45: * @see #isFailed()
46: */
47: public void stop() throws Exception;
48:
49: /* ------------------------------------------------------------ */
50: /**
51: * @return true if the component is starting or has been started.
52: */
53: public boolean isRunning();
54:
55: /* ------------------------------------------------------------ */
56: /**
57: * @return true if the component has been started.
58: * @see #start()
59: * @see #isStarting()
60: */
61: public boolean isStarted();
62:
63: /* ------------------------------------------------------------ */
64: /**
65: * @return true if the component is starting.
66: * @see #isStarted()
67: */
68: public boolean isStarting();
69:
70: /* ------------------------------------------------------------ */
71: /**
72: * @return true if the component is stopping.
73: * @see #isStopped()
74: */
75: public boolean isStopping();
76:
77: /* ------------------------------------------------------------ */
78: /**
79: * @return true if the component has been stopped.
80: * @see #stop()
81: * @see #isStopping()
82: */
83: public boolean isStopped();
84:
85: /* ------------------------------------------------------------ */
86: /**
87: * @return true if the component has failed to start or has failed to stop.
88: */
89: public boolean isFailed();
90: }
|