01: /*
02: * Copyright 2002-2007 the original author or authors.
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: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.context;
18:
19: /**
20: * Interface defining methods for start/stop lifecycle control.
21: * The typical use case for this is to control asynchronous processing.
22: *
23: * <p>Can be implemented by both components (typically a Spring bean defined in
24: * a Spring {@link org.springframework.beans.factory.BeanFactory}) and containers
25: * (typically a Spring {@link ApplicationContext}). Containers will propagate
26: * start/stop signals to all components that apply.
27: *
28: * <p>Can be used for direct invocations or for management operations via JMX.
29: * In the latter case, the {@link org.springframework.jmx.export.MBeanExporter}
30: * will typically be defined with an
31: * {@link org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler},
32: * restricting the visibility of activity-controlled components to the Lifecycle
33: * interface.
34: *
35: * @author Juergen Hoeller
36: * @since 2.0
37: * @see ConfigurableApplicationContext
38: * @see org.springframework.jms.listener.AbstractMessageListenerContainer
39: * @see org.springframework.scheduling.quartz.SchedulerFactoryBean
40: */
41: public interface Lifecycle {
42:
43: /**
44: * Start this component.
45: * Should not throw an exception if the component is already running.
46: * <p>In the case of a container, this will propagate the start signal
47: * to all components that apply.
48: */
49: void start();
50:
51: /**
52: * Stop this component.
53: * Should not throw an exception if the component isn't started yet.
54: * <p>In the case of a container, this will propagate the stop signal
55: * to all components that apply.
56: */
57: void stop();
58:
59: /**
60: * Check whether this component is currently running.
61: * <p>In the case of a container, this will return <code>true</code>
62: * only if <i>all</i> components that apply are currently running.
63: * @return whether the component is currently running
64: */
65: boolean isRunning();
66:
67: }
|