Package io.micronaut.context.scope
Interface CustomScope<A extends java.lang.annotation.Annotation>
-
- Type Parameters:
A
- An annotation type
- All Known Implementing Classes:
AbstractConcurrentCustomScope
@Indexed(CustomScope.class) public interface CustomScope<A extends java.lang.annotation.Annotation>
Represents a custom scope within theBeanContext
.- Since:
- 1.0
- See Also:
Scope
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.Class<A>
annotationType()
default <T> java.util.Optional<BeanRegistration<T>>
findBeanRegistration(BeanDefinition<T> beanDefinition)
Get theBeanDefinition
for the given bean.default <T> java.util.Optional<BeanRegistration<T>>
findBeanRegistration(T bean)
Get theBeanDefinition
for the given bean.<T> T
getOrCreate(BeanCreationContext<T> creationContext)
Resolve an object from the given scope.<T> java.util.Optional<T>
remove(BeanIdentifier identifier)
Remove a bean definition from the scope.
-
-
-
Method Detail
-
annotationType
java.lang.Class<A> annotationType()
- Returns:
- The scope annotation type
-
getOrCreate
<T> T getOrCreate(BeanCreationContext<T> creationContext)
Resolve an object from the given scope.- Type Parameters:
T
- The bean generic type- Parameters:
creationContext
- The creation context- Returns:
- The bean instance
-
remove
<T> java.util.Optional<T> remove(BeanIdentifier identifier)
Remove a bean definition from the scope.- Type Parameters:
T
- The generic type- Parameters:
identifier
- TheBeanIdentifier
- Returns:
- An
Optional
of the instance that was destroyed if it exists
-
findBeanRegistration
default <T> java.util.Optional<BeanRegistration<T>> findBeanRegistration(T bean)
Get theBeanDefinition
for the given bean.- Type Parameters:
T
- The bean generic type- Parameters:
bean
- The bean- Returns:
- The bean definition if it can be resolved
-
findBeanRegistration
default <T> java.util.Optional<BeanRegistration<T>> findBeanRegistration(BeanDefinition<T> beanDefinition)
Get theBeanDefinition
for the given bean.- Type Parameters:
T
- The bean generic type- Parameters:
beanDefinition
- The bean definition- Returns:
- The bean definition if it can be resolved
- Since:
- 3.5.0
-
-