Package pl.morgwai.base.guice.scopes
Class ContextScope<CtxT extends TrackableContext<CtxT>>
- java.lang.Object
-
- pl.morgwai.base.guice.scopes.ContextScope<CtxT>
-
- All Implemented Interfaces:
Scope
- Direct Known Subclasses:
InducedContextScope
public class ContextScope<CtxT extends TrackableContext<CtxT>> extends Object implements Scope
Scopes objects to the current context obtained from the associatedContextTracker
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ContextScope.ScopedProvider<T>
Returned byscope(Key, Provider)
, provides objects obtained from the current context.
-
Field Summary
Fields Modifier and Type Field Description protected ContextTracker<CtxT>
tracker
-
Constructor Summary
Constructors Constructor Description ContextScope(String name, ContextTracker<CtxT> tracker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InjectionContext
getContext()
Returns a context instance from which scoped objects should be obtained by this Scope.String
getName()
<T> Provider<T>
scope(Key<T> key, Provider<T> unscoped)
String
toString()
-
-
-
Field Detail
-
tracker
protected final ContextTracker<CtxT extends TrackableContext<CtxT>> tracker
-
-
Constructor Detail
-
ContextScope
public ContextScope(String name, ContextTracker<CtxT> tracker)
-
-
Method Detail
-
getName
public String getName()
-
scope
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped)
- Specified by:
scope
in interfaceScope
- Returns:
- a
ContextScope.ScopedProvider
.
-
getContext
protected InjectionContext getContext()
Returns a context instance from which scoped objects should be obtained by this Scope. By default returns directly the context obtained fromtracker
. May be overridden to return some context induced by the one from thetracker
.- See Also:
InducedContextScope
-
-