public class DefaultBeanContext extends Object implements BeanContext
| Modifier and Type | Field and Description |
|---|---|
protected AtomicBoolean |
initializing |
protected static org.slf4j.Logger |
LOG |
protected AtomicBoolean |
running |
protected AtomicBoolean |
terminating |
DEFAULT| Constructor and Description |
|---|
DefaultBeanContext()
Construct a new bean context using the same classloader that loaded this DefaultBeanContext class.
|
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(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.
|
<T> T |
destroyBean(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,
Class<T> beanType,
Qualifier<T> qualifier,
Object... args) |
protected <T> T |
doCreateBean(BeanResolutionContext resolutionContext,
BeanDefinition<T> beanDefinition,
Qualifier<T> qualifier,
boolean isSingleton,
Map<String,Object> argumentValues)
Execution the creation of a bean.
|
<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(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(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(Class<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(Class<T> beanType,
String method,
Class[] arguments)
Finds the original unproxied method for a
ProxyBeanDefinition. |
<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. |
<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.
|
Collection<BeanDefinitionReference<?>> |
getBeanDefinitionReferences()
Get all of the enabled
BeanDefinitionReference. |
<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. |
protected <T> Provider<T> |
getBeanProvider(BeanResolutionContext resolutionContext,
Class<T> beanType)
Get provided beans of the given type.
|
protected <T> Provider<T> |
getBeanProvider(BeanResolutionContext resolutionContext,
Class<T> beanType,
Qualifier<T> qualifier)
Get a bean provider.
|
<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. |
protected <T> Collection<T> |
getBeansOfType(BeanResolutionContext resolutionContext,
Class<T> beanType)
Get all beans of the given type.
|
protected <T> Collection<T> |
getBeansOfType(BeanResolutionContext resolutionContext,
Class<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.
|
ClassLoader |
getClassLoader() |
<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)
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()
Processes parallel bean definitions.
|
void |
publishEvent(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.
|
protected Iterable<BeanConfiguration> |
resolveBeanConfigurations()
Resolves the
BeanConfiguration class instances. |
protected List<BeanDefinitionReference> |
resolveBeanDefinitionReferences()
Resolves the
BeanDefinitionReference class instances. |
AnnotationMetadata |
resolveMetadata(Class<?> type)
Resolve the
AnnotationMetadata for the given type. |
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> 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuild, build, createBean, createBean, createBean, registerSingleton, registerSingleton, registerSingleton, registerSingleton, run, rungetExecutableMethod, getExecutionHandle, getExecutionHandle, getProxyTargetMethodfindBean, findOrInstantiateBean, streamOfTypecontainsBean, findBeanDefinition, getBeanDefinition, getBeanDefinition, getProxyTargetBeanDefinitionresolveMetadataprotected static final org.slf4j.Logger LOG
protected final AtomicBoolean running
protected final AtomicBoolean initializing
protected final AtomicBoolean terminating
public DefaultBeanContext()
public DefaultBeanContext(ClassLoader classLoader)
classLoader - The class loaderpublic DefaultBeanContext(ClassPathResourceLoader resourceLoader)
resourceLoader - The resource loaderpublic 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.getActiveBeanRegistrations in interface BeanDefinitionRegistryqualifier - The qualifierpublic <T> Collection<BeanRegistration<T>> getActiveBeanRegistrations(Class<T> beanType)
BeanDefinitionRegistrySingleton beans for the given bean type.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.getBeanRegistrations in interface BeanDefinitionRegistryT - The concrete typebeanType - The bean typepublic <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 <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(Class<T> type, 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 Optional<BeanConfiguration> findBeanConfiguration(String configurationName)
BeanDefinitionRegistryfindBeanConfiguration in interface BeanDefinitionRegistryconfigurationName - The configuration namepublic <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(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> boolean containsBean(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistrycontainsBean in interface BeanDefinitionRegistryT - The concrete typebeanType - The bean typequalifier - The qualifier for the beanpublic <T> T getBean(Class<T> beanType, Qualifier<T> qualifier)
BeanLocatorgetBean in interface BeanLocatorT - The bean type parameterbeanType - The bean typequalifier - The qualifierQualifierspublic <T> T getBean(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> 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> Stream<T> streamOfType(Class<T> beanType, Qualifier<T> qualifier)
BeanLocatorstreamOfType in interface BeanLocatorT - The bean concrete typebeanType - The 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 qualifierpublic <T> T inject(T instance)
BeanContextinject in interface BeanContextT - The bean generic typeinstance - The instance to injectpublic <T> T createBean(Class<T> beanType, 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 qualifierpublic <T> T createBean(Class<T> beanType, Qualifier<T> qualifier, 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 valuespublic <T> T createBean(Class<T> beanType, Qualifier<T> qualifier, 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 valuesprotected <T> T doCreateBean(BeanResolutionContext resolutionContext, BeanDefinition<T> definition, Class<T> beanType, Qualifier<T> qualifier, 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(Class<T> beanType)
BeanContextdestroyBean in interface BeanContextT - The concrete classbeanType - The bean typeprotected <T> T createBean(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier)
T - The bean generic typeresolutionContext - The bean resolution contextbeanType - The bean typequalifier - The qualifierprotected <T> T inject(BeanResolutionContext resolutionContext, BeanDefinition requestingBeanDefinition, T instance)
T - The instance typeresolutionContext - The bean resolution contextrequestingBeanDefinition - The requesting bean definitioninstance - The instanceprotected <T> Collection<T> getBeansOfType(BeanResolutionContext resolutionContext, Class<T> beanType)
T - The bean type parameterresolutionContext - The bean resolution contextbeanType - The bean typeprotected <T> Collection<T> getBeansOfType(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean resolution contextbeanType - The bean typequalifier - The qualifierprotected <T> Provider<T> getBeanProvider(BeanResolutionContext resolutionContext, Class<T> beanType)
T - The bean type parameterresolutionContext - The bean resolution contextbeanType - The bean typepublic <T> T getProxyTargetBean(Class<T> beanType, Qualifier<T> qualifier)
BeanLocatorgetProxyTargetBean in interface BeanLocatorT - The generic typebeanType - The bean typequalifier - The bean qualifierpublic <T,R> Optional<ExecutableMethod<T,R>> findProxyTargetMethod(Class<T> beanType, String method, 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> Optional<BeanDefinition<T>> findProxyTargetBeanDefinition(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for a ProxyBeanDefinition.findProxyTargetBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definitionpublic Collection<BeanDefinition<?>> getBeanDefinitions(Qualifier<Object> qualifier)
BeanDefinitionRegistryBeanDefinition for the given qualifier.getBeanDefinitions in interface BeanDefinitionRegistryqualifier - The qualiferpublic Collection<BeanDefinition<?>> getAllBeanDefinitions()
BeanDefinitionRegistryBeanDefinition.getAllBeanDefinitions in interface BeanDefinitionRegistrypublic Collection<BeanDefinitionReference<?>> getBeanDefinitionReferences()
BeanDefinitionRegistryBeanDefinitionReference.getBeanDefinitionReferences in interface BeanDefinitionRegistrypublic <T> T getBean(BeanResolutionContext resolutionContext, Class<T> beanType)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typepublic <T> T getBean(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typequalifier - The qualifierpublic <T> Optional<T> findBean(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean context resolutionbeanType - The bean typequalifier - The qualifierOptionalpublic void publishEvent(Object event)
ApplicationEventPublisherpublishEvent in interface ApplicationEventPublisherevent - The event to publishprotected void invalidateCaches()
protected <T> Provider<T> getBeanProvider(BeanResolutionContext resolutionContext, Class<T> beanType, Qualifier<T> qualifier)
T - The bean type parameterresolutionContext - The bean resolution contextbeanType - The bean typequalifier - The qualifierprotected List<BeanDefinitionReference> resolveBeanDefinitionReferences()
BeanDefinitionReference class instances. Default implementation uses ServiceLoader pattern.protected Iterable<BeanConfiguration> resolveBeanConfigurations()
BeanConfiguration class instances. Default implementation uses ServiceLoader pattern.protected void initializeEventListeners()
protected void initializeContext(List<BeanDefinitionReference> contextScopeBeans, List<BeanDefinitionReference> processedBeans)
Context scope beans.contextScopeBeans - The context scope beansprocessedBeans - The beans that require ExecutableMethodProcessor handlingprotected <T> Collection<BeanDefinition<T>> findBeanCandidates(Class<T> beanType, BeanDefinition<?> filter)
T - The bean generic typebeanType - The bean typefilter - A bean definition to filter outprotected <T> Collection<BeanDefinition> findBeanCandidatesForInstance(T instance)
T - The bean generic typeinstance - The bean instanceprotected void registerConfiguration(BeanConfiguration configuration)
configuration - The configuration to registerprotected <T> T doCreateBean(@Nonnull BeanResolutionContext resolutionContext, BeanDefinition<T> beanDefinition, Qualifier<T> qualifier, boolean isSingleton, Map<String,Object> argumentValues)
T - The bean generic typeresolutionContext - The BeanResolutionContextbeanDefinition - The BeanDefinitionqualifier - The QualifierisSingleton - Whether the bean is a singletonargumentValues - Any argument values passed to create the beanprotected <T> BeanDefinition<T> findConcreteCandidate(Class<T> beanType, Qualifier<T> qualifier, Collection<BeanDefinition<T>> candidates)
T - The generic timebeanType - The bean typequalifier - The qualifiercandidates - The candidatesprotected void processParallelBeans()
public <T> Optional<BeanDefinition<T>> findProxyBeanDefinition(Class<T> beanType, Qualifier<T> qualifier)
BeanDefinitionRegistryBeanDefinition for a ProxyBeanDefinition.findProxyBeanDefinition in interface BeanDefinitionRegistryT - The concrete typebeanType - The typequalifier - The qualifierOptional of the bean definition