public interface BeanContext
BeanIdStore
to optimize the access performance. If
all the BeanId
objects are registered with the BeanIdStore before this object
is created then you get 'direct access' performance.
For performance reasons it is best to register all BeanId objects up front. Because
if new BeanId objects are registered after the BeanContext is created then the BeanContext
needs to do synchronize with the BeanIdStore,
It is possible to get the bean by it's bean id String name. However this isn't as
fast as using the BeanId objects.Modifier and Type | Method and Description |
---|---|
void |
addBean(BeanId beanId,
Object bean)
Add a bean instance under the specified
BeanId . |
void |
addBean(BeanId beanId,
Object bean,
Fragment source)
Add a bean instance under the specified beanId string.
|
void |
addBean(String beanId,
Object bean)
Add a bean instance under the specified beanId.
|
void |
addBean(String beanId,
Object bean,
Fragment source)
Add a bean instance under the specified beanId.
|
void |
addObserver(BeanContextLifecycleObserver observer)
Registers a bean context observer.
|
void |
changeBean(BeanId beanId,
Object bean,
Fragment source)
Changes a bean instance of the given
BeanId . |
void |
clear()
Removes all the beans from the bean map
|
boolean |
containsBean(BeanId beanId)
Looks if a bean instance is set under the
BeanId |
Object |
getBean(BeanId beanId)
Get the current bean, specified by the supplied
BeanId . |
<T> T |
getBean(Class<T> beanType)
Returns the bean by it's beanId name.
|
Object |
getBean(String beanId)
Returns the bean by it's beanId name.
|
BeanId |
getBeanId(String beanId)
Get the
BeanId instance for the specified beanId String. |
Map<String,Object> |
getBeanMap()
This returns a map which is backed by this repository.
|
BeanContext |
newSubContext(ExecutionContext executionContext)
|
void |
notifyObservers(BeanContextLifecycleEvent event)
Notify all observers of a specific bean lifecycle event.
|
Object |
removeBean(BeanId beanId,
Fragment source)
Removes a bean and all its associated lifecycle beans from the bean map
|
Object |
removeBean(String beanId,
Fragment source)
Removes a bean and all its associated lifecycle beans from the bean map
|
void |
removeObserver(BeanContextLifecycleObserver observer)
Unregisters a bean observer.
|
void |
setBeanInContext(BeanId beanId,
boolean inContext)
Mark the bean as being in context.
|
String |
toString() |
void addBean(BeanId beanId, Object bean)
BeanId
.beanId
- The BeanId
under which the bean is to be stored.bean
- The bean instance to be stored.void addBean(BeanId beanId, Object bean, Fragment source)
BeanId
in the background.beanId
- The BeanId
under which the bean is to be stored.bean
- The bean instance to be stored.source
- Source fragment.void addBean(String beanId, Object bean)
BeanId
instance
for the beanId String and then use the addBean(BeanId, Object, Fragment)
method.beanId
- The beanId under which the bean is to be stored.bean
- The bean instance to be stored.void addBean(String beanId, Object bean, Fragment source)
BeanId
instance
for the beanId String and then use the addBean(BeanId, Object, Fragment)
method.beanId
- The beanId under which the bean is to be stored.bean
- The bean instance to be stored.source
- Source fragment.BeanId getBeanId(String beanId)
BeanId
instance for the specified beanId String.
Regsiters the beanId if it's not already registered.beanId
- The beanId String.BeanId
instance.boolean containsBean(BeanId beanId)
BeanId
beanId
- The BeanId
under which is looked.Object getBean(BeanId beanId)
BeanId
.
beanId
- The BeanId
of the bean to be returned.null
.Object getBean(String beanId)
beanId
- The type of the bean to be returned.null
.<T> T getBean(Class<T> beanType)
beanType
- The type of the bean to be returned.null
.void changeBean(BeanId beanId, Object bean, Fragment source)
BeanId
. The difference to addBean(BeanId, Object)
is that the bean must exist, the associated beans aren't removed and the observers of the
BeanLifecycle.CHANGE
event are notified.beanId
- The BeanId
under which the bean instance is to be stored.bean
- The bean instance to be stored.source
- Source fragment.Object removeBean(BeanId beanId, Fragment source)
beanId
- The beanId to remove the beans from.source
- Source fragment.Object removeBean(String beanId, Fragment source)
beanId
- The beanId to remove the beans from.source
- Source fragment.void clear()
void addObserver(BeanContextLifecycleObserver observer)
observer
- The actual BeanObserver instance.void notifyObservers(BeanContextLifecycleEvent event)
event
- The event.void removeObserver(BeanContextLifecycleObserver observer)
observer
- The actual BeanObserver instance.Map<String,Object> getBeanMap()
void setBeanInContext(BeanId beanId, boolean inContext)
beanId
- The bean ID.inContext
- True if the bean is in context, otherwise false.BeanContext newSubContext(ExecutionContext executionContext)
executionContext
- The Associated ExecutionContext
.BeanContext
.Copyright © 2020. All rights reserved.