Class KiwiDropwizardLifecycles
- java.lang.Object
-
- org.kiwiproject.dropwizard.lifecycle.KiwiDropwizardLifecycles
-
public class KiwiDropwizardLifecycles extends Object
Provides utilities related to the Dropwizard lifecycle.
-
-
Constructor Summary
Constructors Constructor Description KiwiDropwizardLifecycles()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidmanage(io.dropwizard.lifecycle.setup.LifecycleEnvironment lifecycle, Runnable startAction, Runnable stopAction)Creates a DropwizardManagedwhose start action isstartActionand whose stop action isstopAction, and attaches it to the given Dropwizardlifecycle.
-
-
-
Method Detail
-
manage
public static void manage(io.dropwizard.lifecycle.setup.LifecycleEnvironment lifecycle, Runnable startAction, Runnable stopAction)Creates a DropwizardManagedwhose start action isstartActionand whose stop action isstopAction, and attaches it to the given Dropwizardlifecycle.Useful when you have some external object that has start and stop methods, but you don't want to clutter your code by creating an anonymous inner class just to specify the start and stop actions. For example if you have an ActiveMQ
PooledConnectionFactory(which hasstartandstopmethods) you can simply call this method:KiwiDropwizardLifecycles.manage(lifecycle, () -> factory.start(), () -> factory.stop());To make the code cleaner, use method references:
KiwiDropwizardLifecycles.manage(lifecycle, factory::start, factory::stop);- Parameters:
lifecycle- the lifecycle to managestartAction- the action to run when Dropwizard starts the applicationstopAction- the action to run when Dropwizard stops the application
-
-