@Singleton @Requires(notEnv={"function","android"}) public class RefreshScope extends Object implements CustomScope<Refreshable>, LifeCycle<RefreshScope>, ApplicationEventListener<RefreshEvent>
Refreshable
.Refreshable
,
RefreshEvent
Constructor and Description |
---|
RefreshScope(BeanContext beanContext,
Executor executorService) |
Modifier and Type | Method and Description |
---|---|
Class<Refreshable> |
annotationType() |
<T> Optional<BeanRegistration<T>> |
findBeanRegistration(T bean)
Get the
BeanDefinition for the given bean. |
<T> T |
get(BeanResolutionContext resolutionContext,
BeanDefinition<T> beanDefinition,
BeanIdentifier identifier,
Provider<T> provider)
Resolve an object from the given scope.
|
protected ReadWriteLock |
getLock(Object object) |
boolean |
isRunning() |
void |
onApplicationEvent(RefreshEvent event)
Handle an application event.
|
void |
onRefreshEvent(RefreshEvent event)
Handle a
RefreshEvent synchronously. |
<T> Optional<T> |
remove(BeanIdentifier identifier)
Remove a bean definition from the scope.
|
RefreshScope |
stop()
Stops the life cycle component.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
supports
public RefreshScope(BeanContext beanContext, @Named(value="io") Executor executorService)
beanContext
- The bean context to allow DI of beans annotated with Inject
executorService
- The executor servicepublic boolean isRunning()
isRunning
in interface LifeCycle<RefreshScope>
public Class<Refreshable> annotationType()
annotationType
in interface CustomScope<Refreshable>
public <T> T get(BeanResolutionContext resolutionContext, BeanDefinition<T> beanDefinition, BeanIdentifier identifier, Provider<T> provider)
CustomScope
get
in interface CustomScope<Refreshable>
T
- The bean generic typeresolutionContext
- The bean resolution contextbeanDefinition
- The bean definitionidentifier
- The BeanIdentifier
provider
- The provider that will build the bean definitionpublic RefreshScope stop()
LifeCycle
stop
in interface LifeCycle<RefreshScope>
public <T> Optional<T> remove(BeanIdentifier identifier)
CustomScope
remove
in interface CustomScope<Refreshable>
T
- The generic typeidentifier
- The BeanIdentifier
Optional
of the instance if it existspublic void onApplicationEvent(RefreshEvent event)
ApplicationEventListener
onApplicationEvent
in interface ApplicationEventListener<RefreshEvent>
event
- the event to respond topublic final void onRefreshEvent(RefreshEvent event)
RefreshEvent
synchronously. This method blocks unlike onApplicationEvent(RefreshEvent)
.event
- The eventpublic <T> Optional<BeanRegistration<T>> findBeanRegistration(T bean)
CustomScope
BeanDefinition
for the given bean.findBeanRegistration
in interface CustomScope<Refreshable>
T
- The bean generic typebean
- The beanprotected ReadWriteLock getLock(Object object)
object
- The bean