Package io.awspring.cloud.sqs
Class LifecycleHandler
java.lang.Object
io.awspring.cloud.sqs.LifecycleHandler
Handler for lifecycle methods. The singleton instance should be retrieved by using the
get()
method. This class is thread-safe.
Methods accept Object
instances and apply lifecycle methods then the SmartLifecycle
interface is
implemented. Can handle lifecycle actions either sequentially or in parallel, according to the
parallelLifecycle
property.- Since:
- 3.0
- Author:
- Tomaz Fernandes
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Execute theDisposableBean.destroy()
method if the provided object is aDisposableBean
instance.static LifecycleHandler
get()
Get the singleton instance for this class.boolean
Check whether a object is running if it's an instance ofSmartLifecycle
.void
manageLifecycle
(Consumer<SmartLifecycle> action, Object... objects) Execute the provided action if the provided objects areSmartLifecycle
instances.void
setParallelLifecycle
(boolean parallelLifecycle) Set whether lifecycle management should be handled in parallel or sequentially.void
Starts the provided objects that are aSmartLifecycle
instance.void
Starts the provided objects that are aSmartLifecycle
instance.
-
Method Details
-
get
Get the singleton instance for this class.- Returns:
- the instance.
-
setParallelLifecycle
public void setParallelLifecycle(boolean parallelLifecycle) Set whether lifecycle management should be handled in parallel or sequentially.- Parameters:
parallelLifecycle
- false to disable parallel lifecycle management.
-
manageLifecycle
Execute the provided action if the provided objects areSmartLifecycle
instances.- Parameters:
action
- the action.objects
- the objects.
-
start
Starts the provided objects that are aSmartLifecycle
instance.- Parameters:
objects
- the objects.
-
stop
Starts the provided objects that are aSmartLifecycle
instance.- Parameters:
objects
- the objects.
-
isRunning
Check whether a object is running if it's an instance ofSmartLifecycle
.- Parameters:
object
- the object to check.- Returns:
- whether the object is running, or true if it's not a
SmartLifecycle
instance.
-
dispose
Execute theDisposableBean.destroy()
method if the provided object is aDisposableBean
instance.- Parameters:
destroyable
- the object to destroy.
-