MCPcopy Index your code
hub / github.com/apache/tomcat / LifecycleBase

Class LifecycleBase

java/org/apache/catalina/util/LifecycleBase.java:36–417  ·  view source on GitHub ↗

Base implementation of the Lifecycle interface that implements the state transition rules for Lifecycle#start() and Lifecycle#stop()

Source from the content-addressed store, hash-verified

34 * {@link Lifecycle#start()} and {@link Lifecycle#stop()}
35 */
36public abstract class LifecycleBase implements Lifecycle {
37
38 /**
39 * Default constructor.
40 */
41 public LifecycleBase() {
42 }
43
44 private static final Log log = LogFactory.getLog(LifecycleBase.class);
45
46 private static final StringManager sm = StringManager.getManager(LifecycleBase.class);
47
48
49 /**
50 * The list of registered LifecycleListeners for event notifications.
51 */
52 private final List<LifecycleListener> lifecycleListeners = new CopyOnWriteArrayList<>();
53
54
55 /**
56 * The current state of the source component.
57 */
58 private volatile LifecycleState state = LifecycleState.NEW;
59
60
61 private boolean throwOnFailure = true;
62
63
64 /**
65 * Will a {@link LifecycleException} thrown by a subclass during {@link #initInternal()}, {@link #startInternal()},
66 * {@link #stopInternal()} or {@link #destroyInternal()} be re-thrown for the caller to handle or will it be logged
67 * instead?
68 *
69 * @return {@code true} if the exception will be re-thrown, otherwise {@code false}
70 */
71 public boolean getThrowOnFailure() {
72 return throwOnFailure;
73 }
74
75
76 /**
77 * Configure if a {@link LifecycleException} thrown by a subclass during {@link #initInternal()},
78 * {@link #startInternal()}, {@link #stopInternal()} or {@link #destroyInternal()} will be re-thrown for the caller
79 * to handle or if it will be logged instead.
80 *
81 * @param throwOnFailure {@code true} if the exception should be re-thrown, otherwise {@code false}
82 */
83 public void setThrowOnFailure(boolean throwOnFailure) {
84 this.throwOnFailure = throwOnFailure;
85 }
86
87
88 @Override
89 public void addLifecycleListener(LifecycleListener listener) {
90 lifecycleListeners.add(listener);
91 }
92
93

Callers

nothing calls this directly

Calls 2

getLogMethod · 0.95
getManagerMethod · 0.95

Tested by

no test coverage detected