public class SimpleInstanceStore extends java.lang.Object implements InstanceStore
| Modifier and Type | Field and Description |
|---|---|
protected Context |
context |
protected InstanceFactory |
instanceFactory |
| Constructor and Description |
|---|
SimpleInstanceStore(Context context,
InstanceFactory instanceFactory) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Object> |
allByAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
Context context)
Return a map of all bean instances annotated with the specified annotation
|
<T> T[] |
allByType(java.lang.Class<T> type,
Context context,
boolean create)
Return an array of all bean instances implementing the expected type
|
java.util.List<java.lang.String> |
allNames()
Return all bean names set in this container
|
<T> T |
byName(java.lang.String name,
Context context)
Lookup a bean by its name
The implementation is free to create and return a default instance (such as a service proxy) if no bean exists
|
<T> T |
byType(java.lang.Class<T> type,
Context context)
Lookup a bean by its type
If more than one instance is found, should throw a runtime exception
|
void |
clear()
Clear all beans from the container
Not applicable to statically configured containers (Spring/CDI)
|
protected java.lang.Object |
createInstance() |
boolean |
exists(java.lang.String name)
Indicate if a bean of the specified name exists in the store
|
<T> T |
getNoProxy(java.lang.String name,
Context context)
Lookup a bean by its name
Does not create a proxy if no bean found
|
void |
init() |
void |
inject(java.lang.Object target,
java.lang.String componentName,
java.util.Map<java.lang.String,java.lang.Object> properties)
Inject context value into provided instance
|
void |
remove(java.lang.Object instance)
Remove a bean from the container
Not applicable to statically configured containers (Spring/CDI)
|
void |
remove(java.lang.String name)
Remove a bean from the container
Not applicable to statically configured containers (Spring/CDI)
|
<T> T |
set(java.lang.String name,
T instance)
Set a named bean in the container
Not applicable to statically configured containers (Spring/CDI)
|
<T> T |
set(T instance)
Set a bean in the container without specifying a name
Not applicable to statically configured containers (Spring/CDI)
The bean will be accessible only by its type
|
protected final Context context
protected final InstanceFactory instanceFactory
public SimpleInstanceStore(Context context, InstanceFactory instanceFactory)
public void init()
init in interface InstanceStorepublic <T> T set(java.lang.String name,
T instance)
InstanceStoreset in interface InstanceStoreT - bean typename - bean nameinstance - bean instancepublic <T> T set(T instance)
InstanceStoreset in interface InstanceStoreT - bean typeinstance - bean instancepublic void remove(java.lang.String name)
InstanceStoreremove in interface InstanceStorename - bean namepublic void remove(java.lang.Object instance)
InstanceStoreremove in interface InstanceStoreinstance - bean instancepublic void clear()
InstanceStoreclear in interface InstanceStorepublic java.util.List<java.lang.String> allNames()
InstanceStoreallNames in interface InstanceStorepublic <T> T getNoProxy(java.lang.String name,
Context context)
InstanceStoregetNoProxy in interface InstanceStoreT - bean typename - bean namecontext - context to lookuppublic boolean exists(java.lang.String name)
InstanceStoreexists in interface InstanceStorename - component namepublic <T> T byName(java.lang.String name,
Context context)
InstanceStorebyName in interface InstanceStoreT - expected bean typename - bean namecontext - context to lookupprotected java.lang.Object createInstance()
public <T> T byType(java.lang.Class<T> type,
Context context)
InstanceStorebyType in interface InstanceStoreT - expected bean typetype - expected bean typecontext - context to lookuppublic <T> T[] allByType(java.lang.Class<T> type,
Context context,
boolean create)
InstanceStoreallByType in interface InstanceStoreT - expected bean typetype - expected bean typecontext - context to lookupcreate - if true, should create an instance if none is existingpublic java.util.Map<java.lang.String,java.lang.Object> allByAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
Context context)
InstanceStoreallByAnnotatedWith in interface InstanceStoreannotationClass - annotationcontext - context to lookuppublic void inject(java.lang.Object target,
java.lang.String componentName,
java.util.Map<java.lang.String,java.lang.Object> properties)
InstanceStoreinject in interface InstanceStoretarget - instance to inject intocomponentName - component nameproperties - properties defined on the context