1
// ========================================================================
2
// Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
3
// ------------------------------------------------------------------------
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
8
// Unless required by applicable law or agreed to in writing, software
9
// 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
// ========================================================================
15
package org.mortbay.component;
17
import java.util.EventListener;
19
import org.mortbay.util.LazyList;
21
/* ------------------------------------------------------------ */
23
* The lifecycle interface for generic components.
25
* Classes implementing this interface have a defined life cycle
26
* defined by the methods of this interface.
28
* @author Greg Wilkins (gregw)
30
public interface LifeCycle
32
/* ------------------------------------------------------------ */
34
* Starts the component.
35
* @throws Exception If the component fails to start
43
/* ------------------------------------------------------------ */
45
* Stops the component.
46
* The component may wait for current activities to complete
47
* normally, but it can be interrupted.
48
* @exception Exception If the component fails to stop
56
/* ------------------------------------------------------------ */
58
* @return true if the component is starting or has been started.
60
public boolean isRunning();
62
/* ------------------------------------------------------------ */
64
* @return true if the component has been started.
68
public boolean isStarted();
70
/* ------------------------------------------------------------ */
72
* @return true if the component is starting.
75
public boolean isStarting();
77
/* ------------------------------------------------------------ */
79
* @return true if the component is stopping.
82
public boolean isStopping();
84
/* ------------------------------------------------------------ */
86
* @return true if the component has been stopped.
90
public boolean isStopped();
92
/* ------------------------------------------------------------ */
94
* @return true if the component has failed to start or has failed to stop.
96
public boolean isFailed();
98
/* ------------------------------------------------------------ */
99
public void addLifeCycleListener(LifeCycle.Listener listener);
101
/* ------------------------------------------------------------ */
102
public void removeLifeCycleListener(LifeCycle.Listener listener);
105
/* ------------------------------------------------------------ */
107
* A listener for Lifecycle events.
109
public interface Listener extends EventListener
111
public void lifeCycleStarting(LifeCycle event);
112
public void lifeCycleStarted(LifeCycle event);
113
public void lifeCycleFailure(LifeCycle event,Throwable cause);
114
public void lifeCycleStopping(LifeCycle event);
115
public void lifeCycleStopped(LifeCycle event);