public class DefaultBeanContext extends java.lang.Object implements BeanContext
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicBoolean |
initializing |
protected static org.slf4j.Logger |
LOG |
protected static org.slf4j.Logger |
LOG_LIFECYCLE |
protected java.util.concurrent.atomic.AtomicBoolean |
running |
protected java.util.concurrent.atomic.AtomicBoolean |
terminating |
EMPTY
DEFAULT
Constructor and Description |
---|
DefaultBeanContext()
Construct a new bean context using the same classloader that loaded this DefaultBeanContext class.
|
DefaultBeanContext(BeanContextConfiguration contextConfiguration)
Creates a new bean context with the given configuration.
|
DefaultBeanContext(java.lang.ClassLoader classLoader)
Construct a new bean context with the given class loader.
|
DefaultBeanContext(ClassPathResourceLoader resourceLoader)
Construct a new bean context with the given class loader.
|
Modifier and Type | Method and Description |
---|---|
<T> boolean |
containsBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Return whether the bean of the given type is contained within this context.
|
protected <T> T |
createBean(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Creates a bean.
|
<T> T |
createBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Creates a new instance of the given bean performing dependency injection and returning a new instance.
|
<T> T |
createBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier,
java.util.Map<java.lang.String,java.lang.Object> argumentValues)
Creates a new instance of the given bean performing dependency injection and returning a new instance.
|
<T> T |
createBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier,
java.lang.Object... args)
Creates a new instance of the given bean performing dependency injection and returning a new instance.
|
MethodExecutionHandle<?,java.lang.Object> |
createExecutionHandle(BeanDefinition<? extends java.lang.Object> beanDefinition,
ExecutableMethod<java.lang.Object,?> method)
Create an execution handle for the given bean definition and method.
|
<T> T |
destroyBean(java.lang.Class<T> beanType)
Destroys the bean for the given type causing it to be re-created.
|
protected <T> T |
doCreateBean(BeanResolutionContext resolutionContext,
BeanDefinition<T> definition,
java.lang.Class<T> beanType,
Qualifier<T> qualifier,
java.lang.Object... args) |
protected <T> T |
doCreateBean(BeanResolutionContext resolutionContext,
BeanDefinition<T> beanDefinition,
Qualifier<T> qualifier,
boolean isSingleton,
java.util.Map<java.lang.String,java.lang.Object> argumentValues)
Execution the creation of a bean.
|
<T> java.util.Optional<T> |
findBean(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Find an optional bean of the given type and qualifier.
|
<T> java.util.Optional<T> |
findBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Finds a Bean for the given type and qualifier.
|
protected <T> java.util.Collection<BeanDefinition<T>> |
findBeanCandidates(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
BeanDefinition<?> filter,
boolean filterProxied)
Find bean candidates for the given type.
|
protected <T> java.util.Collection<BeanDefinition<T>> |
findBeanCandidates(java.lang.Class<T> beanType,
BeanDefinition<?> filter)
Find bean candidates for the given type.
|
protected <T> java.util.Collection<BeanDefinition> |
findBeanCandidatesForInstance(T instance)
Find bean candidates for the given type.
|
java.util.Optional<BeanConfiguration> |
findBeanConfiguration(java.lang.String configurationName)
Obtain a bean configuration by name.
|
<T> java.util.Optional<BeanDefinition<T>> |
findBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
<T> java.util.Optional<BeanRegistration<T>> |
findBeanRegistration(T bean)
Obtain a
BeanDefinition for the given bean. |
protected <T> BeanDefinition<T> |
findConcreteCandidate(java.lang.Class<T> beanType,
Qualifier<T> qualifier,
java.util.Collection<BeanDefinition<T>> candidates)
Fall back method to attempt to find a candidate for the given definitions.
|
<T,R> java.util.Optional<ExecutableMethod<T,R>> |
findExecutableMethod(java.lang.Class<T> beanType,
java.lang.String method,
java.lang.Class[] arguments)
Finds an optimized execution handle for invoking a bean method.
|
<T,R> java.util.Optional<MethodExecutionHandle<T,R>> |
findExecutionHandle(java.lang.Class<T> beanType,
Qualifier<?> qualifier,
java.lang.String method,
java.lang.Class... arguments)
Finds an optimized execution handle for invoking a bean method.
|
<T,R> java.util.Optional<MethodExecutionHandle<T,R>> |
findExecutionHandle(java.lang.Class<T> beanType,
java.lang.String method,
java.lang.Class... arguments)
Finds an optimized execution handle for invoking a bean method.
|
<T,R> java.util.Optional<MethodExecutionHandle<T,R>> |
findExecutionHandle(T bean,
java.lang.String method,
java.lang.Class[] arguments)
Finds an optimized execution handle for invoking a bean method.
|
<T> java.util.Optional<BeanDefinition<T>> |
findProxyBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition . |
<T> java.util.Optional<BeanDefinition<T>> |
findProxyTargetBeanDefinition(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition . |
<T,R> java.util.Optional<ExecutableMethod<T,R>> |
findProxyTargetMethod(java.lang.Class<T> beanType,
Qualifier<T> qualifier,
java.lang.String method,
java.lang.Class... arguments)
Finds the original unproxied method for a
ProxyBeanDefinition . |
<T,R> java.util.Optional<ExecutableMethod<T,R>> |
findProxyTargetMethod(java.lang.Class<T> beanType,
java.lang.String method,
java.lang.Class[] arguments)
Finds the original unproxied method for a
ProxyBeanDefinition . |
protected <T> BeanRegistration<T> |
getActiveBeanRegistration(BeanDefinition<T> beanDefinition,
Qualifier qualifier)
Find an active
Singleton bean for the given definition and qualifier. |
<T> java.util.Collection<BeanRegistration<T>> |
getActiveBeanRegistrations(java.lang.Class<T> beanType)
Find active
Singleton beans for the given bean type. |
java.util.Collection<BeanRegistration<?>> |
getActiveBeanRegistrations(Qualifier<?> qualifier)
Find active
Singleton beans for the given qualifier. |
java.util.Collection<BeanDefinition<?>> |
getAllBeanDefinitions()
Get all of the registered
BeanDefinition . |
java.util.Optional<java.lang.Object> |
getAttribute(java.lang.CharSequence name)
Obtain the value of an attribute on the HTTP method.
|
<T> java.util.Optional<T> |
getAttribute(java.lang.CharSequence name,
java.lang.Class<T> type)
Obtain the value of an attribute on the HTTP method.
|
MutableConvertibleValues<java.lang.Object> |
getAttributes()
Overrides the default
AttributeHolder.getAttributes() method to return a mutable object. |
<T> T |
getBean(BeanDefinition<T> definition)
Obtains a Bean for the given bean definition.
|
<T> T |
getBean(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType)
Get a bean of the given type.
|
<T> T |
getBean(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Get a bean of the given type and qualifier.
|
<T> T |
getBean(java.lang.Class<T> beanType)
Obtains a Bean for the given type.
|
<T> T |
getBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtains a Bean for the given type and qualifier.
|
java.util.Collection<BeanDefinitionReference<?>> |
getBeanDefinitionReferences()
Get all of the enabled
BeanDefinitionReference . |
<T> java.util.Collection<BeanDefinition<T>> |
getBeanDefinitions(java.lang.Class<T> beanType)
Obtain a
BeanDefinition for the given type. |
<T> java.util.Collection<BeanDefinition<T>> |
getBeanDefinitions(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
java.util.Collection<BeanDefinition<?>> |
getBeanDefinitions(Qualifier<java.lang.Object> qualifier)
Get all of the
BeanDefinition for the given qualifier. |
protected <T> javax.inject.Provider<T> |
getBeanProvider(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType)
Get provided beans of the given type.
|
protected <T> javax.inject.Provider<T> |
getBeanProvider(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Get a bean provider.
|
<T> java.util.Collection<BeanRegistration<T>> |
getBeanRegistrations(java.lang.Class<T> beanType)
Find and if necessary initialize
Singleton beans for the given bean type, returning all the active registrations. |
protected <T> java.util.Collection<T> |
getBeansOfType(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType)
Get all beans of the given type.
|
protected <T> java.util.Collection<T> |
getBeansOfType(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Get all beans of the given type and qualifier.
|
<T> java.util.Collection<T> |
getBeansOfType(java.lang.Class<T> beanType)
Get all beans of the given type.
|
<T> java.util.Collection<T> |
getBeansOfType(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Get all beans of the given type.
|
BeanDefinitionValidator |
getBeanValidator() |
java.lang.ClassLoader |
getClassLoader() |
<T> T |
getProxyTargetBean(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Resolves the proxy target for a given bean type.
|
protected void |
initializeContext(java.util.List<BeanDefinitionReference> contextScopeBeans,
java.util.List<BeanDefinitionReference> processedBeans,
java.util.List<BeanDefinitionReference> parallelBeans)
Initialize the context with the given
Context scope beans. |
protected void |
initializeEventListeners()
Initialize the event listeners.
|
protected <T> T |
inject(BeanResolutionContext resolutionContext,
BeanDefinition requestingBeanDefinition,
T instance)
Injects a bean.
|
<T> T |
inject(T instance)
Inject an existing instance.
|
protected void |
invalidateCaches()
Invalidates the bean caches.
|
boolean |
isRunning() |
protected void |
processParallelBeans(java.util.List<BeanDefinitionReference> parallelBeans)
Processes parallel bean definitions.
|
void |
publishEvent(java.lang.Object event)
Publish the given event.
|
java.util.concurrent.Future<java.lang.Void> |
publishEventAsync(java.lang.Object event)
Publish the given event.
|
<T> java.util.Optional<T> |
refreshBean(BeanIdentifier identifier)
Refresh the state of the given registered bean applying dependency injection and configuration wiring again.
|
protected void |
registerConfiguration(BeanConfiguration configuration)
Registers an active configuration.
|
<T> BeanContext |
registerSingleton(java.lang.Class<T> type,
T singleton,
Qualifier<T> qualifier,
boolean inject)
Registers a new singleton bean at runtime.
|
<T> java.util.Optional<T> |
removeAttribute(java.lang.CharSequence name,
java.lang.Class<T> type)
Remove an attribute.
|
protected java.lang.Iterable<BeanConfiguration> |
resolveBeanConfigurations()
Resolves the
BeanConfiguration class instances. |
protected java.util.List<BeanDefinitionReference> |
resolveBeanDefinitionReferences()
Resolves the
BeanDefinitionReference class instances. |
AnnotationMetadata |
resolveMetadata(java.lang.Class<?> type)
Resolve the
AnnotationMetadata for the given type. |
BeanContext |
setAttribute(java.lang.CharSequence name,
java.lang.Object value)
Sets an attribute on the message.
|
BeanContext |
start()
The start method will read all bean definition classes found on the classpath and initialize any pre-required
state.
|
BeanContext |
stop()
The close method will shut down the context calling
PreDestroy hooks on loaded
singletons. |
protected <T> java.util.stream.Stream<T> |
streamOfType(BeanResolutionContext resolutionContext,
java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtains a stream of beans of the given type and qualifier.
|
<T> java.util.stream.Stream<T> |
streamOfType(java.lang.Class<T> beanType,
Qualifier<T> qualifier)
Obtain a stream of beans of the given type.
|
protected <T> java.util.Collection<BeanDefinition<T>> |
transformIterables(BeanResolutionContext resolutionContext,
java.util.Collection<BeanDefinition<T>> candidates,
boolean filterProxied)
Method that transforms iterable candidates if possible.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
build, build, createBean, createBean, createBean, registerSingleton, registerSingleton, registerSingleton, registerSingleton, run, run
getExecutableMethod, getExecutionHandle, getExecutionHandle, getProxyTargetMethod, getProxyTargetMethod
findBean, findOrInstantiateBean, streamOfType
containsBean, findBeanDefinition, getBeanDefinition, getBeanDefinition, getProxyTargetBeanDefinition
resolveMetadata
protected static final org.slf4j.Logger LOG
protected static final org.slf4j.Logger LOG_LIFECYCLE
protected final java.util.concurrent.atomic.AtomicBoolean running
protected final java.util.concurrent.atomic.AtomicBoolean initializing
protected final java.util.concurrent.atomic.AtomicBoolean terminating
public DefaultBeanContext()
public DefaultBeanContext(@NonNull java.lang.ClassLoader classLoader)
classLoader
- The class loaderpublic DefaultBeanContext(@NonNull ClassPathResourceLoader resourceLoader)
resourceLoader
- The resource loaderpublic DefaultBeanContext(@NonNull BeanContextConfiguration contextConfiguration)
contextConfiguration
- The context configurationpublic boolean isRunning()
isRunning
in interface LifeCycle<BeanContext>
public BeanContext start()
start
in interface LifeCycle<BeanContext>
public BeanContext stop()
PreDestroy
hooks on loaded
singletons.stop
in interface LifeCycle<BeanContext>
@NonNull public AnnotationMetadata resolveMetadata(java.lang.Class<?> type)
AnnotationMetadataResolver
AnnotationMetadata
for the given type.resolveMetadata
in interface AnnotationMetadataResolver
type
- The typeAnnotationMetadata
public <T> java.util.Optional<T> refreshBean(BeanIdentifier identifier)
BeanContext
Refresh the state of the given registered bean applying dependency injection and configuration wiring again.
Note that if the bean was produced by a Factory
then this method will
refresh the factory too
refreshBean
in interface BeanContext
T
- The concrete classidentifier
- The BeanIdentifier
Optional
of the instance if it exists for the given registrationpublic java.util.Collection<BeanRegistration<?>> getActiveBeanRegistrations(Qualifier<?> qualifier)
BeanDefinitionRegistry
Singleton
beans 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.getActiveBeanRegistrations
in interface BeanDefinitionRegistry
qualifier
- The qualifierpublic <T> java.util.Collection<BeanRegistration<T>> getActiveBeanRegistrations(java.lang.Class<T> beanType)
BeanDefinitionRegistry
Singleton
beans 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.getActiveBeanRegistrations
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The bean typepublic <T> java.util.Collection<BeanRegistration<T>> getBeanRegistrations(java.lang.Class<T> beanType)
BeanDefinitionRegistry
Singleton
beans 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.getBeanRegistrations
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The bean typepublic <T> java.util.Optional<BeanRegistration<T>> findBeanRegistration(T bean)
BeanDefinitionRegistry
BeanDefinition
for the given bean.findBeanRegistration
in interface BeanDefinitionRegistry
T
- The concrete typebean
- The beanOptional
of the bean definitionpublic <T,R> java.util.Optional<MethodExecutionHandle<T,R>> findExecutionHandle(java.lang.Class<T> beanType, java.lang.String method, java.lang.Class... arguments)
ExecutionHandleLocator
findExecutionHandle
in interface ExecutionHandleLocator
T
- The target beanR
- The result type of the execution handlebeanType
- The bean typemethod
- The methodarguments
- The argumentspublic MethodExecutionHandle<?,java.lang.Object> createExecutionHandle(BeanDefinition<? extends java.lang.Object> beanDefinition, ExecutableMethod<java.lang.Object,?> method)
ExecutionHandleLocator
createExecutionHandle
in interface ExecutionHandleLocator
beanDefinition
- The bean definitionmethod
- The methodpublic <T,R> java.util.Optional<MethodExecutionHandle<T,R>> findExecutionHandle(java.lang.Class<T> beanType, Qualifier<?> qualifier, java.lang.String method, java.lang.Class... arguments)
ExecutionHandleLocator
findExecutionHandle
in interface ExecutionHandleLocator
T
- The target beanR
- The result type of the execution handlebeanType
- The bean typequalifier
- The bean qualifermethod
- The methodarguments
- The argumentspublic <T,R> java.util.Optional<ExecutableMethod<T,R>> findExecutableMethod(java.lang.Class<T> beanType, java.lang.String method, java.lang.Class[] arguments)
ExecutionHandleLocator
findExecutableMethod
in interface ExecutionHandleLocator
T
- The bean type classR
- The result type of the execution handlebeanType
- The bean typemethod
- The methodarguments
- The argumentspublic <T,R> java.util.Optional<MethodExecutionHandle<T,R>> findExecutionHandle(T bean, java.lang.String method, java.lang.Class[] arguments)
ExecutionHandleLocator
findExecutionHandle
in interface ExecutionHandleLocator
T
- The target beanR
- The result type of the execution handlebean
- The bean to invoke the method onmethod
- The methodarguments
- The argumentspublic <T> BeanContext registerSingleton(@NonNull java.lang.Class<T> type, @NonNull T singleton, Qualifier<T> qualifier, boolean inject)
BeanDefinitionRegistry
Registers 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 PostConstruct
hooks.
If no bean definition data is found the bean is registered as is.
registerSingleton
in interface BeanContext
registerSingleton
in interface BeanDefinitionRegistry
T
- The concrete typetype
- The bean typesingleton
- The singleton beanqualifier
- The bean qualifierinject
- Whether the singleton should be injected (defaults to true)public java.lang.ClassLoader getClassLoader()
getClassLoader
in interface BeanContext
public BeanDefinitionValidator getBeanValidator()
getBeanValidator
in interface BeanContext
public java.util.Optional<BeanConfiguration> findBeanConfiguration(java.lang.String configurationName)
BeanDefinitionRegistry
findBeanConfiguration
in interface BeanDefinitionRegistry
configurationName
- The configuration namepublic <T> java.util.Optional<BeanDefinition<T>> findBeanDefinition(java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistry
BeanDefinition
for the given type.findBeanDefinition
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionpublic <T> java.util.Collection<BeanDefinition<T>> getBeanDefinitions(java.lang.Class<T> beanType)
BeanDefinitionRegistry
BeanDefinition
for the given type.getBeanDefinitions
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The typeOptional
of the bean definitionpublic <T> java.util.Collection<BeanDefinition<T>> getBeanDefinitions(java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistry
BeanDefinition
for the given type.getBeanDefinitions
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionpublic <T> boolean containsBean(@NonNull java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistry
containsBean
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The bean typequalifier
- The qualifier for the beanpublic <T> T getBean(java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanLocator
getBean
in interface BeanLocator
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifierQualifiers
public <T> T getBean(java.lang.Class<T> beanType)
BeanLocator
getBean
in interface BeanLocator
T
- The bean type parameterbeanType
- The bean typepublic <T> java.util.Optional<T> findBean(java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanLocator
findBean
in interface BeanLocator
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifierOptional
that is either empty or containing the specified beanQualifiers
public <T> java.util.Collection<T> getBeansOfType(java.lang.Class<T> beanType)
BeanLocator
getBeansOfType
in interface BeanLocator
T
- The bean type parameterbeanType
- The bean typepublic <T> java.util.Collection<T> getBeansOfType(java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanLocator
getBeansOfType
in interface BeanLocator
T
- The bean type parameterbeanType
- The bean typequalifier
- The qualifierpublic <T> java.util.stream.Stream<T> streamOfType(java.lang.Class<T> beanType, Qualifier<T> qualifier)
BeanLocator
streamOfType
in interface BeanLocator
T
- The bean concrete typebeanType
- The bean typequalifier
- The qualifierQualifiers
protected <T> java.util.stream.Stream<T> streamOfType(BeanResolutionContext resolutionContext, java.lang.Class<T> beanType, Qualifier<T> qualifier)
T
- The bean concrete typeresolutionContext
- The bean resolution contextbeanType
- The bean typequalifier
- The qualifier@NonNull public <T> T inject(@NonNull T instance)
BeanContext
inject
in interface BeanContext
T
- The bean generic typeinstance
- The instance to inject@NonNull public <T> T createBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanContext
Note that the instance returned is not saved as a singleton in the context.
createBean
in interface BeanContext
T
- The bean generic typebeanType
- The bean typequalifier
- The qualifier@NonNull public <T> T createBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable java.util.Map<java.lang.String,java.lang.Object> argumentValues)
BeanContext
Creates a new instance of the given bean performing dependency injection and returning a new instance.
If the bean defines any Parameter
values then the values passed
in the argumentValues
parameter will be used
Note that the instance returned is not saved as a singleton in the context.
createBean
in interface BeanContext
T
- The bean generic typebeanType
- The bean typequalifier
- The qualifierargumentValues
- The argument values@NonNull public <T> T createBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable java.lang.Object... args)
BeanContext
Creates a new instance of the given bean performing dependency injection and returning a new instance.
If the bean defines any Parameter
values then the values passed in
the argumentValues
parameter will be used
Note that the instance returned is not saved as a singleton in the context.
createBean
in interface BeanContext
T
- The bean generic typebeanType
- The bean typequalifier
- The qualifierargs
- The argument values@NonNull protected <T> T doCreateBean(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> definition, @NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable java.lang.Object... args)
T
- the bean generic typeresolutionContext
- The bean resolution contextdefinition
- The bean definitionbeanType
- The bean typequalifier
- The qualifierargs
- The argument values@Nullable public <T> T destroyBean(@NonNull java.lang.Class<T> beanType)
BeanContext
destroyBean
in interface BeanContext
T
- The concrete classbeanType
- The bean type@Nullable protected <T> BeanRegistration<T> getActiveBeanRegistration(BeanDefinition<T> beanDefinition, Qualifier qualifier)
Singleton
bean for the given definition and qualifier.T
- The bean generic typebeanDefinition
- The bean definitionqualifier
- The qualifier@NonNull protected <T> T createBean(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean generic typeresolutionContext
- The bean resolution contextbeanType
- The bean typequalifier
- The qualifier@NonNull protected <T> T inject(@NonNull BeanResolutionContext resolutionContext, @Nullable BeanDefinition requestingBeanDefinition, @NonNull T instance)
T
- The instance typeresolutionContext
- The bean resolution contextrequestingBeanDefinition
- The requesting bean definitioninstance
- The instance@NonNull protected <T> java.util.Collection<T> getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType)
T
- The bean type parameterresolutionContext
- The bean resolution contextbeanType
- The bean type@NonNull protected <T> java.util.Collection<T> getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterresolutionContext
- The bean resolution contextbeanType
- The bean typequalifier
- The qualifier@NonNull protected <T> javax.inject.Provider<T> getBeanProvider(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType)
T
- The bean type parameterresolutionContext
- The bean resolution contextbeanType
- The bean type@NonNull public <T> T getProxyTargetBean(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanLocator
getProxyTargetBean
in interface BeanLocator
T
- The generic typebeanType
- The bean typequalifier
- The bean qualifier@NonNull public <T,R> java.util.Optional<ExecutableMethod<T,R>> findProxyTargetMethod(@NonNull java.lang.Class<T> beanType, @NonNull java.lang.String method, @NonNull java.lang.Class[] arguments)
ExecutionHandleLocator
ProxyBeanDefinition
.findProxyTargetMethod
in interface ExecutionHandleLocator
T
- The bean type classR
- The result type of the execution handlebeanType
- The bean typemethod
- The methodarguments
- The argumentspublic <T,R> java.util.Optional<ExecutableMethod<T,R>> findProxyTargetMethod(java.lang.Class<T> beanType, Qualifier<T> qualifier, java.lang.String method, java.lang.Class... arguments)
ExecutionHandleLocator
ProxyBeanDefinition
.findProxyTargetMethod
in interface ExecutionHandleLocator
T
- The bean type classR
- The result type of the execution handlebeanType
- The bean typequalifier
- The qualifiermethod
- The methodarguments
- The arguments@NonNull public <T> java.util.Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinitionRegistry
BeanDefinition
for a ProxyBeanDefinition
.findProxyTargetBeanDefinition
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definition@NonNull public java.util.Collection<BeanDefinition<?>> getBeanDefinitions(@Nullable Qualifier<java.lang.Object> qualifier)
BeanDefinitionRegistry
BeanDefinition
for the given qualifier.getBeanDefinitions
in interface BeanDefinitionRegistry
qualifier
- The qualifer@NonNull public java.util.Collection<BeanDefinition<?>> getAllBeanDefinitions()
BeanDefinitionRegistry
BeanDefinition
.getAllBeanDefinitions
in interface BeanDefinitionRegistry
@NonNull public java.util.Collection<BeanDefinitionReference<?>> getBeanDefinitionReferences()
BeanDefinitionRegistry
BeanDefinitionReference
.getBeanDefinitionReferences
in interface BeanDefinitionRegistry
@NonNull public <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType)
T
- The bean type parameterresolutionContext
- The bean context resolutionbeanType
- The bean type@NonNull public <T> T getBean(@NonNull BeanDefinition<T> definition)
BeanLocator
getBean
in interface BeanLocator
T
- The bean type parameterdefinition
- The bean typeQualifiers
@NonNull public <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterresolutionContext
- The bean context resolutionbeanType
- The bean typequalifier
- The qualifier@NonNull public <T> java.util.Optional<T> findBean(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterresolutionContext
- The bean context resolutionbeanType
- The bean typequalifier
- The qualifierOptional
public void publishEvent(@NonNull java.lang.Object event)
ApplicationEventPublisher
publishEvent
in interface ApplicationEventPublisher
event
- The event to publish@NonNull public java.util.concurrent.Future<java.lang.Void> publishEventAsync(@NonNull java.lang.Object event)
ApplicationEventPublisher
publishEventAsync
in interface ApplicationEventPublisher
event
- The event to publish@NonNull public <T> java.util.Optional<BeanDefinition<T>> findProxyBeanDefinition(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinitionRegistry
BeanDefinition
for a ProxyBeanDefinition
.findProxyBeanDefinition
in interface BeanDefinitionRegistry
T
- The concrete typebeanType
- The typequalifier
- The qualifierOptional
of the bean definitionprotected void invalidateCaches()
@NonNull protected <T> javax.inject.Provider<T> getBeanProvider(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier)
T
- The bean type parameterresolutionContext
- The bean resolution contextbeanType
- The bean typequalifier
- The qualifier@NonNull protected java.util.List<BeanDefinitionReference> resolveBeanDefinitionReferences()
BeanDefinitionReference
class instances. Default implementation uses ServiceLoader pattern.@NonNull protected java.lang.Iterable<BeanConfiguration> resolveBeanConfigurations()
BeanConfiguration
class instances. Default implementation uses ServiceLoader pattern.protected void initializeEventListeners()
protected void initializeContext(@NonNull java.util.List<BeanDefinitionReference> contextScopeBeans, @NonNull java.util.List<BeanDefinitionReference> processedBeans, @NonNull java.util.List<BeanDefinitionReference> parallelBeans)
Context
scope beans.contextScopeBeans
- The context scope beansprocessedBeans
- The beans that require ExecutableMethodProcessor
handlingparallelBeans
- The parallel bean definitions@NonNull protected <T> java.util.Collection<BeanDefinition<T>> findBeanCandidates(@NonNull java.lang.Class<T> beanType, @Nullable BeanDefinition<?> filter)
T
- The bean generic typebeanType
- The bean typefilter
- A bean definition to filter out@NonNull protected <T> java.util.Collection<BeanDefinition<T>> findBeanCandidates(@Nullable BeanResolutionContext resolutionContext, @NonNull java.lang.Class<T> beanType, @Nullable BeanDefinition<?> filter, boolean filterProxied)
T
- The bean generic typeresolutionContext
- The current resolution contextbeanType
- The bean typefilter
- A bean definition to filter outfilterProxied
- Whether to filter out bean proxy targetsprotected <T> java.util.Collection<BeanDefinition<T>> transformIterables(BeanResolutionContext resolutionContext, java.util.Collection<BeanDefinition<T>> candidates, boolean filterProxied)
T
- The bean typeresolutionContext
- The resolution contextcandidates
- The candidates.filterProxied
- Whether to filter proxied.@NonNull protected <T> java.util.Collection<BeanDefinition> findBeanCandidatesForInstance(@NonNull T instance)
T
- The bean generic typeinstance
- The bean instanceprotected void registerConfiguration(@NonNull BeanConfiguration configuration)
configuration
- The configuration to register@Nullable protected <T> T doCreateBean(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> beanDefinition, @Nullable Qualifier<T> qualifier, boolean isSingleton, @Nullable java.util.Map<java.lang.String,java.lang.Object> argumentValues)
T
- The bean generic typeresolutionContext
- The BeanResolutionContext
beanDefinition
- The BeanDefinition
qualifier
- The Qualifier
isSingleton
- Whether the bean is a singletonargumentValues
- Any argument values passed to create the bean@NonNull protected <T> BeanDefinition<T> findConcreteCandidate(@NonNull java.lang.Class<T> beanType, @Nullable Qualifier<T> qualifier, @NonNull java.util.Collection<BeanDefinition<T>> candidates)
T
- The generic timebeanType
- The bean typequalifier
- The qualifiercandidates
- The candidatesprotected void processParallelBeans(java.util.List<BeanDefinitionReference> parallelBeans)
parallelBeans
- The parallel beans@NonNull public MutableConvertibleValues<java.lang.Object> getAttributes()
MutableAttributeHolder
AttributeHolder.getAttributes()
method to return a mutable object.getAttributes
in interface AttributeHolder
getAttributes
in interface MutableAttributeHolder
@NonNull public java.util.Optional<java.lang.Object> getAttribute(java.lang.CharSequence name)
AttributeHolder
getAttribute
in interface AttributeHolder
name
- The name of the attributeOptional
value@NonNull public <T> java.util.Optional<T> getAttribute(java.lang.CharSequence name, java.lang.Class<T> type)
AttributeHolder
getAttribute
in interface AttributeHolder
T
- type Genericname
- The name of the attributetype
- The required typeOptional
value@NonNull public BeanContext setAttribute(@NonNull java.lang.CharSequence name, @Nullable java.lang.Object value)
MutableAttributeHolder
setAttribute
in interface MutableAttributeHolder
name
- The name of the attributevalue
- The value of the attribute@NonNull public <T> java.util.Optional<T> removeAttribute(@NonNull java.lang.CharSequence name, @NonNull java.lang.Class<T> type)
MutableAttributeHolder
removeAttribute
in interface MutableAttributeHolder
T
- type Genericname
- The name of the attributetype
- The required typeOptional
value