Class AutoCloseableLifecycleComponent
- java.lang.Object
-
- org.apache.bookkeeper.common.component.AutoCloseableLifecycleComponent
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,LifecycleComponent
public class AutoCloseableLifecycleComponent extends java.lang.Object implements LifecycleComponent
Allows for AutoClosable resources to be added to the component lifecycle without having to implement ServerLifecycleComponent directly.
-
-
Field Summary
Fields Modifier and Type Field Description protected Lifecycle
lifecycle
protected java.lang.Thread.UncaughtExceptionHandler
uncaughtExceptionHandler
-
Constructor Summary
Constructors Constructor Description AutoCloseableLifecycleComponent(java.lang.String componentName, java.lang.AutoCloseable closeable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLifecycleListener(LifecycleListener listener)
void
close()
java.lang.String
getName()
Lifecycle.State
lifecycleState()
void
removeLifecycleListener(LifecycleListener listener)
void
setExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Set the default handler invoked when a lifecycle component abruptly terminates due an uncaught exception.void
start()
void
stop()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.common.component.LifecycleComponent
publishInfo
-
-
-
-
Field Detail
-
lifecycle
protected final Lifecycle lifecycle
-
uncaughtExceptionHandler
protected volatile java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceLifecycleComponent
-
setExceptionHandler
public void setExceptionHandler(java.lang.Thread.UncaughtExceptionHandler handler)
Description copied from interface:LifecycleComponent
Set the default handler invoked when a lifecycle component abruptly terminates due an uncaught exception.- Specified by:
setExceptionHandler
in interfaceLifecycleComponent
- Parameters:
handler
- handler invoked when an uncaught exception happens in the lifecycle component.
-
lifecycleState
public Lifecycle.State lifecycleState()
- Specified by:
lifecycleState
in interfaceLifecycleComponent
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
- Specified by:
addLifecycleListener
in interfaceLifecycleComponent
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
- Specified by:
removeLifecycleListener
in interfaceLifecycleComponent
-
start
public void start()
- Specified by:
start
in interfaceLifecycleComponent
-
stop
public void stop()
- Specified by:
stop
in interfaceLifecycleComponent
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceLifecycleComponent
-
-