Package io.micronaut.context
Class BeanRegistration<T>
- java.lang.Object
-
- io.micronaut.context.BeanRegistration<T>
-
- Type Parameters:
T- The type
- All Implemented Interfaces:
CreatedBean<T>,io.micronaut.core.annotation.AnnotationMetadataProvider,io.micronaut.core.annotation.AnnotationSource,io.micronaut.core.order.Ordered,BeanContextConditional,BeanType<T>,java.io.Closeable,java.lang.AutoCloseable
public class BeanRegistration<T> extends java.lang.Object implements io.micronaut.core.order.Ordered, CreatedBean<T>, BeanType<T>
A bean registration is an association between a
BeanDefinitionand a created bean, typically aSingleton.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description BeanRegistration(BeanIdentifier identifier, BeanDefinition<T> beanDefinition, T bean)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tbean()voidclose()Destroy the bean entry, performing any shutdown and releasing any dependent objects.BeanDefinition<T>definition()booleanequals(java.lang.Object o)TgetBean()BeanDefinition<T>getBeanDefinition()java.lang.Class<T>getBeanType()Returns the bean type.BeanIdentifiergetIdentifier()intgetOrder()inthashCode()BeanIdentifierid()Returns an ID that is unique to the bean and can be used to cache the instance if necessary.booleanisEnabled(BeanContext context, BeanResolutionContext resolutionContext)Return whether this component is enabled for the given context.static <K> BeanRegistration<K>of(BeanContext beanContext, BeanIdentifier identifier, BeanDefinition<K> beanDefinition, K bean)Creates new bean registration.static <K> BeanRegistration<K>of(BeanContext beanContext, BeanIdentifier identifier, BeanDefinition<K> beanDefinition, K bean, java.util.List<BeanRegistration<?>> dependents)Creates new bean registration.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclared
-
Methods inherited from interface io.micronaut.inject.BeanContextConditional
isEnabled
-
Methods inherited from interface io.micronaut.inject.BeanType
getExposedTypes, getName, isCandidateBean, isContainerType, isPrimary, requiresMethodProcessing
-
-
-
-
Constructor Detail
-
BeanRegistration
public BeanRegistration(BeanIdentifier identifier, BeanDefinition<T> beanDefinition, T bean)
- Parameters:
identifier- The bean identifierbeanDefinition- The bean definitionbean- The bean instance
-
-
Method Detail
-
of
@NonNull public static <K> BeanRegistration<K> of(@NonNull BeanContext beanContext, @NonNull BeanIdentifier identifier, @NonNull BeanDefinition<K> beanDefinition, @NonNull K bean)
Creates new bean registration. Possibly disposing registration can be returned.- Type Parameters:
K- The bean registration type- Parameters:
beanContext- The bean contextidentifier- The bean identifierbeanDefinition- The bean definitionbean- The bean instance- Returns:
- new bean registration
- Since:
- 3.5.0
-
of
@NonNull public static <K> BeanRegistration<K> of(@NonNull BeanContext beanContext, @NonNull BeanIdentifier identifier, @NonNull BeanDefinition<K> beanDefinition, @NonNull K bean, @Nullable java.util.List<BeanRegistration<?>> dependents)
Creates new bean registration. Possibly disposing registration can be returned.- Type Parameters:
K- The bean registration type- Parameters:
beanContext- The bean contextidentifier- The bean identifierbeanDefinition- The bean definitionbean- The bean instancedependents- The dependents- Returns:
- new bean registration
- Since:
- 3.5.0
-
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceio.micronaut.core.order.Ordered
-
getIdentifier
public BeanIdentifier getIdentifier()
- Returns:
- Teh bean identifier
-
getBeanDefinition
public BeanDefinition<T> getBeanDefinition()
- Returns:
- The bean definition
-
getBean
public T getBean()
- Returns:
- The bean instance
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
definition
public BeanDefinition<T> definition()
- Specified by:
definitionin interfaceCreatedBean<T>- Returns:
- The bean definition.
-
bean
@NonNull public T bean()
- Specified by:
beanin interfaceCreatedBean<T>- Returns:
- The bean
-
id
public BeanIdentifier id()
Description copied from interface:CreatedBeanReturns an ID that is unique to the bean and can be used to cache the instance if necessary.- Specified by:
idin interfaceCreatedBean<T>- Returns:
- The id
-
close
public void close()
Description copied from interface:CreatedBeanDestroy the bean entry, performing any shutdown and releasing any dependent objects.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceCreatedBean<T>
-
isEnabled
public boolean isEnabled(BeanContext context, BeanResolutionContext resolutionContext)
Description copied from interface:BeanContextConditionalReturn whether this component is enabled for the given context.- Specified by:
isEnabledin interfaceBeanContextConditional- Parameters:
context- The contextresolutionContext- The bean resolution context- Returns:
- True if it is
-
getBeanType
public java.lang.Class<T> getBeanType()
Description copied from interface:BeanTypeReturns the bean type.- Specified by:
getBeanTypein interfaceBeanType<T>- Returns:
- The underlying bean type
-
-