public class DefaultBeanContext extends Object implements InitializableBeanContext
| Modifier and Type | Field and Description |
|---|---|
protected AtomicBoolean |
initializing |
protected static org.slf4j.Logger |
LOG |
protected static org.slf4j.Logger |
LOG_LIFECYCLE |
protected AtomicBoolean |
running |
protected AtomicBoolean |
terminating |
EMPTYNO_OPDEFAULT| 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(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(Argument<T> beanType,
Qualifier<T> qualifier)
Return whether the bean of the given type is contained within this context.
|
<T> boolean |
containsBean(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,
Class<T> beanType,
Qualifier<T> qualifier)
Creates a bean.
|
<T> T |
createBean(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(Class<T> beanType,
Qualifier<T> qualifier,
Map<String,Object> argumentValues)
Creates a new instance of the given bean performing dependency injection and returning a new instance.
|
<T> T |
createBean(Class<T> beanType,
Qualifier<T> qualifier,
Object... args)
Creates a new instance of the given bean performing dependency injection and returning a new instance.
|
protected CustomScopeRegistry |
createCustomScopeRegistry()
Allows customizing the custom scope registry.
|
MethodExecutionHandle<?,Object> |
createExecutionHandle(BeanDefinition<? extends Object> beanDefinition,
ExecutableMethod<Object,?> method)
Create an execution handle for the given bean definition and method.
|
<T> T |
destroyBean(Argument<T> beanType,
Qualifier<T> qualifier)
Destroys the bean for the given type causing it to be re-created.
|
<T> T |
destroyBean(Class<T> beanType)
Destroys the bean for the given type causing it to be re-created.
|
<T> T |
destroyBean(T bean)
Destroys the given bean.
|
protected <T> T |
doCreateBean(BeanResolutionContext resolutionContext,
BeanDefinition<T> definition,
Argument<T> beanType,
Qualifier<T> qualifier,
Object... args) |
protected <T> T |
doCreateBean(BeanResolutionContext resolutionContext,
BeanDefinition<T> beanDefinition,
Qualifier<T> qualifier,
Argument<T> qualifierBeanType,
boolean isSingleton,
Map<String,Object> argumentValues)
Execution the creation of a bean.
|
protected <T> T |
doCreateBean(BeanResolutionContext resolutionContext,
BeanDefinition<T> beanDefinition,
Qualifier<T> qualifier,
boolean isSingleton,
Map<String,Object> argumentValues)
Deprecated.
|
void |
finalizeConfiguration()
Performs operations required before starting the application
context, such as reading bean configurations.
|
<T> Optional<T> |
findBean(Argument<T> beanType,
Qualifier<T> qualifier)
Finds a Bean for the given type and qualifier.
|
<T> Optional<T> |
findBean(BeanResolutionContext resolutionContext,
Argument<T> beanType,
Qualifier<T> qualifier)
Find an optional bean of the given type and qualifier.
|
<T> Optional<T> |
findBean(BeanResolutionContext resolutionContext,
Class<T> beanType,
Qualifier<T> qualifier)
Find an optional bean of the given type and qualifier.
|
<T> Optional<T> |
findBean(Class<T> beanType,
Qualifier<T> qualifier)
Finds a Bean for the given type and qualifier.
|
protected <T> Collection<BeanDefinition<T>> |
findBeanCandidates(BeanResolutionContext resolutionContext,
Argument<T> beanType,
BeanDefinition<?> filter,
boolean filterProxied)
Find bean candidates for the given type.
|
protected <T> Collection<BeanDefinition<T>> |
findBeanCandidates(BeanResolutionContext resolutionContext,
Argument<T> beanType,
boolean filterProxied,
Predicate<BeanDefinition<T>> predicate)
Find bean candidates for the given type.
|
protected <T> Collection<BeanDefinition<T>> |
findBeanCandidates(Class<T> beanType,
BeanDefinition<?> filter)
Find bean candidates for the given type.
|
protected <T> Collection<BeanDefinition> |
findBeanCandidatesForInstance(T instance)
Find bean candidates for the given type.
|
Optional<BeanConfiguration> |
findBeanConfiguration(String configurationName)
Obtain a bean configuration by name.
|
<T> Optional<BeanDefinition<T>> |
findBeanDefinition(Argument<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
<T> Optional<BeanDefinition<T>> |
findBeanDefinition(Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
<T> Optional<BeanRegistration<T>> |
findBeanRegistration(T bean)
Obtain a
BeanDefinition for the given bean. |
protected <T> BeanDefinition<T> |
findConcreteCandidate(Class<T> beanType,
Qualifier<T> qualifier,
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<?> qualifier,
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> Optional<BeanDefinition<T>> |
findProxyBeanDefinition(Argument<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition. |
<T> Optional<BeanDefinition<T>> |
findProxyBeanDefinition(Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition. |
<T> Optional<BeanDefinition<T>> |
findProxyTargetBeanDefinition(Argument<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition. |
<T> Optional<BeanDefinition<T>> |
findProxyTargetBeanDefinition(Class<T> beanType,
Qualifier<T> qualifier)
Obtain the original
BeanDefinition for a ProxyBeanDefinition. |
<T,R> Optional<ExecutableMethod<T,R>> |
findProxyTargetMethod(Argument<T> beanType,
Qualifier<T> qualifier,
String method,
Class... arguments)
Finds the original unproxied method for a
ProxyBeanDefinition. |
<T,R> Optional<ExecutableMethod<T,R>> |
findProxyTargetMethod(Class<T> beanType,
Qualifier<T> qualifier,
String method,
Class... arguments)
Finds the original unproxied method for a
ProxyBeanDefinition. |
<T,R> Optional<ExecutableMethod<T,R>> |
findProxyTargetMethod(Class<T> beanType,
String method,
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> Collection<BeanRegistration<T>> |
getActiveBeanRegistrations(Class<T> beanType)
Find active
Singleton beans for the given bean type. |
Collection<BeanRegistration<?>> |
getActiveBeanRegistrations(Qualifier<?> qualifier)
Find active
Singleton beans for the given qualifier. |
Collection<BeanDefinition<?>> |
getAllBeanDefinitions()
Get all of the registered
BeanDefinition. |
Optional<Object> |
getAttribute(CharSequence name)
Obtain the value of an attribute on the HTTP method.
|
<T> Optional<T> |
getAttribute(CharSequence name,
Class<T> type)
Obtain the value of an attribute on the HTTP method.
|
MutableConvertibleValues<Object> |
getAttributes()
Overrides the default
AttributeHolder.getAttributes() method to return a mutable object. |
<T> T |
getBean(Argument<T> beanType,
Qualifier<T> qualifier)
Obtains a Bean for the given type and qualifier.
|
<T> T |
getBean(BeanDefinition<T> definition)
Obtains a Bean for the given bean definition.
|
<T> T |
getBean(BeanResolutionContext resolutionContext,
Argument<T> beanType,
Qualifier<T> qualifier)
Get a bean of the given type and qualifier.
|
<T> T |
getBean(BeanResolutionContext resolutionContext,
Class<T> beanType)
Get a bean of the given type.
|
<T> T |
getBean(BeanResolutionContext resolutionContext,
Class<T> beanType,
Qualifier<T> qualifier)
Get a bean of the given type and qualifier.
|
<T> T |
getBean(Class<T> beanType)
Obtains a Bean for the given type.
|
<T> T |
getBean(Class<T> beanType,
Qualifier<T> qualifier)
Obtains a Bean for the given type and qualifier.
|
<T> BeanDefinition<T> |
getBeanDefinition(Argument<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
Collection<BeanDefinitionReference<?>> |
getBeanDefinitionReferences()
Get all of the enabled
BeanDefinitionReference. |
<T> Collection<BeanDefinition<T>> |
getBeanDefinitions(Argument<T> beanType)
Obtain a
BeanDefinition for the given type. |
<T> Collection<BeanDefinition<T>> |
getBeanDefinitions(Argument<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
<T> Collection<BeanDefinition<T>> |
getBeanDefinitions(Class<T> beanType)
Obtain a
BeanDefinition for the given type. |
<T> Collection<BeanDefinition<T>> |
getBeanDefinitions(Class<T> beanType,
Qualifier<T> qualifier)
Obtain a
BeanDefinition for the given type. |
Collection<BeanDefinition<?>> |
getBeanDefinitions(Qualifier<Object> qualifier)
Get all of the
BeanDefinition for the given qualifier. |
<T> BeanRegistration<T> |
getBeanRegistration(Argument<T> beanType,
Qualifier<T> qualifier)
Find a bean registration for the given bean type and optional qualifier.
|
protected <T> BeanRegistration<T> |
getBeanRegistration(BeanResolutionContext resolutionContext,
Argument<T> beanType,
Qualifier<T> qualifier)
Obtains the bean registration for the given type and qualifier.
|
<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(Argument<T> beanType,
Qualifier<T> qualifier)
Find and if necessary initialize
Singleton beans for the given bean type, returning all the active registrations. |
<T> Collection<BeanRegistration<T>> |
getBeanRegistrations(BeanResolutionContext resolutionContext,
Argument<T> beanType,
Qualifier<T> qualifier)
Obtains the bean registrations for the given type and qualifier.
|
<T> Collection<BeanRegistration<T>> |
getBeanRegistrations(Class<T> beanType)
Find and if necessary initialize
Singleton beans 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 initialize
Singleton beans for the given bean type, returning all the active registrations. |
<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.
|
protected <T> Collection<T> |
getBeansOfType(BeanResolutionContext resolutionContext,
Argument<T> beanType)
Get all beans of the given type.
|
<T> Collection<T> |
getBeansOfType(BeanResolutionContext resolutionContext,
Argument<T> beanType,
Qualifier<T> qualifier)
Get all beans of the given type and qualifier.
|
<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.
|
BeanDefinitionValidator |
getBeanValidator() |
ClassLoader |
getClassLoader() |
BeanContextConfiguration |
getContextConfiguration()
Obtains the configuration for this context.
|
<T> T |
getProxyTargetBean(Argument<T> beanType,
Qualifier<T> qualifier)
Resolves the proxy target for a given bean type.
|
<T> T |
getProxyTargetBean(BeanResolutionContext resolutionContext,
Argument<T> beanType,
Qualifier<T> qualifier)
Resolves the proxy target for a given bean type.
|
<T> T |
getProxyTargetBean(Class<T> beanType,
Qualifier<T> qualifier)
Resolves the proxy target for a given bean type.
|
protected void |
initializeContext(List<BeanDefinitionReference> contextScopeBeans,
List<BeanDefinitionReference> processedBeans,
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(List<BeanDefinitionReference> parallelBeans)
Processes parallel bean definitions.
|
void |
publishEvent(Object event)
Publish the given event.
|
Future<Void> |
publishEventAsync(Object event)
Publish the given event.
|
<T> 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(Class<T> type,
T singleton,
Qualifier<T> qualifier,
boolean inject)
Registers a new singleton bean at runtime.
|
<T> Optional<T> |
removeAttribute(CharSequence name,
Class<T> type)
Remove an attribute.
|
protected Iterable<BeanConfiguration> |
resolveBeanConfigurations()
Resolves the
BeanConfiguration class instances. |
protected List<BeanDefinitionReference> |
resolveBeanDefinitionReferences()
Resolves the
BeanDefinitionReference class instances. |
protected List<BeanDefinitionReference> |
resolveBeanDefinitionReferences(Predicate<BeanDefinitionReference> predicate)
Deprecated.
|
AnnotationMetadata |
resolveMetadata(Class<?> type)
Resolve the
AnnotationMetadata for the given type. |
BeanContext |
setAttribute(CharSequence name,
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. |
<T> Stream<T> |
streamOfType(Argument<T> beanType,
Qualifier<T> qualifier)
Obtain a stream of beans of the given type.
|
<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(Class<T> beanType,
Qualifier<T> qualifier)
Obtain a stream of beans of the given type.
|
protected <T> Collection<BeanDefinition<T>> |
transformIterables(BeanResolutionContext resolutionContext,
Collection<BeanDefinition<T>> candidates,
boolean filterProxied)
Method that transforms iterable candidates if possible.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuild, build, createBean, createBean, createBean, destroyBean, getEventPublisher, registerSingleton, registerSingleton, registerSingleton, registerSingleton, run, rungetExecutableMethod, getExecutionHandle, getExecutionHandle, getProxyTargetMethod, getProxyTargetMethod, getProxyTargetMethodfindBean, findBean, findOrInstantiateBean, getBean, streamOfType, streamOfTypecontainsBean, containsBean, findBeanDefinition, findBeanDefinition, getBeanDefinition, getBeanDefinition, getBeanDefinition, getProxyTargetBeanDefinition, getProxyTargetBeanDefinitionnoOpresolveMetadataprotected static final org.slf4j.Logger LOG
protected static final org.slf4j.Logger LOG_LIFECYCLE
protected final AtomicBoolean running
protected final AtomicBoolean initializing
protected final AtomicBoolean terminating
public DefaultBeanContext()
public DefaultBeanContext(@NonNull ClassLoader classLoader)
classLoader - The class loaderpublic DefaultBeanContext(@NonNull ClassPathResourceLoader resourceLoader)
resourceLoader - The resource loaderpublic DefaultBeanContext(@NonNull BeanContextConfiguration contextConfiguration)
contextConfiguration - The context configuration@NonNull protected CustomScopeRegistry createCustomScopeRegistry()
public 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(Class<?> type)
AnnotationMetadataResolverAnnotationMetadata for the given type.resolveMetadata in interface AnnotationMetadataResolvertype - The typeAnnotationMetadatapublic <T> Optional<T> refreshBean(BeanIdentifier identifier)
BeanContextRefresh 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 BeanContextT - The concrete classidentifier - The BeanIdentifierOptional of the instance if it exists for the given registrationpublic Collection<BeanRegistration<?>> getActiveBeanRegistrations(Qualifier<?> qualifier)
BeanDefinitionRegistrySingleton 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 BeanDefinitionRegistryqualifier - The qualifierpublic <T> Collection<BeanRegistration<T>> getActiveBeanRegistrations(Class<T> beanType)
BeanDefinitionRegistrySingleton 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 BeanDefinitionRegistryT - The concrete typebeanType - The bean typepublic <T> Collection<BeanRegistration<T>> getBeanRegistrations(Class<T> beanType)
BeanDefinitionRegistrySingleton 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 BeanDefinitionRegistryT - The concrete typebeanType - The bean typepublic <T> BeanRegistration<T> getBeanRegistration(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrygetBeanRegistration in interface BeanDefinitionRegistryT - The concrete typebeanType - The bean typequalifier - The qualifierpublic <T> Collection<BeanRegistration<T>> getBeanRegistrations(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrySingleton 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 BeanDefinitionRegistryT - The concrete typebeanType - The bean typequalifier - The qualifierpublic <T> Collection<BeanRegistration<T>> getBeanRegistrations(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrySingleton 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 BeanDefinitionRegistryT - The concrete typebeanType - The bean typequalifier - The qualifierpublic <T> BeanRegistration<T> getBeanRegistration(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrygetBeanRegistration in interface BeanDefinitionRegistryT - The concrete typebeanType - The potentially parameterized bean typequalifier - The qualifierpublic <T> Optional<BeanRegistration<T>> findBeanRegistration(T bean)
BeanDefinitionRegistryBeanDefinition for the given bean.findBeanRegistration in interface BeanDefinitionRegistryT - The concrete typebean - The beanOptional of the bean definitionpublic <T,R> Optional<MethodExecutionHandle<T,R>> findExecutionHandle(Class<T> beanType, String method, Class... arguments)
ExecutionHandleLocatorfindExecutionHandle in interface ExecutionHandleLocatorT - The target beanR - The result type of the execution handlebeanType - The bean typemethod - The methodarguments - The argumentspublic MethodExecutionHandle<?,Object> createExecutionHandle(BeanDefinition<? extends Object> beanDefinition, ExecutableMethod<Object,?> method)
ExecutionHandleLocatorcreateExecutionHandle in interface ExecutionHandleLocatorbeanDefinition - The bean definitionmethod - The methodpublic <T,R> Optional<MethodExecutionHandle<T,R>> findExecutionHandle(Class<T> beanType, Qualifier<?> qualifier, String method, Class... arguments)
ExecutionHandleLocatorfindExecutionHandle in interface ExecutionHandleLocatorT - The target beanR - The result type of the execution handlebeanType - The bean typequalifier - The bean qualifermethod - The methodarguments - The argumentspublic <T,R> Optional<ExecutableMethod<T,R>> findExecutableMethod(Class<T> beanType, String method, Class[] arguments)
ExecutionHandleLocatorfindExecutableMethod in interface ExecutionHandleLocatorT - The bean type classR - The result type of the execution handlebeanType - The bean typemethod - The methodarguments - The argumentspublic <T,R> Optional<MethodExecutionHandle<T,R>> findExecutionHandle(T bean, String method, Class[] arguments)
ExecutionHandleLocatorfindExecutionHandle in interface ExecutionHandleLocatorT - 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 Class<T> type, @NonNull T singleton, Qualifier<T> qualifier, boolean inject)
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 PostConstruct hooks.
If no bean definition data is found the bean is registered as is.
registerSingleton in interface BeanContextregisterSingleton in interface BeanDefinitionRegistryT - The concrete typetype - The bean typesingleton - The singleton beanqualifier - The bean qualifierinject - Whether the singleton should be injected (defaults to true)public ClassLoader getClassLoader()
getClassLoader in interface BeanContextpublic BeanDefinitionValidator getBeanValidator()
getBeanValidator in interface BeanContextpublic Optional<BeanConfiguration> findBeanConfiguration(String configurationName)
BeanDefinitionRegistryfindBeanConfiguration in interface BeanDefinitionRegistryconfigurationName - The configuration namepublic <T> BeanDefinition<T> getBeanDefinition(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for the given type.getBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The potentially parameterized type typequalifier - The qualifierBeanDefinitionpublic <T> Optional<BeanDefinition<T>> findBeanDefinition(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for the given type.findBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The potentially parameterized typequalifier - The qualifierOptional of the bean definitionpublic <T> Optional<BeanDefinition<T>> findBeanDefinition(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for the given type.findBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definitionpublic <T> Collection<BeanDefinition<T>> getBeanDefinitions(Class<T> beanType)
BeanDefinitionRegistryBeanDefinition for the given type.getBeanDefinitions in interface BeanDefinitionRegistryT - The concrete typebeanType - The typeOptional of the bean definitionpublic <T> Collection<BeanDefinition<T>> getBeanDefinitions(Argument<T> beanType)
BeanDefinitionRegistryBeanDefinition for the given type.getBeanDefinitions in interface BeanDefinitionRegistryT - The concrete typebeanType - The typeOptional of the bean definitionpublic <T> Collection<BeanDefinition<T>> getBeanDefinitions(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for the given type.getBeanDefinitions in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definitionpublic <T> Collection<BeanDefinition<T>> getBeanDefinitions(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for the given type.getBeanDefinitions in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definitionpublic <T> boolean containsBean(@NonNull Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrycontainsBean in interface BeanDefinitionRegistryT - The concrete typebeanType - The bean typequalifier - The qualifier for the beanpublic <T> boolean containsBean(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrycontainsBean in interface BeanDefinitionRegistryT - The concrete typebeanType - The bean typequalifier - The qualifier for the bean@NonNull public <T> T getBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanLocatorgetBean in interface BeanLocatorT - The bean type parameterbeanType - The bean typequalifier - The qualifierQualifiers@NonNull public <T> T getBean(@NonNull Class<T> beanType)
BeanLocatorgetBean in interface BeanLocatorT - The bean type parameterbeanType - The bean typepublic <T> Optional<T> findBean(Class<T> beanType, Qualifier<T> qualifier)
BeanLocatorfindBean in interface BeanLocatorT - The bean type parameterbeanType - The bean typequalifier - The qualifierOptional that is either empty or containing the specified beanQualifierspublic <T> Optional<T> findBean(Argument<T> beanType, Qualifier<T> qualifier)
BeanLocatorfindBean in interface BeanLocatorT - The bean type parameterbeanType - The bean typequalifier - The qualifierOptional that is either empty or containing the specified beanQualifierspublic <T> Collection<T> getBeansOfType(Class<T> beanType)
BeanLocatorgetBeansOfType in interface BeanLocatorT - The bean type parameterbeanType - The bean typepublic <T> Collection<T> getBeansOfType(Class<T> beanType, Qualifier<T> qualifier)
BeanLocatorgetBeansOfType in interface BeanLocatorT - The bean type parameterbeanType - The bean typequalifier - The qualifierpublic <T> Collection<T> getBeansOfType(Argument<T> beanType)
BeanLocatorgetBeansOfType in interface BeanLocatorT - The bean type parameterbeanType - The potenitally parameterized bean typepublic <T> Collection<T> getBeansOfType(Argument<T> beanType, Qualifier<T> qualifier)
BeanLocatorgetBeansOfType in interface BeanLocatorT - The bean type parameterbeanType - The potenitally parameterized bean typequalifier - The qualifierpublic <T> Stream<T> streamOfType(Class<T> beanType, Qualifier<T> qualifier)
BeanLocatorstreamOfType in interface BeanLocatorT - The bean concrete typebeanType - The bean typequalifier - The qualifierQualifierspublic <T> Stream<T> streamOfType(Argument<T> beanType, Qualifier<T> qualifier)
BeanLocatorstreamOfType in interface BeanLocatorT - The bean concrete typebeanType - The potentially parameterized bean typequalifier - The qualifierQualifiersprotected <T> Stream<T> streamOfType(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier)
T - The bean concrete typeresolutionContext - The bean resolution contextbeanType - The bean typequalifier - The qualifier@Internal public <T> Stream<T> streamOfType(BeanResolutionContext resolutionContext, Argument<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)
BeanContextinject in interface BeanContextT - The bean generic typeinstance - The instance to inject@NonNull public <T> T createBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanContextNote that the instance returned is not saved as a singleton in the context.
createBean in interface BeanContextT - The bean generic typebeanType - The bean typequalifier - The qualifier@NonNull public <T> T createBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable Map<String,Object> argumentValues)
BeanContextCreates 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 BeanContextT - The bean generic typebeanType - The bean typequalifier - The qualifierargumentValues - The argument values@NonNull public <T> T createBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable Object... args)
BeanContextCreates 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 BeanContextT - 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 Argument<T> beanType, @Nullable Qualifier<T> qualifier, @Nullable Object... args)
T - the bean generic typeresolutionContext - The bean resolution contextdefinition - The bean definitionbeanType - The bean typequalifier - The qualifierargs - The argument valuespublic <T> T destroyBean(Argument<T> beanType, Qualifier<T> qualifier)
BeanContextdestroyBean in interface BeanContextT - The concrete classbeanType - The bean typequalifier - The qualifier@NonNull public <T> T destroyBean(T bean)
BeanContextdestroyBean in interface BeanContextT - The concrete classbean - The bean@Nullable public <T> T destroyBean(@NonNull Class<T> beanType)
BeanContextdestroyBean in interface BeanContextT - The concrete classbeanType - The bean type@Nullable protected <T> BeanRegistration<T> getActiveBeanRegistration(BeanDefinition<T> beanDefinition, Qualifier qualifier)
T - The bean generic typebeanDefinition - The bean definitionqualifier - The qualifier@NonNull protected <T> T createBean(@Nullable BeanResolutionContext resolutionContext, @NonNull 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> Collection<T> getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType)
T - The bean type parameterresolutionContext - The bean resolution contextbeanType - The bean type@Internal @NonNull public <T> Collection<T> getBeansOfType(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean resolution contextbeanType - The bean typequalifier - The qualifier@NonNull public <T> T getProxyTargetBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanLocatorgetProxyTargetBean in interface BeanLocatorT - The generic typebeanType - The bean typequalifier - The bean qualifier@NonNull public <T> T getProxyTargetBean(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
BeanLocatorgetProxyTargetBean in interface BeanLocatorT - The generic typebeanType - The bean typequalifier - The bean qualifier@NonNull public <T> T getProxyTargetBean(BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T - The generic typeresolutionContext - The bean resolution contextbeanType - The bean typequalifier - The bean qualifier@NonNull public <T,R> Optional<ExecutableMethod<T,R>> findProxyTargetMethod(@NonNull Class<T> beanType, @NonNull String method, @NonNull Class[] arguments)
ExecutionHandleLocatorProxyBeanDefinition.findProxyTargetMethod in interface ExecutionHandleLocatorT - The bean type classR - The result type of the execution handlebeanType - The bean typemethod - The methodarguments - The argumentspublic <T,R> Optional<ExecutableMethod<T,R>> findProxyTargetMethod(Class<T> beanType, Qualifier<T> qualifier, String method, Class... arguments)
ExecutionHandleLocatorProxyBeanDefinition.findProxyTargetMethod in interface ExecutionHandleLocatorT - The bean type classR - The result type of the execution handlebeanType - The bean typequalifier - The qualifiermethod - The methodarguments - The argumentspublic <T,R> Optional<ExecutableMethod<T,R>> findProxyTargetMethod(Argument<T> beanType, Qualifier<T> qualifier, String method, Class... arguments)
ExecutionHandleLocatorProxyBeanDefinition.findProxyTargetMethod in interface ExecutionHandleLocatorT - The bean type classR - The result type of the execution handlebeanType - The bean typequalifier - The qualifiermethod - The methodarguments - The arguments@NonNull public <T> Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for a ProxyBeanDefinition.findProxyTargetBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definitionpublic <T> Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(Argument<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for a ProxyBeanDefinition.findProxyTargetBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definition@NonNull public Collection<BeanDefinition<?>> getBeanDefinitions(@Nullable Qualifier<Object> qualifier)
BeanDefinitionRegistryBeanDefinition for the given qualifier.getBeanDefinitions in interface BeanDefinitionRegistryqualifier - The qualifier@NonNull public Collection<BeanDefinition<?>> getAllBeanDefinitions()
BeanDefinitionRegistryBeanDefinition.getAllBeanDefinitions in interface BeanDefinitionRegistry@NonNull public Collection<BeanDefinitionReference<?>> getBeanDefinitionReferences()
BeanDefinitionRegistryBeanDefinitionReference.getBeanDefinitionReferences in interface BeanDefinitionRegistry@NonNull public <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean type@NonNull public <T> T getBean(@NonNull BeanDefinition<T> definition)
BeanLocatorgetBean in interface BeanLocatorT - The bean type parameterdefinition - The bean typeQualifiers@NonNull public <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typequalifier - The qualifier@NonNull public <T> T getBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typequalifier - The qualifierpublic <T> T getBean(Argument<T> beanType, Qualifier<T> qualifier)
BeanLocatorgetBean in interface BeanLocatorT - The bean type parameterbeanType - The potentially parameterized bean typequalifier - The qualifierQualifiers@NonNull public <T> Optional<T> findBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typequalifier - The qualifierOptional@NonNull public <T> Optional<T> findBean(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typequalifier - The qualifierOptionalpublic BeanContextConfiguration getContextConfiguration()
BeanContextgetContextConfiguration in interface BeanContextBeanContextConfigurationpublic void publishEvent(@NonNull Object event)
BeanContextpublishEvent in interface BeanContextpublishEvent in interface ApplicationEventPublisher<Object>event - The event to publish@NonNull public Future<Void> publishEventAsync(@NonNull Object event)
BeanContextpublishEventAsync in interface BeanContextpublishEventAsync in interface ApplicationEventPublisher<Object>event - The event to publish@NonNull public <T> Optional<BeanDefinition<T>> findProxyBeanDefinition(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for a ProxyBeanDefinition.findProxyBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definition@NonNull public <T> Optional<BeanDefinition<T>> findProxyBeanDefinition(@NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for a ProxyBeanDefinition.findProxyBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definitionprotected void invalidateCaches()
@NonNull protected List<BeanDefinitionReference> resolveBeanDefinitionReferences()
BeanDefinitionReference class instances. Default implementation uses ServiceLoader pattern.@Deprecated @NonNull protected List<BeanDefinitionReference> resolveBeanDefinitionReferences(@Nullable Predicate<BeanDefinitionReference> predicate)
BeanDefinitionReference class instances. Default implementation uses ServiceLoader pattern.predicate - The filter predicate, can be null@NonNull protected Iterable<BeanConfiguration> resolveBeanConfigurations()
BeanConfiguration class instances. Default implementation uses ServiceLoader pattern.protected void initializeEventListeners()
protected void initializeContext(@NonNull List<BeanDefinitionReference> contextScopeBeans, @NonNull List<BeanDefinitionReference> processedBeans, @NonNull List<BeanDefinitionReference> parallelBeans)
Context scope beans.contextScopeBeans - The context scope beansprocessedBeans - The beans that require ExecutableMethodProcessor handlingparallelBeans - The parallel bean definitions@NonNull protected <T> Collection<BeanDefinition<T>> findBeanCandidates(@NonNull Class<T> beanType, @Nullable BeanDefinition<?> filter)
T - The bean generic typebeanType - The bean typefilter - A bean definition to filter out@NonNull protected <T> Collection<BeanDefinition<T>> findBeanCandidates(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<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 targets@NonNull protected <T> Collection<BeanDefinition<T>> findBeanCandidates(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, boolean filterProxied, Predicate<BeanDefinition<T>> predicate)
T - The bean generic typeresolutionContext - The current resolution contextbeanType - The bean typefilterProxied - Whether to filter out bean proxy targetspredicate - The predicate to filter candidatesprotected <T> Collection<BeanDefinition<T>> transformIterables(BeanResolutionContext resolutionContext, Collection<BeanDefinition<T>> candidates, boolean filterProxied)
T - The bean typeresolutionContext - The resolution contextcandidates - The candidates.filterProxied - Whether to filter proxied.@NonNull protected <T> 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 @Deprecated protected <T> T doCreateBean(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> beanDefinition, @Nullable Qualifier<T> qualifier, boolean isSingleton, @Nullable Map<String,Object> argumentValues)
doCreateBean(BeanResolutionContext, BeanDefinition, Qualifier, Argument, boolean, Map) instead.T - The bean generic typeresolutionContext - The BeanResolutionContextbeanDefinition - The BeanDefinitionqualifier - The QualifierisSingleton - Whether the bean is a singletonargumentValues - Any argument values passed to create the bean@Nullable protected <T> T doCreateBean(@NonNull BeanResolutionContext resolutionContext, @NonNull BeanDefinition<T> beanDefinition, @Nullable Qualifier<T> qualifier, @Nullable Argument<T> qualifierBeanType, boolean isSingleton, @Nullable Map<String,Object> argumentValues)
T - The bean generic typeresolutionContext - The BeanResolutionContextbeanDefinition - The BeanDefinitionqualifier - The QualifierqualifierBeanType - The bean type used in the qualifierisSingleton - Whether the bean is a singletonargumentValues - Any argument values passed to create the bean@NonNull protected <T> BeanDefinition<T> findConcreteCandidate(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @NonNull Collection<BeanDefinition<T>> candidates)
T - The generic timebeanType - The bean typequalifier - The qualifiercandidates - The candidates, always more than 1protected void processParallelBeans(List<BeanDefinitionReference> parallelBeans)
parallelBeans - The parallel beansprotected <T> BeanRegistration<T> getBeanRegistration(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T - The generic typeresolutionContext - The resolution contextbeanType - The bean typequalifier - The qualifierBeanRegistrationpublic <T> Collection<BeanRegistration<T>> getBeanRegistrations(@Nullable BeanResolutionContext resolutionContext, @NonNull Argument<T> beanType, @Nullable Qualifier<T> qualifier)
T - The generic typeresolutionContext - The resolution contextbeanType - The bean typequalifier - The qualifierBeanRegistration@NonNull public MutableConvertibleValues<Object> getAttributes()
MutableAttributeHolderAttributeHolder.getAttributes() method to return a mutable object.getAttributes in interface AttributeHoldergetAttributes in interface MutableAttributeHolder@NonNull public Optional<Object> getAttribute(CharSequence name)
AttributeHoldergetAttribute in interface AttributeHoldername - The name of the attributeOptional value@NonNull public <T> Optional<T> getAttribute(CharSequence name, Class<T> type)
AttributeHoldergetAttribute in interface AttributeHolderT - type Genericname - The name of the attributetype - The required typeOptional value@NonNull public BeanContext setAttribute(@NonNull CharSequence name, @Nullable Object value)
MutableAttributeHoldersetAttribute in interface MutableAttributeHoldername - The name of the attributevalue - The value of the attribute@NonNull public <T> Optional<T> removeAttribute(@NonNull CharSequence name, @NonNull Class<T> type)
MutableAttributeHolderremoveAttribute in interface MutableAttributeHolderT - type Genericname - The name of the attributetype - The required typeOptional valuepublic void finalizeConfiguration()
InitializableBeanContextfinalizeConfiguration in interface InitializableBeanContext