public class ActivityScopedFactoryBeanHandler extends java.lang.Object implements ScopedFactoryBeanHandler
ScopedFactoryBeanHandler for the "activity"-scope.
It provides a bean-instance per Activity, always scoped to the
foregraound-activity. Due to the limitation of the
ViewModelProviders this only works for subtypes of FragmentActivity such as the
android.support.v7.app.AppCompatActivity.
The ActivityScopedFactoryBeanHandler supports the ActivityAware-interface.
| Modifier and Type | Class and Description |
|---|---|
static class |
ActivityScopedFactoryBeanHandler.ActivityScopedBeanHolder<T> |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACTIVITY_SCOPE
The name of the
Activity-scope. |
| Constructor and Description |
|---|
ActivityScopedFactoryBeanHandler(ForegroundActivityHolder foregroundActivityHolder) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
getBean(java.lang.String name,
ScopedFactoryBean<T> factoryBean)
Returns the bean defined by the given
ScopedFactoryBean. |
java.lang.String |
getName()
Returns the name of the scope.
|
boolean |
isActive()
Checks whether the scope is active, i.e.
|
public static final java.lang.String ACTIVITY_SCOPE
Activity-scope.public ActivityScopedFactoryBeanHandler(ForegroundActivityHolder foregroundActivityHolder)
public java.lang.String getName()
ScopedFactoryBeanHandlergetName in interface ScopedFactoryBeanHandlerpublic boolean isActive()
ScopedFactoryBeanHandlerisActive in interface ScopedFactoryBeanHandlertrue or false whether the scope is active@Nullable
public <T> T getBean(java.lang.String name,
ScopedFactoryBean<T> factoryBean)
ScopedFactoryBeanHandlerScopedFactoryBean.
The bean can be an existing one already lining in this scope, if so. Otherwise a new bean is created by the
factoryBean.
Note: This method may only be called, when the scope is active.
getBean in interface ScopedFactoryBeanHandlerT - the type of the beanname - the name of the bean, which is equal to the name of the factory beanfactoryBean - the factory bean to produce the desired bean