Class 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 BeanDefinition and a created bean, typically a Singleton.

    Since:
    1.0
    • Constructor Detail

      • BeanRegistration

        public BeanRegistration​(BeanIdentifier identifier,
                                BeanDefinition<T> beanDefinition,
                                T bean)
        Parameters:
        identifier - The bean identifier
        beanDefinition - The bean definition
        bean - 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 context
        identifier - The bean identifier
        beanDefinition - The bean definition
        bean - 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 context
        identifier - The bean identifier
        beanDefinition - The bean definition
        bean - The bean instance
        dependents - The dependents
        Returns:
        new bean registration
        Since:
        3.5.0
      • getOrder

        public int getOrder()
        Specified by:
        getOrder in interface io.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:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • bean

        @NonNull
        public T bean()
        Specified by:
        bean in interface CreatedBean<T>
        Returns:
        The bean
      • id

        public BeanIdentifier id()
        Description copied from interface: CreatedBean
        Returns an ID that is unique to the bean and can be used to cache the instance if necessary.
        Specified by:
        id in interface CreatedBean<T>
        Returns:
        The id
      • close

        public void close()
        Description copied from interface: CreatedBean
        Destroy the bean entry, performing any shutdown and releasing any dependent objects.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface CreatedBean<T>
      • getBeanType

        public java.lang.Class<T> getBeanType()
        Description copied from interface: BeanType
        Returns the bean type.
        Specified by:
        getBeanType in interface BeanType<T>
        Returns:
        The underlying bean type