Package org.movealong.sly.app
Class App
- java.lang.Object
-
- org.movealong.sly.app.App
-
public final class App extends Object
A- See Also:
Service,ServiceHandle
-
-
Constructor Summary
Constructors Constructor Description App()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,App,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<App>>bind(ServiceHandle<S> handle, Service<S> service)Binds aServiceto aServiceHandle.static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,S,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<S>>resolve(Service<S> service)Resolves a service.static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,S,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<S>>resolve(ServiceHandle<S> handle)Resolves a service by itsServiceHandle.static <R,F extends com.jnape.palatable.lambda.functor.Functor<?,F>,FR extends com.jnape.palatable.lambda.functor.Functor<R,F>,A extends Runner<R,F,FR>>
FRrun(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,A,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<A>> application)Runs an application in the form of an application function that yields nRunnerthat produces aFunctorthat bears the ultimate return type.static <S extends Starter<com.jnape.palatable.lambda.io.IO<?>>>
voidstart(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,S,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<S>> application)Starts an application in the form of an application function that yields aStarter, which in turn handles starting and stopping the long-running components of the application.
-
-
-
Method Detail
-
bind
public static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,App,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<App>> bind(ServiceHandle<S> handle, Service<S> service)
Binds aServiceto aServiceHandle. Binding a service to a handle makes the service accessible to other services via resolution. A handle can only be bound once, and rebinding a handle will result in an exception. The service that the supplied handle is bound to it may not resolve other handles that are bound to services that resolve the supplied handle, including indirectly. This will not cause an error immediately, but will if any handle in the cycle is later resolved.- Type Parameters:
S- the service type- Parameters:
handle- theServiceHandleto bind the service toservice- theServicebeing bound- Returns:
- A
Kleislifunction that forms part of the composition of an application
-
resolve
public static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,S,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<S>> resolve(Service<S> service)
Resolves a service. Composing aKleislireturned fromresolveonto aKleislicomposed of one or morebindcalls will produce an application function suitable for use withrunorstart.- Type Parameters:
S- the service object type- Parameters:
service- theService- Returns:
- An application function
-
resolve
public static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,S,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<S>> resolve(ServiceHandle<S> handle)
Resolves a service by itsServiceHandle. The handle must have been previously bound usingbindto aServicethat has a carrier of typeS. Composing aKleislireturned fromresolveonto aKleislicomposed of one or morebindcalls will produce an application function suitable for use withrun.- Type Parameters:
S- theRunnertype- Parameters:
handle- handle for the application service- Returns:
- An application function
-
run
public static <R,F extends com.jnape.palatable.lambda.functor.Functor<?,F>,FR extends com.jnape.palatable.lambda.functor.Functor<R,F>,A extends Runner<R,F,FR>> FR run(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,A,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<A>> application)
Runs an application in the form of an application function that yields nRunnerthat produces aFunctorthat bears the ultimate return type.runwill perform theIOthat results from applying the function exactly once, throw an exception if thatIOis in its error mode, and otherwise return theIO's result.- Type Parameters:
R- carrier type of the application returnF-Functortype of the application returnFR- the application return typeA- theRunnertype- Parameters:
application- theKleislifunction representing the application- Returns:
- the result of running the application
-
start
public static <S extends Starter<com.jnape.palatable.lambda.io.IO<?>>> void start(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,S,com.jnape.palatable.lambda.io.IO<?>,com.jnape.palatable.lambda.io.IO<S>> application)
Starts an application in the form of an application function that yields aStarter, which in turn handles starting and stopping the long-running components of the application.- Type Parameters:
S- theStartertype- Parameters:
application- the application function
-
-