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(condition=RefreshScopeCondition.class)
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
FieldsFields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Optional<BeanRegistration<T>> findBeanRegistration(T bean) Get theBeanDefinitionfor the given bean.protected ReadWriteLock<T> TgetOrCreate(BeanCreationContext<T> creationContext) Resolve an object from the given scope.intgetOrder()booleanvoidonApplicationEvent(RefreshEvent event) Handle an application event.final voidonRefreshEvent(RefreshEvent event) Handle aRefreshEventsynchronously.<T> Optional<T> remove(BeanIdentifier identifier) Remove a bean definition from the scope.stop()Stops the life cycle component.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ApplicationEventListener
supportsMethods inherited from interface 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:
isRunningin interfaceLifeCycle<RefreshScope>- Returns:
- Whether the component is running
-
annotationType
- Specified by:
annotationTypein interfaceCustomScope<Refreshable>- Returns:
- The scope annotation type
-
getOrCreate
Description copied from interface:CustomScopeResolve an object from the given scope.- Specified by:
getOrCreatein interfaceCustomScope<Refreshable>- Type Parameters:
T- The bean generic type- Parameters:
creationContext- The creation context- Returns:
- The bean instance
-
stop
Description copied from interface:LifeCycleStops the life cycle component.- Specified by:
stopin interfaceLifeCycle<RefreshScope>- Returns:
- This lifecycle component
-
remove
Description copied from interface:CustomScopeRemove a bean definition from the scope.- Specified by:
removein interfaceCustomScope<Refreshable>- Type Parameters:
T- The generic type- Parameters:
identifier- TheBeanIdentifier- Returns:
- An
Optionalof the instance that was destroyed if it exists
-
onApplicationEvent
Description copied from interface:ApplicationEventListenerHandle an application event.- Specified by:
onApplicationEventin interfaceApplicationEventListener<RefreshEvent>- Parameters:
event- the event to respond to
-
onRefreshEvent
Handle aRefreshEventsynchronously. This method blocks unlikeonApplicationEvent(RefreshEvent).- Parameters:
event- The event
-
getOrder
-
findBeanRegistration
Description copied from interface:CustomScopeGet theBeanDefinitionfor the given bean.- Specified by:
findBeanRegistrationin 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
-