Class RefreshScope
java.lang.Object
io.micronaut.runtime.context.scope.refresh.RefreshScope
- All Implemented Interfaces:
ApplicationEventListener<RefreshEvent>
,LifeCycle<RefreshScope>
,CustomScope<Refreshable>
,Ordered
,Closeable
,AutoCloseable
,EventListener
@Singleton
@Requires(notEnv={"function","android"})
public class RefreshScope
extends Object
implements CustomScope<Refreshable>, LifeCycle<RefreshScope>, ApplicationEventListener<RefreshEvent>, Ordered
Implementation of
Refreshable
.- Since:
- 1.0
- Author:
- Graeme Rocher
- See Also:
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> Optional<BeanRegistration<T>>
findBeanRegistration
(T bean) Get theBeanDefinition
for the given bean.protected ReadWriteLock
<T> T
getOrCreate
(BeanCreationContext<T> creationContext) Resolve an object from the given scope.int
getOrder()
boolean
void
onApplicationEvent
(RefreshEvent event) Handle an application event.final void
onRefreshEvent
(RefreshEvent event) Handle aRefreshEvent
synchronously.<T> Optional<T>
remove
(BeanIdentifier identifier) Remove a bean definition from the scope.stop()
Stops the life cycle component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.context.event.ApplicationEventListener
supports
Methods inherited from interface io.micronaut.context.scope.CustomScope
findBeanRegistration
-
Field Details
-
POSITION
public static final int POSITION- See Also:
-
-
Constructor Details
-
RefreshScope
- Parameters:
beanContext
- The bean context to allow DI of beans annotated with @Inject
-
-
Method Details
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceLifeCycle<RefreshScope>
- Returns:
- Whether the component is running
-
annotationType
- Specified by:
annotationType
in interfaceCustomScope<Refreshable>
- Returns:
- The scope annotation type
-
getOrCreate
Description copied from interface:CustomScope
Resolve an object from the given scope.- Specified by:
getOrCreate
in interfaceCustomScope<Refreshable>
- Type Parameters:
T
- The bean generic type- Parameters:
creationContext
- The creation context- Returns:
- The bean instance
-
stop
Description copied from interface:LifeCycle
Stops the life cycle component.- Specified by:
stop
in interfaceLifeCycle<RefreshScope>
- Returns:
- This lifecycle component
-
remove
Description copied from interface:CustomScope
Remove a bean definition from the scope.- Specified by:
remove
in interfaceCustomScope<Refreshable>
- Type Parameters:
T
- The generic type- Parameters:
identifier
- TheBeanIdentifier
- Returns:
- An
Optional
of the instance that was destroyed if it exists
-
onApplicationEvent
Description copied from interface:ApplicationEventListener
Handle an application event.- Specified by:
onApplicationEvent
in interfaceApplicationEventListener<RefreshEvent>
- Parameters:
event
- the event to respond to
-
onRefreshEvent
Handle aRefreshEvent
synchronously. This method blocks unlikeonApplicationEvent(RefreshEvent)
.- Parameters:
event
- The event
-
getOrder
public int getOrder() -
findBeanRegistration
Description copied from interface:CustomScope
Get theBeanDefinition
for the given bean.- Specified by:
findBeanRegistration
in interfaceCustomScope<Refreshable>
- Type Parameters:
T
- The bean generic type- Parameters:
bean
- The bean- Returns:
- The bean definition if it can be resolved
-
getLock
- Parameters:
object
- The bean- Returns:
- The lock on the object
-