Package pl.morgwai.base.guice.scopes
Class TrackableContext<CtxT extends TrackableContext<CtxT>>
- java.lang.Object
-
- pl.morgwai.base.guice.scopes.ServerSideContext
-
- pl.morgwai.base.guice.scopes.TrackableContext<CtxT>
-
public abstract class TrackableContext<CtxT extends TrackableContext<CtxT>> extends ServerSideContext
AServerSideContext
that can be tracked across threads by executing closures within it.Overriding classes must use themselves as
CtxT
type argument.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TrackableContext(ContextTracker<CtxT> tracker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeWithinSelf(Runnable operation)
Sets itself as the current context for the current thread and executesoperation
synchronously.<T> T
executeWithinSelf(Callable<T> operation)
Sets itself as the current context for the current thread and executesoperation
synchronously.-
Methods inherited from class pl.morgwai.base.guice.scopes.ServerSideContext
removeScopedObject
-
-
-
-
Constructor Detail
-
TrackableContext
protected TrackableContext(ContextTracker<CtxT> tracker)
-
-
Method Detail
-
executeWithinSelf
public void executeWithinSelf(Runnable operation)
Sets itself as the current context for the current thread and executesoperation
synchronously. Afterwards clears the current context.
-
executeWithinSelf
public <T> T executeWithinSelf(Callable<T> operation) throws Exception
Sets itself as the current context for the current thread and executesoperation
synchronously. Afterwards clears the current context.- Throws:
Exception
- See Also:
ContextTrackingExecutor.executeWithinAll(java.util.List, Callable)
-
-