Package io.milton.context
Class Context
- java.lang.Object
-
- io.milton.context.Context
-
- All Implemented Interfaces:
Contextual
- Direct Known Subclasses:
RequestContext,RootContext
public abstract class Context extends Object implements Contextual
Basic context functionality. Use either a RootContext or RequestContext
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<Class,Registration>itemByClassprotected HashMap<String,Registration>itemByName
-
Constructor Summary
Constructors Modifier Constructor Description protectedContext()Used by subclasses
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tget(Class<T> c)<T> Tget(String id)protected <T> Registration<T>getRegistration(Class<T> c)protected <T> Registration<T>getRegistration(String id)intnumItemsById()<T> Registration<T>put(String id, T o)Place o into context, keying by the given id<T> Registration<T>put(String id, T o, Factory f)Put the given object into context, keying only the given id<T> Registration<T>put(T o)Place the given object into context, keying only by its class<T> Registration<T>put(T o, RemovalCallback f)voidtearDown()
-
-
-
Field Detail
-
itemByClass
protected HashMap<Class,Registration> itemByClass
-
itemByName
protected HashMap<String,Registration> itemByName
-
-
Method Detail
-
numItemsById
public int numItemsById()
-
get
public <T> T get(String id)
- Specified by:
getin interfaceContextual
-
get
public <T> T get(Class<T> c)
- Specified by:
getin interfaceContextual
-
getRegistration
protected <T> Registration<T> getRegistration(Class<T> c)
-
getRegistration
protected <T> Registration<T> getRegistration(String id)
-
put
public <T> Registration<T> put(String id, T o)
Place o into context, keying by the given id- Type Parameters:
T-- Parameters:
id-o-- Returns:
-
put
public <T> Registration<T> put(T o)
Place the given object into context, keying only by its class
-
put
public <T> Registration<T> put(T o, RemovalCallback f)
-
put
public <T> Registration<T> put(String id, T o, Factory f)
Put the given object into context, keying only the given id
-
tearDown
public void tearDown()
-
-