Package org.movealong.sly.app
Interface Starter<M extends com.jnape.palatable.lambda.monad.Monad<?,M>>
-
- Type Parameters:
M- the monad type
public interface Starter<M extends com.jnape.palatable.lambda.monad.Monad<?,M>>StarterandStopperform a mechanism for controlling an application component that requires set up and tear down. TheAppclass provides thestartmethod which properly invokes this functionality for components whose lifecycle runs matches the lifecycle of the application. However, it is also possible to useStarterandStopperat any time in an application's life to control the lifecycle of a component, for example to control one that is request- scoped.- See Also:
Stopper
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Starter<M>andThen(Starter<M> next)default <N extends com.jnape.palatable.lambda.monad.Monad<?,N>>
Starter<N>mapStarter(com.jnape.palatable.winterbourne.NaturalTransformation<M,N> trans)<MS extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,M>>
MSstart()Starts an application component, returning aStopperin a monadic context.static <M extends com.jnape.palatable.lambda.monad.Monad<?,M>>
Starter<M>starter(com.jnape.palatable.lambda.functions.Fn0<? extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,M>> starter)A convenience method for creating aStarterfrom a lambda expression.
-
-
-
Method Detail
-
start
<MS extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,M>> MS start()
Starts an application component, returning aStopperin a monadic context. The returnedStopperwill stop the application component when invoked. It is expected that the returnedStopperwill be invoked at the appropriate time, and failure to do so should be considered a resource leak.- Type Parameters:
MS- theStopperwrapped in the monad type- Returns:
- A stopper for the application component that has been started
-
andThen
default Starter<M> andThen(Starter<M> next)
Creates a newStarterwill composethisandnextso thatthisis started followed bynext. TheStopperthat this composedStarterreturns works in the reverse order, stopping the component managed bynextfirst and then the component managed bythis. This has the effect of nesting another application component's lifecycle within the boundaries of this one.
-
mapStarter
default <N extends com.jnape.palatable.lambda.monad.Monad<?,N>> Starter<N> mapStarter(com.jnape.palatable.winterbourne.NaturalTransformation<M,N> trans)
- Type Parameters:
N- the newMonadtype- Parameters:
trans- theNaturalTransformationto apply- Returns:
- A
Starterwith parametric typeN
-
starter
static <M extends com.jnape.palatable.lambda.monad.Monad<?,M>> Starter<M> starter(com.jnape.palatable.lambda.functions.Fn0<? extends com.jnape.palatable.lambda.monad.Monad<Stopper<M>,M>> starter)
A convenience method for creating aStarterfrom a lambda expression.- Type Parameters:
M- theMonadtype- Parameters:
starter- anFn0that implements thestartmethod- Returns:
- A
Starter
-
-