Class DefaultBeanContext
- All Implemented Interfaces:
BeanContext,BeanDefinitionRegistry,BeanLocator,ConfigurableBeanContext,ApplicationEventPublisher<Object>,ExecutionHandleLocator,InitializableBeanContext,LifeCycle<BeanContext>,AnnotationMetadataResolver,AttributeHolder,MutableAttributeHolder,ConversionServiceProvider,Closeable,AutoCloseable
- Direct Known Subclasses:
DefaultApplicationContext
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanprotected final AtomicBooleanprotected static final org.slf4j.Loggerprotected static final org.slf4j.Loggerstatic final Stringprotected final AtomicBooleanprotected final io.micronaut.context.SingletonScopeprotected final AtomicBooleanFields inherited from interface io.micronaut.core.annotation.AnnotationMetadataResolver
DEFAULTFields inherited from interface io.micronaut.context.event.ApplicationEventPublisher
NO_OPFields inherited from interface io.micronaut.context.ExecutionHandleLocator
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new bean context using the same classloader that loaded this DefaultBeanContext class.DefaultBeanContext(@NonNull BeanContextConfiguration contextConfiguration) Creates a new bean context with the given configuration.DefaultBeanContext(@NonNull ClassPathResourceLoader resourceLoader) Construct a new bean context with the given class loader.DefaultBeanContext(@NonNull ClassLoader classLoader) Construct a new bean context with the given class loader. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> voidcollectIterableBeans(@Nullable BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> iterableBean, @NonNull Set<BeanDefinition<T>> targetSet, @NonNull Argument<T> beanType) Collects iterable beans from a given iterable.final voidConfigures the bean context loading all bean definitions required to perform successful startup without starting the context itself.<T> booleancontainsBean(@NonNull Class<T> beanType, Qualifier<T> qualifier) Return whether the bean of the given type is contained within this context.<T> booleancontainsBean(Argument<T> beanType, Qualifier<T> qualifier) Return whether the bean of the given type is contained within this context.<T> TcreateBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Creates a new instance of the given bean performing dependency injection and returning a new instance.<T> TCreates a new instance of the given bean performing dependency injection and returning a new instance.<T> TcreateBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable Map<String, Object> argumentValues) Creates a new instance of the given bean performing dependency injection and returning a new instance.protected <T> TcreateBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Creates a bean.protected @NonNull CustomScopeRegistryAllows customizing the custom scope registry.createExecutionHandle(BeanDefinition<?> beanDefinition, ExecutableMethod<Object, ?> method) Create an execution handle for the given bean definition and method.<T> voiddestroyBean(@NonNull BeanRegistration<T> registration) Destroys the given bean.<T> TdestroyBean(@NonNull Argument<T> beanType, Qualifier<T> qualifier) Destroys the bean for the given type causing it to be re-created.<T> TdestroyBean(@NonNull Class<T> beanType) Destroys the bean for the given type causing it to be re-created.<T> TdestroyBean(T bean) Destroys the given bean.protected <T> voiddestroyLifeCycleBean(LifeCycle<?> cycle, BeanDefinition<T> definition) Destroy a lifecycle bean.voidPerforms operations required before starting the application context, such as reading bean configurations.findBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Find an optional bean of the given type and qualifier.findBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Find an optional bean of the given type and qualifier.<T> Optional<T>Finds a Bean for the given type and qualifier.<T> Optional<T>Finds a Bean for the given type and qualifier.protected <T> @NonNull Collection<BeanDefinition<T>>findBeanCandidates(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, boolean collectIterables, Predicate<BeanDefinition<T>> predicate) Find bean candidates for the given type.final <T> @NonNull Collection<BeanDefinition<T>>findBeanCandidates(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable BeanDefinition<?> filter) Find bean candidates for the given type.protected <T> @NonNull Collection<BeanDefinition<T>>findBeanCandidatesForInstance(T instance) Find bean candidates for the given type.findBeanConfiguration(String configurationName) Obtain a bean configuration by name.<T> Optional<BeanDefinition<T>>findBeanDefinition(Argument<T> beanType, Qualifier<T> qualifier) Obtain aBeanDefinitionfor the given type.<T> Optional<BeanDefinition<T>>findBeanDefinition(Class<T> beanType, Qualifier<T> qualifier) Obtain aBeanDefinitionfor the given type.<T> Optional<BeanRegistration<T>>findBeanRegistration(T bean) Obtain aBeanRegistrationfor the given bean.protected <T> @NonNull BeanDefinition<T>findConcreteCandidate(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @NonNull Collection<BeanDefinition<T>> candidates) Fall back method to attempt to find a candidate for the given definitions.<T,R> Optional<ExecutableMethod<T, R>> findExecutableMethod(Class<T> beanType, String method, Class<?>[] arguments) Finds an optimized execution handle for invoking a bean method.<T,R> Optional<MethodExecutionHandle<T, R>> findExecutionHandle(Class<T> beanType, Qualifier<?> q, String method, Class<?>... arguments) Finds an optimized execution handle for invoking a bean method.<T,R> Optional<MethodExecutionHandle<T, R>> findExecutionHandle(Class<T> beanType, String method, Class<?>... arguments) Finds an optimized execution handle for invoking a bean method.<T,R> Optional<MethodExecutionHandle<T, R>> findExecutionHandle(T bean, String method, Class<?>[] arguments) Finds an optimized execution handle for invoking a bean method.<T> @NonNull Optional<BeanDefinition<T>>findProxyBeanDefinition(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtain the proxyBeanDefinitionfor the bean of type and qualifier.<T> @NonNull Optional<BeanDefinition<T>>findProxyBeanDefinition(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Obtain the proxyBeanDefinitionfor the bean of type and qualifier.<T> Optional<BeanDefinition<T>>findProxyTargetBeanDefinition(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtain the originalBeanDefinitionfor aProxyBeanDefinition.<T> @NonNull Optional<BeanDefinition<T>>findProxyTargetBeanDefinition(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Obtain the originalBeanDefinitionfor aProxyBeanDefinition.<T,R> Optional<ExecutableMethod<T, R>> findProxyTargetMethod(@NonNull Argument<T> beanType, Qualifier<T> qualifier, @NonNull String method, Class<?>... arguments) Finds the original unproxied method for aProxyBeanDefinition.<T,R> @NonNull Optional<ExecutableMethod<T, R>> findProxyTargetMethod(@NonNull Class<T> beanType, @NonNull String method, @NonNull Class<?>[] arguments) Finds the original unproxied method for aProxyBeanDefinition.<T,R> @NonNull Optional<ExecutableMethod<T, R>> findProxyTargetMethod(@NonNull Class<T> beanType, Qualifier<T> qualifier, @NonNull String method, Class<?>... arguments) Finds the original unproxied method for aProxyBeanDefinition.protected <T> @Nullable BeanRegistration<T>getActiveBeanRegistration(BeanDefinition<T> beanDefinition, Qualifier qualifier) Find an active singleton bean for the given definition and qualifier.getActiveBeanRegistrations(Qualifier<?> qualifier) Find activeSingletonbeans for the given qualifier.<T> Collection<BeanRegistration<T>>getActiveBeanRegistrations(Class<T> beanType) Find activeSingletonbeans for the given bean type.Get all registeredBeanDefinition.getAttribute(CharSequence name) Obtain the value of an attribute on the HTTP method.getAttribute(CharSequence name, Class<T> type) Obtain the value of an attribute on the HTTP method.Overrides the defaultAttributeHolder.getAttributes()method to return a mutable object.<T> TObtains a Bean for the given type and qualifier.<T> TgetBean(@NonNull BeanDefinition<T> definition) Obtains a Bean for the given bean definition.<T> TObtains a Bean for the given type.<T> TObtains a Bean for the given type and qualifier.<T> TgetBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Get a bean of the given type and qualifier.<T> TgetBean(@Nullable BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> beanDefinition, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Get a bean of the given bean definition, type and qualifier.<T> TgetBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType) Get a bean of the given type.<T> TgetBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Get a bean of the given type and qualifier.<T> BeanDefinition<T>getBeanDefinition(Argument<T> beanType, Qualifier<T> qualifier) Obtain aBeanDefinitionfor the given type.Get all enabledBeanDefinitionReference.getBeanDefinitions(@Nullable Qualifier<Object> qualifier) Get all of theBeanDefinitionfor the given qualifier.<T> Collection<BeanDefinition<T>>getBeanDefinitions(Argument<T> beanType) Obtain aBeanDefinitionfor the given type.<T> Collection<BeanDefinition<T>>getBeanDefinitions(Argument<T> beanType, Qualifier<T> qualifier) Obtain aBeanDefinitionfor the given type.<T> Collection<BeanDefinition<T>>getBeanDefinitions(Class<T> beanType) Obtain aBeanDefinitionfor the given type.<T> Collection<BeanDefinition<T>>getBeanDefinitions(Class<T> beanType, Qualifier<T> qualifier) Obtain aBeanDefinitionfor the given type.<T> BeanRegistration<T>getBeanRegistration(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtains the bean registration for the given type and qualifier.<T> BeanRegistration<T>getBeanRegistration(Argument<T> beanType, Qualifier<T> qualifier) Find a bean registration for the given bean type and optional qualifier.<T> BeanRegistration<T>getBeanRegistration(BeanDefinition<T> beanDefinition) Find a bean registration for the given bean definition.<T> BeanRegistration<T>getBeanRegistration(Class<T> beanType, Qualifier<T> qualifier) Find a bean registration for the given bean type and optional qualifier.<T> Collection<BeanRegistration<T>>getBeanRegistrations(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Obtains the bean registrations for the given type and qualifier.<T> Collection<BeanRegistration<T>>getBeanRegistrations(Argument<T> beanType, Qualifier<T> qualifier) Find and if necessary initializeSingletonbeans for the given bean type, returning all the active registrations.<T> Collection<BeanRegistration<T>>getBeanRegistrations(Class<T> beanType) Find and if necessary initializeSingletonbeans for the given bean type, returning all the active registrations.<T> Collection<BeanRegistration<T>>getBeanRegistrations(Class<T> beanType, Qualifier<T> qualifier) Find and if necessary initializeSingletonbeans for the given bean type, returning all the active registrations.protected <T> @NonNull Collection<T>getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType) Get all beans of the given type.<T> @NonNull Collection<T>getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Get all beans of the given type and qualifier.<T> Collection<T>getBeansOfType(Argument<T> beanType) Get all beans of the given type.<T> Collection<T>getBeansOfType(Argument<T> beanType, Qualifier<T> qualifier) Get all beans of the given type.<T> Collection<T>getBeansOfType(Class<T> beanType) Get all beans of the given type.<T> Collection<T>getBeansOfType(Class<T> beanType, Qualifier<T> qualifier) Get all beans of the given type.Obtains the configuration for this context.Provides the conversion service.Get all disabledDisabledBean.<T> TgetProxyTargetBean(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given bean type.<T> TgetProxyTargetBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given bean type.<T> TgetProxyTargetBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given bean type.<T> TgetProxyTargetBean(@Nullable BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> definition, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given proxy bean definition.protected voidinitializeContext(@NonNull List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> eagerInitBeans, @NonNull List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> processedBeans, @NonNull List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> parallelBeans) Initialize the context with the givenContextscope beans.protected voidInitialize the event listeners.protected <T> Tinject(@NonNull BeanResolutionContext resolutionContext, @Nullable BeanDefinition<?> requestingBeanDefinition, T instance) Injects a bean.<T> Tinject(T instance) Inject an existing instance.protected voidInvalidates the bean caches.booleanmapOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<V> beanType, @Nullable Qualifier<V> qualifier) Obtains a map of beans of the given type and qualifier.Obtain a map of beans of the given type where the key is the qualifier.protected <T> @NonNull NoSuchBeanExceptionnewNoSuchBeanException(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @NonNull Qualifier<T> qualifier, @Nullable String message) Trigger a no such bean exception.protected voidprocessParallelBeans(List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> parallelBeans) Processes parallel bean definitions.voidpublishEvent(@NonNull Object event) Publish the given event.publishEventAsync(@NonNull Object event) Publish the given event.<T> voidrefreshBean(@NonNull BeanRegistration<T> beanRegistration) Refresh the state of the given registered bean applying dependency injection and configuration wiring again.<T> Optional<T>refreshBean(@Nullable BeanIdentifier identifier) Refresh the state of the given registered bean applying dependency injection and configuration wiring again.registerBeanConfiguration(BeanConfiguration configuration) Registers a bean configuration.<B> @NonNull BeanContextregisterBeanDefinition(@NonNull RuntimeBeanDefinition<B> definition) Registers a new reference at runtime.protected voidregisterConfiguration(@NonNull BeanConfiguration configuration) Registers an active configuration.protected voidRegisters conversion service.<T> BeanContextregisterSingleton(@NonNull Class<T> type, T singleton, Qualifier<T> qualifier, boolean inject) Registers a new singleton bean at runtime.removeAttribute(@NonNull CharSequence name, @NonNull Class<T> type) Remove an attribute.protected @NonNull Iterable<BeanConfiguration>Resolves theBeanConfigurationclass instances.protected @NonNull List<BeanDefinitionReference>Resolves theBeanDefinitionReferenceclass instances.protected @NonNull List<BeanDefinitionReference>Deprecated.resolveDisabledBeanMessage(BeanResolutionContext resolutionContext, Argument<T> beanType, Qualifier<T> qualifier) Resolves the message to use for a disabled bean.resolveMetadata(Class<?> type) Resolve theAnnotationMetadatafor the given type.setAttribute(@NonNull CharSequence name, @Nullable Object value) Sets an attribute on the message.start()The start method will read all bean definition classes found on the classpath and initialize any pre-required state.stop()The close method will shut down the context callingPreDestroyhooks on loaded singletons.<T> Stream<T>streamOfType(BeanResolutionContext resolutionContext, Argument<T> beanType, Qualifier<T> qualifier) Obtains a stream of beans of the given type and qualifier.protected <T> Stream<T>streamOfType(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier) Obtains a stream of beans of the given type and qualifier.<T> Stream<T>streamOfType(Argument<T> beanType, Qualifier<T> qualifier) Obtain a stream of beans of the given type.<T> Stream<T>streamOfType(Class<T> beanType, Qualifier<T> qualifier) Obtain a stream of beans of the given type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadataResolver
resolveMetadataMethods inherited from interface io.micronaut.context.event.ApplicationEventPublisher
isEmptyMethods inherited from interface io.micronaut.context.BeanContext
createBean, createBean, createBean, destroyBean, getEventPublisher, registerSingleton, registerSingleton, registerSingleton, registerSingletonMethods inherited from interface io.micronaut.context.BeanDefinitionRegistry
containsBean, containsBean, findBeanDefinition, findBeanDefinition, findBeanDefinition, findProxyTargetBeanDefinition, getBeanDefinition, getBeanDefinition, getBeanDefinition, getProxyTargetBeanDefinition, getProxyTargetBeanDefinitionMethods inherited from interface io.micronaut.context.BeanLocator
findBean, findBean, findOrInstantiateBean, getBean, getProvider, getProvider, getProvider, getProvider, mapOfType, mapOfType, mapOfType, streamOfType, streamOfTypeMethods inherited from interface io.micronaut.context.ExecutionHandleLocator
getExecutableMethod, getExecutionHandle, getExecutionHandle, getProxyTargetMethod, getProxyTargetMethod, getProxyTargetMethod
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
LOG_LIFECYCLE
protected static final org.slf4j.Logger LOG_LIFECYCLE -
MSG_BEAN_DEFINITION
- See Also:
-
running
-
configured
-
initializing
-
terminating
-
singletonScope
protected final io.micronaut.context.SingletonScope singletonScope
-
-
Constructor Details
-
DefaultBeanContext
public DefaultBeanContext()Construct a new bean context using the same classloader that loaded this DefaultBeanContext class. -
DefaultBeanContext
Construct a new bean context with the given class loader.- Parameters:
classLoader- The class loader
-
DefaultBeanContext
Construct a new bean context with the given class loader.- Parameters:
resourceLoader- The resource loader
-
DefaultBeanContext
Creates a new bean context with the given configuration.- Parameters:
contextConfiguration- The context configuration
-
-
Method Details
-
createCustomScopeRegistry
Allows customizing the custom scope registry.- Returns:
- The custom scope registry to use.
- Since:
- 3.0.0
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceLifeCycle<BeanContext>- Returns:
- Whether the component is running
-
start
The start method will read all bean definition classes found on the classpath and initialize any pre-required state.- Specified by:
startin interfaceLifeCycle<BeanContext>- Returns:
- This lifecycle component
-
registerConversionService
protected void registerConversionService()Registers conversion service. -
stop
The close method will shut down the context callingPreDestroyhooks on loaded singletons.- Specified by:
stopin interfaceLifeCycle<BeanContext>- Returns:
- This lifecycle component
-
resolveMetadata
Description copied from interface:AnnotationMetadataResolverResolve theAnnotationMetadatafor the given type.- Specified by:
resolveMetadatain interfaceAnnotationMetadataResolver- Parameters:
type- The type- Returns:
- The
AnnotationMetadata
-
refreshBean
Description copied from interface:BeanContextRefresh the state of the given registered bean applying dependency injection and configuration wiring again.
Note that if the bean was produced by a
Factorythen this method will refresh the factory too- Specified by:
refreshBeanin interfaceBeanContext- Type Parameters:
T- The concrete class- Parameters:
identifier- TheBeanIdentifier- Returns:
- An
Optionalof the instance if it exists for the given registration
-
refreshBean
Description copied from interface:BeanContextRefresh the state of the given registered bean applying dependency injection and configuration wiring again.
Note that if the bean was produced by a
This methods skips an additional resolution of theFactorythen this method will refresh the factory tooBeanRegistration.- Specified by:
refreshBeanin interfaceBeanContext- Type Parameters:
T- The concrete class- Parameters:
beanRegistration- TheBeanRegistration
-
getActiveBeanRegistrations
Description copied from interface:BeanDefinitionRegistryFind activeSingletonbeans for the given qualifier. Note that this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.- Specified by:
getActiveBeanRegistrationsin interfaceBeanDefinitionRegistry- Parameters:
qualifier- The qualifier- Returns:
- The beans
-
getActiveBeanRegistrations
Description copied from interface:BeanDefinitionRegistryFind activeSingletonbeans for the given bean type. Note that this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.- Specified by:
getActiveBeanRegistrationsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean type- Returns:
- The beans
-
getBeanRegistrations
Description copied from interface:BeanDefinitionRegistryFind and if necessary initializeSingletonbeans for the given bean type, returning all the active registrations. Note that this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.- Specified by:
getBeanRegistrationsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean type- Returns:
- The beans
-
getBeanRegistration
Description copied from interface:BeanDefinitionRegistryFind a bean registration for the given bean type and optional qualifier.- Specified by:
getBeanRegistrationin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The bean registration
-
getBeanRegistrations
public <T> Collection<BeanRegistration<T>> getBeanRegistrations(Class<T> beanType, Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryFind and if necessary initializeSingletonbeans for the given bean type, returning all the active registrations. Note that this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.- Specified by:
getBeanRegistrationsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The beans
-
getBeanRegistrations
public <T> Collection<BeanRegistration<T>> getBeanRegistrations(Argument<T> beanType, Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryFind and if necessary initializeSingletonbeans for the given bean type, returning all the active registrations. Note that this method can return multiple registrations for a given singleton bean instance since each bean may have multiple qualifiers.- Specified by:
getBeanRegistrationsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The beans
-
getBeanRegistration
Description copied from interface:BeanDefinitionRegistryFind a bean registration for the given bean type and optional qualifier.- Specified by:
getBeanRegistrationin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- The bean registration
-
getBeanRegistration
Description copied from interface:BeanDefinitionRegistryFind a bean registration for the given bean definition.- Specified by:
getBeanRegistrationin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanDefinition- The bean definition- Returns:
- The bean registration
-
findBeanRegistration
Description copied from interface:BeanDefinitionRegistryObtain aBeanRegistrationfor the given bean.- Specified by:
findBeanRegistrationin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
bean- The bean- Returns:
- An
Optionalof the bean definition
-
findExecutionHandle
public <T,R> Optional<MethodExecutionHandle<T,R>> findExecutionHandle(Class<T> beanType, String method, Class<?>... arguments) Description copied from interface:ExecutionHandleLocatorFinds an optimized execution handle for invoking a bean method. The execution handle may or may not be implemented by generated byte code.- Specified by:
findExecutionHandlein interfaceExecutionHandleLocator- Type Parameters:
T- The target beanR- The result type of the execution handle- Parameters:
beanType- The bean typemethod- The methodarguments- The arguments- Returns:
- The execution handle
-
createExecutionHandle
public MethodExecutionHandle<?,Object> createExecutionHandle(BeanDefinition<?> beanDefinition, ExecutableMethod<Object, ?> method) Description copied from interface:ExecutionHandleLocatorCreate an execution handle for the given bean definition and method.- Specified by:
createExecutionHandlein interfaceExecutionHandleLocator- Parameters:
beanDefinition- The bean definitionmethod- The method- Returns:
- The execution handle
-
findExecutionHandle
public <T,R> Optional<MethodExecutionHandle<T,R>> findExecutionHandle(Class<T> beanType, Qualifier<?> q, String method, Class<?>... arguments) Description copied from interface:ExecutionHandleLocatorFinds an optimized execution handle for invoking a bean method. The execution handle may or may not be implemented by generated byte code.- Specified by:
findExecutionHandlein interfaceExecutionHandleLocator- Type Parameters:
T- The target beanR- The result type of the execution handle- Parameters:
beanType- The bean typeq- The bean qualifermethod- The methodarguments- The arguments- Returns:
- The execution handle
-
findExecutableMethod
public <T,R> Optional<ExecutableMethod<T,R>> findExecutableMethod(Class<T> beanType, String method, Class<?>[] arguments) Description copied from interface:ExecutionHandleLocatorFinds an optimized execution handle for invoking a bean method. The execution handle may or may not be implemented by generated byte code.- Specified by:
findExecutableMethodin interfaceExecutionHandleLocator- Type Parameters:
T- The bean type classR- The result type of the execution handle- Parameters:
beanType- The bean typemethod- The methodarguments- The arguments- Returns:
- The execution handle
-
findExecutionHandle
public <T,R> Optional<MethodExecutionHandle<T,R>> findExecutionHandle(T bean, String method, Class<?>[] arguments) Description copied from interface:ExecutionHandleLocatorFinds an optimized execution handle for invoking a bean method. The execution handle may or may not be implemented by generated byte code.- Specified by:
findExecutionHandlein interfaceExecutionHandleLocator- Type Parameters:
T- The target beanR- The result type of the execution handle- Parameters:
bean- The bean to invoke the method onmethod- The methodarguments- The arguments- Returns:
- The execution handle
-
registerSingleton
public <T> BeanContext registerSingleton(@NonNull @NonNull Class<T> type, @NonNull T singleton, Qualifier<T> qualifier, boolean inject) Description copied from interface:BeanDefinitionRegistryRegisters a new singleton bean at runtime. This method expects that the bean definition data will have been compiled ahead of time.
If bean definition data is found the method will perform dependency injection on the instance followed by invoking any
PostConstructhooks.If no bean definition data is found the bean is registered as is.
- Specified by:
registerSingletonin interfaceBeanContext- Specified by:
registerSingletonin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
type- The bean typesingleton- The singleton beanqualifier- The bean qualifierinject- Whether the singleton should be injected (defaults to true)- Returns:
- This bean context
-
getClassLoader
- Specified by:
getClassLoaderin interfaceBeanContext- Returns:
- The class loader used by this context
-
getBeanValidator
- Specified by:
getBeanValidatorin interfaceBeanContext- Returns:
- Get the configured bean validator, if any.
-
findBeanConfiguration
Description copied from interface:BeanDefinitionRegistryObtain a bean configuration by name.- Specified by:
findBeanConfigurationin interfaceBeanDefinitionRegistry- Parameters:
configurationName- The configuration name- Returns:
- An optional with the configuration either present or not
-
getBeanDefinition
Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
getBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The potentially parameterized typequalifier- The qualifier- Returns:
- The
BeanDefinition
-
findBeanDefinition
public <T> Optional<BeanDefinition<T>> findBeanDefinition(Argument<T> beanType, Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
findBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The potentially parameterized typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
findBeanDefinition
public <T> Optional<BeanDefinition<T>> findBeanDefinition(Class<T> beanType, Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
findBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
getBeanDefinitions
Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The type- Returns:
- An
Optionalof the bean definition
-
getBeanDefinitions
Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The type- Returns:
- An
Optionalof the bean definition
-
getBeanDefinitions
public <T> Collection<BeanDefinition<T>> getBeanDefinitions(Class<T> beanType, Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
getBeanDefinitions
public <T> Collection<BeanDefinition<T>> getBeanDefinitions(Argument<T> beanType, Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain aBeanDefinitionfor the given type.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
containsBean
Description copied from interface:BeanDefinitionRegistryReturn whether the bean of the given type is contained within this context.- Specified by:
containsBeanin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean typequalifier- The qualifier for the bean- Returns:
- True if it is
-
containsBean
Description copied from interface:BeanDefinitionRegistryReturn whether the bean of the given type is contained within this context.- Specified by:
containsBeanin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The bean typequalifier- The qualifier for the bean- Returns:
- True if it is
-
getBean
@NonNull public <T> T getBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanLocatorObtains a Bean for the given type and qualifier.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- An instanceof said bean
- See Also:
-
getBean
Description copied from interface:BeanLocatorObtains a Bean for the given type.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean type- Returns:
- An instanceof said bean
-
getBean
@NonNull public <T> T getBean(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanLocatorObtains a Bean for the given type and qualifier.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- An instanceof said bean
- See Also:
-
findBean
Description copied from interface:BeanLocatorFinds a Bean for the given type and qualifier.- Specified by:
findBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- An instance of
Optionalthat is either empty or containing the specified bean - See Also:
-
findBean
Description copied from interface:BeanLocatorFinds a Bean for the given type and qualifier.- Specified by:
findBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- An instance of
Optionalthat is either empty or containing the specified bean - See Also:
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean type- Returns:
- The found beans
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The found beans
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The potenitally parameterized bean type- Returns:
- The found beans
-
getBeansOfType
Description copied from interface:BeanLocatorGet all beans of the given type.- Specified by:
getBeansOfTypein interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
beanType- The potenitally parameterized bean typequalifier- The qualifier- Returns:
- The found beans
-
streamOfType
Description copied from interface:BeanLocatorObtain a stream of beans of the given type.- Specified by:
streamOfTypein interfaceBeanLocator- Type Parameters:
T- The bean concrete type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- A stream of instances
- See Also:
-
streamOfType
Description copied from interface:BeanLocatorObtain a stream of beans of the given type.- Specified by:
streamOfTypein interfaceBeanLocator- Type Parameters:
T- The bean concrete type- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- A stream of instances
- See Also:
-
mapOfType
Description copied from interface:BeanLocatorObtain a map of beans of the given type where the key is the qualifier.- Specified by:
mapOfTypein interfaceBeanLocator- Type Parameters:
V- The bean concrete type- Parameters:
beanType- The potentially parameterized bean typequalifier- The qualifier- Returns:
- A map of instances
- See Also:
-
streamOfType
protected <T> Stream<T> streamOfType(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier) Obtains a stream of beans of the given type and qualifier.- Type Parameters:
T- The bean concrete type- Parameters:
resolutionContext- The bean resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- A stream
-
mapOfType
@NonNull protected <V> @NonNull Map<String,V> mapOfType(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<V> beanType, @Nullable @Nullable Qualifier<V> qualifier) Obtains a map of beans of the given type and qualifier.- Type Parameters:
V- The bean type- Parameters:
resolutionContext- The resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- A map of beans, never
null. - Since:
- 4.0.0
-
streamOfType
@Internal public <T> Stream<T> streamOfType(BeanResolutionContext resolutionContext, Argument<T> beanType, Qualifier<T> qualifier) Obtains a stream of beans of the given type and qualifier.- Type Parameters:
T- The bean concrete type- Parameters:
resolutionContext- The bean resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- A stream
-
inject
Description copied from interface:BeanContextInject an existing instance.- Specified by:
injectin interfaceBeanContext- Type Parameters:
T- The bean generic type- Parameters:
instance- The instance to inject- Returns:
- The instance to inject
-
createBean
@NonNull public <T> T createBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanContextCreates a new instance of the given bean performing dependency injection and returning a new instance.Note that the instance returned is not saved as a singleton in the context.
- Specified by:
createBeanin interfaceBeanContext- Type Parameters:
T- The bean generic type- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The instance
-
createBean
@NonNull public <T> T createBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier, @Nullable @Nullable Map<String, Object> argumentValues) Description copied from interface:BeanContextCreates a new instance of the given bean performing dependency injection and returning a new instance.
If the bean defines any
Parametervalues then the values passed in theargumentValuesparameter will be usedNote that the instance returned is not saved as a singleton in the context.
- Specified by:
createBeanin interfaceBeanContext- Type Parameters:
T- The bean generic type- Parameters:
beanType- The bean typequalifier- The qualifierargumentValues- The argument values- Returns:
- The instance
-
createBean
@NonNull public <T> T createBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier, @Nullable @Nullable Object... args) Description copied from interface:BeanContextCreates a new instance of the given bean performing dependency injection and returning a new instance.
If the bean defines any
Parametervalues then the values passed in theargumentValuesparameter will be usedNote that the instance returned is not saved as a singleton in the context.
- Specified by:
createBeanin interfaceBeanContext- Type Parameters:
T- The bean generic type- Parameters:
beanType- The bean typequalifier- The qualifierargs- The argument values- Returns:
- The instance
-
destroyBean
Description copied from interface:BeanContextDestroys the bean for the given type causing it to be re-created. If a singleton has been loaded it will be destroyed and removed from the context, otherwise null will be returned.- Specified by:
destroyBeanin interfaceBeanContext- Type Parameters:
T- The concrete class- Parameters:
beanType- The bean typequalifier- The qualifier- Returns:
- The destroy instance or null if no such bean exists
-
destroyBean
Description copied from interface:BeanContextDestroys the given bean.- Specified by:
destroyBeanin interfaceBeanContext- Type Parameters:
T- The concrete class- Parameters:
bean- The bean- Returns:
- The destroy instance
-
destroyBean
Description copied from interface:BeanContextDestroys the bean for the given type causing it to be re-created. If a singleton has been loaded it will be destroyed and removed from the context, otherwise null will be returned.- Specified by:
destroyBeanin interfaceBeanContext- Type Parameters:
T- The concrete class- Parameters:
beanType- The bean type- Returns:
- The destroy instance or null if no such bean exists
-
destroyBean
Description copied from interface:BeanContextDestroys the given bean.- Specified by:
destroyBeanin interfaceBeanContext- Type Parameters:
T- The bean type- Parameters:
registration- The bean registration
-
destroyLifeCycleBean
Destroy a lifecycle bean.- Type Parameters:
T- The bean type- Parameters:
cycle- The cycledefinition- The definition
-
getActiveBeanRegistration
@Nullable protected <T> @Nullable BeanRegistration<T> getActiveBeanRegistration(BeanDefinition<T> beanDefinition, Qualifier qualifier) Find an active singleton bean for the given definition and qualifier.- Type Parameters:
T- The bean generic type- Parameters:
beanDefinition- The bean definitionqualifier- The qualifier- Returns:
- The bean registration
-
createBean
@NonNull protected <T> T createBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Creates a bean.- Type Parameters:
T- The bean generic type- Parameters:
resolutionContext- The bean resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- The instance
-
inject
@Internal @NonNull protected <T> T inject(@NonNull @NonNull BeanResolutionContext resolutionContext, @Nullable @Nullable BeanDefinition<?> requestingBeanDefinition, @NonNull T instance) Injects a bean.- Type Parameters:
T- The instance type- Parameters:
resolutionContext- The bean resolution contextrequestingBeanDefinition- The requesting bean definitioninstance- The instance- Returns:
- The instance
-
getBeansOfType
@NonNull protected <T> @NonNull Collection<T> getBeansOfType(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType) Get all beans of the given type.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean resolution contextbeanType- The bean type- Returns:
- The found beans
-
getBeansOfType
@Internal @NonNull public <T> @NonNull Collection<T> getBeansOfType(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Get all beans of the given type and qualifier.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- The found beans
-
getProxyTargetBean
@NonNull public <T> T getProxyTargetBean(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanLocatorResolves the proxy target for a given bean type. If the bean has no proxy then the original bean is returned.- Specified by:
getProxyTargetBeanin interfaceBeanLocator- Type Parameters:
T- The generic type- Parameters:
beanType- The bean typequalifier- The bean qualifier- Returns:
- The proxied instance
-
getProxyTargetBean
@NonNull public <T> T getProxyTargetBean(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanLocatorResolves the proxy target for a given bean type. If the bean has no proxy then the original bean is returned.- Specified by:
getProxyTargetBeanin interfaceBeanLocator- Type Parameters:
T- The generic type- Parameters:
beanType- The bean typequalifier- The bean qualifier- Returns:
- The proxied instance
-
getProxyTargetBean
@NonNull public <T> T getProxyTargetBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given bean type. If the bean has no proxy then the original bean is returned.- Type Parameters:
T- The generic type- Parameters:
resolutionContext- The bean resolution contextbeanType- The bean typequalifier- The bean qualifier- Returns:
- The proxied instance
- Since:
- 3.1.0
-
getProxyTargetBean
@Internal @NonNull public <T> T getProxyTargetBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull BeanDefinition<T> definition, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Resolves the proxy target for a given proxy bean definition. If the bean has no proxy then the original bean is returned.- Type Parameters:
T- The generic type- Parameters:
resolutionContext- The bean resolution contextdefinition- The proxy bean definitionbeanType- The bean typequalifier- The bean qualifier- Returns:
- The proxied instance
- Since:
- 4.3.0
-
findProxyTargetMethod
@NonNull public <T,R> @NonNull Optional<ExecutableMethod<T,R>> findProxyTargetMethod(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull String method, @NonNull @NonNull Class<?>[] arguments) Description copied from interface:ExecutionHandleLocatorFinds the original unproxied method for aProxyBeanDefinition.- Specified by:
findProxyTargetMethodin interfaceExecutionHandleLocator- Type Parameters:
T- The bean type classR- The result type of the execution handle- Parameters:
beanType- The bean typemethod- The methodarguments- The arguments- Returns:
- The execution handle
-
findProxyTargetMethod
@NonNull public <T,R> @NonNull Optional<ExecutableMethod<T,R>> findProxyTargetMethod(@NonNull @NonNull Class<T> beanType, Qualifier<T> qualifier, @NonNull @NonNull String method, Class<?>... arguments) Description copied from interface:ExecutionHandleLocatorFinds the original unproxied method for aProxyBeanDefinition.- Specified by:
findProxyTargetMethodin interfaceExecutionHandleLocator- Type Parameters:
T- The bean type classR- The result type of the execution handle- Parameters:
beanType- The bean typequalifier- The qualifiermethod- The methodarguments- The arguments- Returns:
- The execution handle
-
findProxyTargetMethod
public <T,R> Optional<ExecutableMethod<T,R>> findProxyTargetMethod(@NonNull @NonNull Argument<T> beanType, Qualifier<T> qualifier, @NonNull @NonNull String method, Class<?>... arguments) Description copied from interface:ExecutionHandleLocatorFinds the original unproxied method for aProxyBeanDefinition.- Specified by:
findProxyTargetMethodin interfaceExecutionHandleLocator- Type Parameters:
T- The bean type classR- The result type of the execution handle- Parameters:
beanType- The bean typequalifier- The qualifiermethod- The methodarguments- The arguments- Returns:
- The execution handle
-
findProxyTargetBeanDefinition
@NonNull public <T> @NonNull Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain the originalBeanDefinitionfor aProxyBeanDefinition.- Specified by:
findProxyTargetBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
findProxyTargetBeanDefinition
public <T> Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain the originalBeanDefinitionfor aProxyBeanDefinition.- Specified by:
findProxyTargetBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
getBeanDefinitions
@NonNull public @NonNull Collection<BeanDefinition<?>> getBeanDefinitions(@Nullable @Nullable Qualifier<Object> qualifier) Description copied from interface:BeanDefinitionRegistryGet all of theBeanDefinitionfor the given qualifier.- Specified by:
getBeanDefinitionsin interfaceBeanDefinitionRegistry- Parameters:
qualifier- The qualifier- Returns:
- The bean definitions
-
getAllBeanDefinitions
Description copied from interface:BeanDefinitionRegistryGet all registeredBeanDefinition.- Specified by:
getAllBeanDefinitionsin interfaceBeanDefinitionRegistry- Returns:
- The bean definitions
-
getDisabledBeans
Description copied from interface:BeanDefinitionRegistryGet all disabledDisabledBean.- Specified by:
getDisabledBeansin interfaceBeanDefinitionRegistry- Returns:
- The disabled bean definitions
-
getBeanDefinitionReferences
Description copied from interface:BeanDefinitionRegistryGet all enabledBeanDefinitionReference.- Specified by:
getBeanDefinitionReferencesin interfaceBeanDefinitionRegistry- Returns:
- The bean definitions
-
registerBeanConfiguration
Description copied from interface:BeanDefinitionRegistryRegisters a bean configuration. This allows disabling a set of beans based on a condition.- Specified by:
registerBeanConfigurationin interfaceBeanDefinitionRegistry- Parameters:
configuration- The configuration- Returns:
- The registry
-
registerBeanDefinition
@NonNull public <B> @NonNull BeanContext registerBeanDefinition(@NonNull @NonNull RuntimeBeanDefinition<B> definition) Description copied from interface:BeanDefinitionRegistryRegisters a new reference at runtime. Not that registering beans can impact the object graph therefore should this should be done as soon as possible prior to the creation of other beans preferably with a high priorityContextscope bean.- Specified by:
registerBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
B- The bean type- Parameters:
definition- The reference.- Returns:
- The registry
-
getBean
@NonNull public <T> T getBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Class<T> beanType) Get a bean of the given type.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean context resolutionbeanType- The bean type- Returns:
- The found bean
-
getBean
Description copied from interface:BeanLocatorObtains a Bean for the given bean definition.- Specified by:
getBeanin interfaceBeanLocator- Type Parameters:
T- The bean type parameter- Parameters:
definition- The bean type- Returns:
- An instanceof said bean
- See Also:
-
getBean
@NonNull public <T> T getBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Get a bean of the given type and qualifier.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean context resolutionbeanType- The bean typequalifier- The qualifier- Returns:
- The found bean
-
getBean
@NonNull public <T> T getBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Get a bean of the given type and qualifier.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean context resolutionbeanType- The bean typequalifier- The qualifier- Returns:
- The found bean
- Since:
- 3.0.0
-
getBean
@Internal @NonNull public <T> T getBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull BeanDefinition<T> beanDefinition, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Get a bean of the given bean definition, type and qualifier.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean context resolutionbeanDefinition- The bean definitionbeanType- The bean typequalifier- The qualifier- Returns:
- The found bean
- Since:
- 3.5.0
-
findBean
@NonNull public <T> @NonNull Optional<T> findBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Find an optional bean of the given type and qualifier.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean context resolutionbeanType- The bean typequalifier- The qualifier- Returns:
- The found bean wrapped as an
Optional
-
findBean
@Internal @NonNull public <T> @NonNull Optional<T> findBean(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Find an optional bean of the given type and qualifier.- Type Parameters:
T- The bean type parameter- Parameters:
resolutionContext- The bean context resolutionbeanType- The bean typequalifier- The qualifier- Returns:
- The found bean wrapped as an
Optional - Since:
- 3.0.0
-
getContextConfiguration
Description copied from interface:BeanContextObtains the configuration for this context.- Specified by:
getContextConfigurationin interfaceBeanContext- Returns:
- The
BeanContextConfiguration
-
publishEvent
Description copied from interface:ApplicationEventPublisherPublish the given event. The event will be published synchronously and only return once all listeners have consumed the event.- Specified by:
publishEventin interfaceApplicationEventPublisher<Object>- Parameters:
event- The event to publish
-
publishEventAsync
Description copied from interface:ApplicationEventPublisherPublish the given event. The event will be published asynchronously. A future is returned that can be used to check whether the event completed successfully or not.- Specified by:
publishEventAsyncin interfaceApplicationEventPublisher<Object>- Parameters:
event- The event to publish- Returns:
- A future that completes when the event is published
-
findProxyBeanDefinition
@NonNull public <T> @NonNull Optional<BeanDefinition<T>> findProxyBeanDefinition(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain the proxyBeanDefinitionfor the bean of type and qualifier.- Specified by:
findProxyBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
findProxyBeanDefinition
@NonNull public <T> @NonNull Optional<BeanDefinition<T>> findProxyBeanDefinition(@NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Description copied from interface:BeanDefinitionRegistryObtain the proxyBeanDefinitionfor the bean of type and qualifier.- Specified by:
findProxyBeanDefinitionin interfaceBeanDefinitionRegistry- Type Parameters:
T- The concrete type- Parameters:
beanType- The typequalifier- The qualifier- Returns:
- An
Optionalof the bean definition
-
invalidateCaches
Invalidates the bean caches. For testing only. -
resolveBeanDefinitionReferences
Resolves theBeanDefinitionReferenceclass instances. Default implementation uses ServiceLoader pattern.- Returns:
- The bean definition classes
-
resolveBeanDefinitionReferences
@NonNull @Deprecated protected @NonNull List<BeanDefinitionReference> resolveBeanDefinitionReferences(@Nullable @Nullable Predicate<BeanDefinitionReference> predicate) Deprecated.Resolves theBeanDefinitionReferenceclass instances. Default implementation uses ServiceLoader pattern.- Parameters:
predicate- The filter predicate, can be null- Returns:
- The bean definition classes
-
resolveBeanConfigurations
Resolves theBeanConfigurationclass instances. Default implementation uses ServiceLoader pattern.- Returns:
- The bean definition classes
-
initializeEventListeners
protected void initializeEventListeners()Initialize the event listeners. -
initializeContext
@Internal protected void initializeContext(@NonNull @NonNull List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> eagerInitBeans, @NonNull @NonNull List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> processedBeans, @NonNull @NonNull List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> parallelBeans) Initialize the context with the givenContextscope beans.- Parameters:
eagerInitBeans- The context scope beansprocessedBeans- The beans that requireExecutableMethodProcessorhandlingparallelBeans- The parallel bean definitions
-
findBeanCandidates
@NonNull @Internal public final <T> @NonNull Collection<BeanDefinition<T>> findBeanCandidates(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable BeanDefinition<?> filter) Find bean candidates for the given type.- Type Parameters:
T- The bean generic type- Parameters:
resolutionContext- The current resolution contextbeanType- The bean typefilter- A bean definition to filter out- Returns:
- The candidates
-
findBeanCandidates
@NonNull protected <T> @NonNull Collection<BeanDefinition<T>> findBeanCandidates(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, boolean collectIterables, Predicate<BeanDefinition<T>> predicate) Find bean candidates for the given type.- Type Parameters:
T- The bean generic type- Parameters:
resolutionContext- The current resolution contextbeanType- The bean typecollectIterables- Whether iterables should be collectedpredicate- The predicate to filter candidates- Returns:
- The candidates
-
collectIterableBeans
protected <T> void collectIterableBeans(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull BeanDefinition<T> iterableBean, @NonNull @NonNull Set<BeanDefinition<T>> targetSet, @NonNull @NonNull Argument<T> beanType) Collects iterable beans from a given iterable.- Type Parameters:
T- The bean type- Parameters:
resolutionContext- The resolution contextiterableBean- The iterabletargetSet- The target setbeanType- The bean type
-
findBeanCandidatesForInstance
@NonNull protected <T> @NonNull Collection<BeanDefinition<T>> findBeanCandidatesForInstance(@NonNull T instance) Find bean candidates for the given type.- Type Parameters:
T- The bean generic type- Parameters:
instance- The bean instance- Returns:
- The candidates
-
registerConfiguration
Registers an active configuration.- Parameters:
configuration- The configuration to register
-
findConcreteCandidate
@NonNull protected <T> @NonNull BeanDefinition<T> findConcreteCandidate(@NonNull @NonNull Class<T> beanType, @Nullable @Nullable Qualifier<T> qualifier, @NonNull @NonNull Collection<BeanDefinition<T>> candidates) Fall back method to attempt to find a candidate for the given definitions.- Type Parameters:
T- The generic time- Parameters:
beanType- The bean typequalifier- The qualifiercandidates- The candidates, always more than 1- Returns:
- The concrete bean definition
-
processParallelBeans
@Internal protected void processParallelBeans(List<io.micronaut.context.DefaultBeanContext.BeanDefinitionProducer> parallelBeans) Processes parallel bean definitions.- Parameters:
parallelBeans- The parallel beans
-
newNoSuchBeanException
@Internal @NonNull protected <T> @NonNull NoSuchBeanException newNoSuchBeanException(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @NonNull @NonNull Qualifier<T> qualifier, @Nullable @Nullable String message) Trigger a no such bean exception. Subclasses can improve the exception with downstream diagnosis as necessary.- Type Parameters:
T- The type of the bean- Parameters:
resolutionContext- The resolution contextbeanType- The bean typequalifier- The qualifiermessage- A message to use- Returns:
- A no such bean exception
-
resolveDisabledBeanMessage
@Nullable protected <T> @Nullable String resolveDisabledBeanMessage(BeanResolutionContext resolutionContext, Argument<T> beanType, Qualifier<T> qualifier) Resolves the message to use for a disabled bean.- Type Parameters:
T- The bean type- Parameters:
resolutionContext- The resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- The message or null if none exists
-
getBeanRegistration
@Internal public <T> BeanRegistration<T> getBeanRegistration(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Obtains the bean registration for the given type and qualifier.- Type Parameters:
T- The generic type- Parameters:
resolutionContext- The resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- A
BeanRegistration
-
getBeanRegistrations
@Internal public <T> Collection<BeanRegistration<T>> getBeanRegistrations(@Nullable @Nullable BeanResolutionContext resolutionContext, @NonNull @NonNull Argument<T> beanType, @Nullable @Nullable Qualifier<T> qualifier) Obtains the bean registrations for the given type and qualifier.- Type Parameters:
T- The generic type- Parameters:
resolutionContext- The resolution contextbeanType- The bean typequalifier- The qualifier- Returns:
- A collection of
BeanRegistration
-
getAttributes
Description copied from interface:MutableAttributeHolderOverrides the defaultAttributeHolder.getAttributes()method to return a mutable object.- Specified by:
getAttributesin interfaceAttributeHolder- Specified by:
getAttributesin interfaceMutableAttributeHolder- Returns:
- The mutable attributes
-
getAttribute
Description copied from interface:AttributeHolderObtain the value of an attribute on the HTTP method.- Specified by:
getAttributein interfaceAttributeHolder- Parameters:
name- The name of the attribute- Returns:
- An
Optionalvalue
-
getAttribute
Description copied from interface:AttributeHolderObtain the value of an attribute on the HTTP method.- Specified by:
getAttributein interfaceAttributeHolder- Type Parameters:
T- type Generic- Parameters:
name- The name of the attributetype- The required type- Returns:
- An
Optionalvalue
-
setAttribute
@NonNull public @NonNull BeanContext setAttribute(@NonNull @NonNull CharSequence name, @Nullable @Nullable Object value) Description copied from interface:MutableAttributeHolderSets an attribute on the message.- Specified by:
setAttributein interfaceMutableAttributeHolder- Parameters:
name- The name of the attributevalue- The value of the attribute- Returns:
- This message
-
removeAttribute
@NonNull public <T> @NonNull Optional<T> removeAttribute(@NonNull @NonNull CharSequence name, @NonNull @NonNull Class<T> type) Description copied from interface:MutableAttributeHolderRemove an attribute. Returning the old value if it is present.- Specified by:
removeAttributein interfaceMutableAttributeHolder- Type Parameters:
T- type Generic- Parameters:
name- The name of the attributetype- The required type- Returns:
- An
Optionalvalue
-
finalizeConfiguration
public void finalizeConfiguration()Description copied from interface:InitializableBeanContextPerforms operations required before starting the application context, such as reading bean configurations.- Specified by:
finalizeConfigurationin interfaceInitializableBeanContext
-
getConversionService
Description copied from interface:ConversionServiceProviderProvides the conversion service.- Specified by:
getConversionServicein interfaceConversionServiceProvider- Returns:
- the conversion service
-
configure
public final void configure()Description copied from interface:ConfigurableBeanContextConfigures the bean context loading all bean definitions required to perform successful startup without starting the context itself.Once called the methods of the
BeanDefinitionRegistryinterface will return results allowing inspection of the context without needing to run the context.- Specified by:
configurein interfaceConfigurableBeanContext- See Also:
-