Package pl.morgwai.base.guice.scopes
Classes for building Guice
Scope
s, that get automatically transferred
when dispatching work to other threads.
Code organization guidelines for deriving libs:
Deriving libs should usually define their "central class" extending
Module
containing the following:
- instances of
ContextTracker
s for all definedTrackableContext
subclasses - instances of corresponding
ContextScope
s List<ContextTracker<?>> allTrackers
instance var containing all the aboveContextTracker
instancesContextBinder
contextBinder = new ContextBinder(allTrackers)
instance vargetActiveContexts()
method returningContextTracker.getActiveContexts(allTrackers)
-
configure(binder)
method that creates the following bindings:List<ContextTracker<?>>
toallTrackers
ContextBinder
tocontextBinder
- Their respective types to the defined
ContextTracker
instances - Their respective types to
Provider
s of the definedContext
instances, usually defined similarly to 1 of the below:- for
TrackableContext
s:respectiveTrackerInstance::getCurrentContext
- for induced
InjectionContext
s:() -> inducingContextTracker.getCurrentContext().getRespectiveInducedContext()
- for
- See Also:
- project homepage
-
Class Summary Class Description ContextBinder Binds closures toContexts
that were active at the time of a given binding.ContextBoundBiConsumer<T,U> A decorator that executes its wrappedBiConsumer
within suppliedContexts
.ContextBoundBiFunction<T,U,R> A decorator that executes its wrappedBiFunction
within suppliedContexts
.ContextBoundCallable<T> A decorator that executes its wrappedCallable
within suppliedContexts
.ContextBoundClosure<ClosureT> Base class for decorators that execute their wrapped closures within suppliedContexts
.ContextBoundConsumer<T> A decorator that executes its wrappedConsumer
within suppliedContexts
.ContextBoundFunction<T,R> A decorator that executes its wrappedFunction
within suppliedContexts
.ContextBoundRunnable A decorator that executes its wrappedRunnable
within suppliedContexts
.ContextBoundSupplier<T> A decorator that executes its wrappedSupplier
within suppliedContexts
.ContextScope<ContextT extends TrackableContext<? super ContextT>> Scopes objects to theContext
that is current during a givenprovisioning
.ContextTracker<ContextT extends TrackableContext<? super ContextT>> Allows to track whichThread
is running within whichContext
.InducedContextScope<BaseContextT extends TrackableContext<? super BaseContextT>,InducedContextT extends InjectionContext> Scopes objects to theInducedContextT
instance induced by the instance ofBaseContextT
current during a givenprovisioning
.InjectionContext Stores objectsscoped
to the context of some event/call/request/session, such as an RPC, a servlet request processing, a session combining several events etc.TrackableContext<ContextT extends TrackableContext<ContextT>> AnInjectionContext
that canexecute tasks within itself
, so that it can be tracked acrossThreads
using its associatedContextTracker
.