@Singleton @Requires(notEnv={"function","android"}) public class RefreshScope extends java.lang.Object implements CustomScope<Refreshable>, LifeCycle<RefreshScope>, ApplicationEventListener<RefreshEvent>
Refreshable
.Refreshable
,
RefreshEvent
Constructor and Description |
---|
RefreshScope(BeanContext beanContext,
java.util.concurrent.Executor executorService) |
Modifier and Type | Method and Description |
---|---|
java.lang.Class<Refreshable> |
annotationType() |
<T> java.util.Optional<BeanRegistration<T>> |
findBeanRegistration(T bean)
Get the
BeanDefinition for the given bean. |
<T> T |
get(BeanResolutionContext resolutionContext,
BeanDefinition<T> beanDefinition,
BeanIdentifier identifier,
javax.inject.Provider<T> provider)
Resolve an object from the given scope.
|
protected java.util.concurrent.locks.ReadWriteLock |
getLock(java.lang.Object object) |
boolean |
isRunning() |
void |
onApplicationEvent(RefreshEvent event)
Handle an application event.
|
void |
onRefreshEvent(RefreshEvent event)
Handle a
RefreshEvent synchronously. |
<T> java.util.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") java.util.concurrent.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 java.lang.Class<Refreshable> annotationType()
annotationType
in interface CustomScope<Refreshable>
public <T> T get(BeanResolutionContext resolutionContext, BeanDefinition<T> beanDefinition, BeanIdentifier identifier, javax.inject.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> java.util.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> java.util.Optional<BeanRegistration<T>> findBeanRegistration(T bean)
CustomScope
BeanDefinition
for the given bean.findBeanRegistration
in interface CustomScope<Refreshable>
T
- The bean generic typebean
- The beanprotected java.util.concurrent.locks.ReadWriteLock getLock(java.lang.Object object)
object
- The bean