Class BeanManagerImpl

  • All Implemented Interfaces:
    jakarta.enterprise.inject.spi.BeanManager, Serializable, org.jboss.weld.manager.api.WeldManager

    public class BeanManagerImpl
    extends Object
    implements org.jboss.weld.manager.api.WeldManager, Serializable
    Implementation of the Bean Manager.

    Essentially a singleton for registering Beans, Contexts, Observers, Interceptors etc. as well as providing resolution

    Author:
    Pete Muir, Marius Bogoevici, Ales Justin, Jozef Hartinger
    See Also:
    Serialized Form
    • Method Detail

      • newRootManager

        public static BeanManagerImpl newRootManager​(String contextId,
                                                     String id,
                                                     org.jboss.weld.bootstrap.api.ServiceRegistry serviceRegistry)
        Create a new, root, manager
        Parameters:
        serviceRegistry -
        Returns:
      • getContextId

        public String getContextId()
      • addAccessibleBeanManager

        public void addAccessibleBeanManager​(BeanManagerImpl accessibleBeanManager)
      • addBean

        public void addBean​(jakarta.enterprise.inject.spi.Bean<?> bean)
      • addBeans

        public void addBeans​(Collection<? extends jakarta.enterprise.inject.spi.Bean<?>> beans)
        Optimization which modifies CopyOnWrite structures only once instead of once for every bean.
        Parameters:
        beans -
      • addDecorator

        public void addDecorator​(jakarta.enterprise.inject.spi.Decorator<?> bean)
      • resolveObserverMethods

        public <T> Set<jakarta.enterprise.inject.spi.ObserverMethod<? super T>> resolveObserverMethods​(T event,
                                                                                                       Annotation... bindings)
        Specified by:
        resolveObserverMethods in interface jakarta.enterprise.inject.spi.BeanManager
      • addInterceptor

        public void addInterceptor​(jakarta.enterprise.inject.spi.Interceptor<?> bean)
      • getEnabled

        public ModuleEnablement getEnabled()
        Enabled Alternatives, Interceptors and Decorators
        Returns:
      • isBeanEnabled

        public boolean isBeanEnabled​(jakarta.enterprise.inject.spi.Bean<?> bean)
      • getBeans

        public Set<jakarta.enterprise.inject.spi.Bean<?>> getBeans​(Type beanType,
                                                                   Annotation... qualifiers)
        Specified by:
        getBeans in interface jakarta.enterprise.inject.spi.BeanManager
      • getBeans

        public Set<jakarta.enterprise.inject.spi.Bean<?>> getBeans​(Type beanType,
                                                                   Set<Annotation> qualifiers)
      • getBeans

        public Set<jakarta.enterprise.inject.spi.Bean<?>> getBeans​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)
      • registerBeanNamespace

        protected void registerBeanNamespace​(jakarta.enterprise.inject.spi.Bean<?> bean)
      • getEnterpriseBeans

        public Map<org.jboss.weld.ejb.spi.EjbDescriptor<?>,​SessionBean<?>> getEnterpriseBeans()
        Gets the class-mapped beans. For internal use.
        Returns:
        The bean map
      • getBeans

        public List<jakarta.enterprise.inject.spi.Bean<?>> getBeans()
        The beans registered with the Web Bean manager which are resolvable. Does not include interceptor and decorator beans
        Returns:
        The list of known beans
      • getDecorators

        public List<jakarta.enterprise.inject.spi.Decorator<?>> getDecorators()
      • getInterceptors

        public List<jakarta.enterprise.inject.spi.Interceptor<?>> getInterceptors()
      • getDynamicAccessibleBeans

        public Iterable<jakarta.enterprise.inject.spi.Bean<?>> getDynamicAccessibleBeans()
      • getAccessibleBeans

        public Set<jakarta.enterprise.inject.spi.Bean<?>> getAccessibleBeans()
        Unlike getDynamicAccessibleBeans() this method returns a mutable set which is not updated automatically.
        Returns:
        all accessible beans
      • getDynamicAccessibleInterceptors

        public Iterable<jakarta.enterprise.inject.spi.Interceptor<?>> getDynamicAccessibleInterceptors()
      • getDynamicAccessibleDecorators

        public Iterable<jakarta.enterprise.inject.spi.Decorator<?>> getDynamicAccessibleDecorators()
      • addContext

        public void addContext​(jakarta.enterprise.context.spi.Context context)
      • addObserver

        public void addObserver​(jakarta.enterprise.inject.spi.ObserverMethod<?> observer)
        Does the actual observer registration
        Parameters:
        observer - =
      • fireEvent

        public void fireEvent​(Object event,
                              Annotation... qualifiers)
        Fires an event object with given event object for given bindings
        Specified by:
        fireEvent in interface jakarta.enterprise.inject.spi.BeanManager
        Parameters:
        event - The event object to pass along
        qualifiers - The binding types to match
      • getContext

        public jakarta.enterprise.context.spi.Context getContext​(Class<? extends Annotation> scopeType)
        Gets an active context of the given scope. Throws an exception if there are no active contexts found or if there are too many matches
        Specified by:
        getContext in interface jakarta.enterprise.inject.spi.BeanManager
        Parameters:
        scopeType - The scope to match
        Returns:
        A single active context of the given scope
        Throws:
        IllegalStateException - if there are multiple active scopes for a given context
      • getUnwrappedContext

        public jakarta.enterprise.context.spi.Context getUnwrappedContext​(Class<? extends Annotation> scopeType)
      • isContextActive

        public boolean isContextActive​(Class<? extends Annotation> scopeType)
        Specified by:
        isContextActive in interface org.jboss.weld.manager.api.WeldManager
      • getReference

        public Object getReference​(jakarta.enterprise.inject.spi.Bean<?> bean,
                                   Type requestedType,
                                   jakarta.enterprise.context.spi.CreationalContext<?> creationalContext,
                                   boolean noProxy)
      • getReference

        public Object getReference​(jakarta.enterprise.inject.spi.Bean<?> bean,
                                   Type requestedType,
                                   jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)
        Specified by:
        getReference in interface jakarta.enterprise.inject.spi.BeanManager
      • getInjectableReference

        public Object getInjectableReference​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint,
                                             jakarta.enterprise.inject.spi.Bean<?> resolvedBean,
                                             jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)
        Get a reference, registering the injection point used.
        Parameters:
        injectionPoint - the injection point to register
        resolvedBean - the bean to get a reference to
        creationalContext - the creationalContext
        Returns:
        the injectable reference
      • getInjectableReference

        public Object getInjectableReference​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint,
                                             jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)
        Specified by:
        getInjectableReference in interface jakarta.enterprise.inject.spi.BeanManager
      • getBean

        public <T> jakarta.enterprise.inject.spi.Bean<T> getBean​(Resolvable resolvable)
      • getBeans

        public Set<jakarta.enterprise.inject.spi.Bean<?>> getBeans​(String name)
        Specified by:
        getBeans in interface jakarta.enterprise.inject.spi.BeanManager
      • resolveDecorators

        public List<jakarta.enterprise.inject.spi.Decorator<?>> resolveDecorators​(Set<Type> types,
                                                                                  Annotation... qualifiers)
        Specified by:
        resolveDecorators in interface jakarta.enterprise.inject.spi.BeanManager
      • resolveDecorators

        public List<jakarta.enterprise.inject.spi.Decorator<?>> resolveDecorators​(Set<Type> types,
                                                                                  Set<Annotation> qualifiers)
      • resolveInterceptors

        public List<jakarta.enterprise.inject.spi.Interceptor<?>> resolveInterceptors​(jakarta.enterprise.inject.spi.InterceptionType type,
                                                                                      Annotation... interceptorBindings)
        Resolves a list of interceptors based on interception type and interceptor bindings. Transitive interceptor bindings of the interceptor bindings passed as a parameter are considered in the resolution process.
        Specified by:
        resolveInterceptors in interface jakarta.enterprise.inject.spi.BeanManager
        Parameters:
        type - The interception type to resolve
        interceptorBindings - The binding types to match
        Returns:
        A list of matching interceptors
      • resolveInterceptors

        public List<jakarta.enterprise.inject.spi.Interceptor<?>> resolveInterceptors​(jakarta.enterprise.inject.spi.InterceptionType type,
                                                                                      Collection<Annotation> interceptorBindings)
        Resolves a list of interceptors based on interception type and interceptor bindings. Transitive interceptor bindings of the interceptor bindings passed as a parameter are NOT considered in the resolution process. Therefore, the caller is responsible for filtering of transitive interceptor bindings in order to comply with interceptor binding inheritance and overriding (See JSR-346 9.5.2). This is a Weld-specific method.
        Parameters:
        type - The interception type to resolve
        interceptorBindings - The binding types to match
        Returns:
        A list of matching interceptors
      • getBeanResolver

        public TypeSafeBeanResolver getBeanResolver()
        Get the web bean resolver. For internal use
        Returns:
        The resolver
      • getDecoratorResolver

        public TypeSafeDecoratorResolver getDecoratorResolver()
        Get the decorator resolver. For internal use
        Returns:
        The resolver
      • getAccessibleLenientObserverNotifier

        public ObserverNotifier getAccessibleLenientObserverNotifier()
        Get the lenient observer notifier for accessible observer methods. Should never be exposed to an application.
        Returns:
        The ObserverNotifier
      • getGlobalLenientObserverNotifier

        public ObserverNotifier getGlobalLenientObserverNotifier()
        Get the lenient global observer notifier. Should never be exposed to an application.
        Returns:
        The ObserverNotifier
      • getGlobalStrictObserverNotifier

        public ObserverNotifier getGlobalStrictObserverNotifier()
        Get the Strict global observer notifier. This one should be used for firing application / extension events.
        Returns:
        The ObserverNotifier
      • toString

        public String toString()
        Gets a string representation
        Overrides:
        toString in class Object
        Returns:
        A string representation
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getServices

        public org.jboss.weld.bootstrap.api.ServiceRegistry getServices()
        Specified by:
        getServices in interface org.jboss.weld.manager.api.WeldManager
      • getContexts

        protected Map<Class<? extends Annotation>,​List<jakarta.enterprise.context.spi.Context>> getContexts()
      • getNamespaces

        protected List<String> getNamespaces()
        Returns:
        the namespaces
      • getDynamicAccessibleNamespaces

        public Iterable<String> getDynamicAccessibleNamespaces()
      • getAccessibleNamespaces

        public List<String> getAccessibleNamespaces()
        Unlike getDynamicAccessibleNamespaces() this method returns a mutable set which is not updated automatically.
        Returns:
        the accessible namespaces
      • getId

        public String getId()
        Specified by:
        getId in interface org.jboss.weld.manager.api.WeldManager
      • getObservers

        public List<jakarta.enterprise.inject.spi.ObserverMethod<?>> getObservers()
      • createInjectionTarget

        public <T> jakarta.enterprise.inject.spi.InjectionTarget<T> createInjectionTarget​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
        Specified by:
        createInjectionTarget in interface jakarta.enterprise.inject.spi.BeanManager
      • createInjectionTarget

        public <T> jakarta.enterprise.inject.spi.InjectionTarget<T> createInjectionTarget​(org.jboss.weld.ejb.spi.EjbDescriptor<T> descriptor)
        Specified by:
        createInjectionTarget in interface org.jboss.weld.manager.api.WeldManager
      • validate

        public void validate​(jakarta.enterprise.inject.spi.InjectionPoint ij)
        Specified by:
        validate in interface jakarta.enterprise.inject.spi.BeanManager
      • getInterceptorBindingDefinition

        public Set<Annotation> getInterceptorBindingDefinition​(Class<? extends Annotation> bindingType)
        Specified by:
        getInterceptorBindingDefinition in interface jakarta.enterprise.inject.spi.BeanManager
      • getPassivationCapableBean

        public jakarta.enterprise.inject.spi.Bean<?> getPassivationCapableBean​(String id)
        Specified by:
        getPassivationCapableBean in interface jakarta.enterprise.inject.spi.BeanManager
      • getPassivationCapableBean

        public jakarta.enterprise.inject.spi.Bean<?> getPassivationCapableBean​(org.jboss.weld.serialization.spi.BeanIdentifier identifier)
        Specified by:
        getPassivationCapableBean in interface org.jboss.weld.manager.api.WeldManager
      • getStereotypeDefinition

        public Set<Annotation> getStereotypeDefinition​(Class<? extends Annotation> stereotype)
        Specified by:
        getStereotypeDefinition in interface jakarta.enterprise.inject.spi.BeanManager
      • isQualifier

        public boolean isQualifier​(Class<? extends Annotation> annotationType)
        Specified by:
        isQualifier in interface jakarta.enterprise.inject.spi.BeanManager
      • isInterceptorBinding

        public boolean isInterceptorBinding​(Class<? extends Annotation> annotationType)
        Specified by:
        isInterceptorBinding in interface jakarta.enterprise.inject.spi.BeanManager
      • isNormalScope

        public boolean isNormalScope​(Class<? extends Annotation> annotationType)
        Specified by:
        isNormalScope in interface jakarta.enterprise.inject.spi.BeanManager
      • isPassivatingScope

        public boolean isPassivatingScope​(Class<? extends Annotation> annotationType)
        Specified by:
        isPassivatingScope in interface jakarta.enterprise.inject.spi.BeanManager
      • isScope

        public boolean isScope​(Class<? extends Annotation> annotationType)
        Specified by:
        isScope in interface jakarta.enterprise.inject.spi.BeanManager
      • isStereotype

        public boolean isStereotype​(Class<? extends Annotation> annotationType)
        Specified by:
        isStereotype in interface jakarta.enterprise.inject.spi.BeanManager
      • getELResolver

        public jakarta.el.ELResolver getELResolver()
        Specified by:
        getELResolver in interface jakarta.enterprise.inject.spi.BeanManager
      • wrapExpressionFactory

        public jakarta.el.ExpressionFactory wrapExpressionFactory​(jakarta.el.ExpressionFactory expressionFactory)
        Specified by:
        wrapExpressionFactory in interface jakarta.enterprise.inject.spi.BeanManager
      • createCreationalContext

        public <T> WeldCreationalContext<T> createCreationalContext​(jakarta.enterprise.context.spi.Contextual<T> contextual)
        Specified by:
        createCreationalContext in interface jakarta.enterprise.inject.spi.BeanManager
        Specified by:
        createCreationalContext in interface org.jboss.weld.manager.api.WeldManager
      • createAnnotatedType

        public <T> jakarta.enterprise.inject.spi.AnnotatedType<T> createAnnotatedType​(Class<T> type)
        Specified by:
        createAnnotatedType in interface jakarta.enterprise.inject.spi.BeanManager
      • createAnnotatedType

        public <T> jakarta.enterprise.inject.spi.AnnotatedType<T> createAnnotatedType​(Class<T> type,
                                                                                      String id)
        Specified by:
        createAnnotatedType in interface org.jboss.weld.manager.api.WeldManager
      • disposeAnnotatedType

        public <T> void disposeAnnotatedType​(Class<T> type,
                                             String id)
        Specified by:
        disposeAnnotatedType in interface org.jboss.weld.manager.api.WeldManager
      • resolve

        public <X> jakarta.enterprise.inject.spi.Bean<? extends X> resolve​(Set<jakarta.enterprise.inject.spi.Bean<? extends X>> beans)
        Specified by:
        resolve in interface jakarta.enterprise.inject.spi.BeanManager
      • getEjbDescriptor

        public <T> org.jboss.weld.ejb.spi.EjbDescriptor<T> getEjbDescriptor​(String beanName)
        Specified by:
        getEjbDescriptor in interface org.jboss.weld.manager.api.WeldManager
      • getBean

        public <T> SessionBean<T> getBean​(org.jboss.weld.ejb.spi.EjbDescriptor<T> descriptor)
        Specified by:
        getBean in interface org.jboss.weld.manager.api.WeldManager
      • cleanup

        public void cleanup()
      • cleanupAfterBoot

        public void cleanupAfterBoot()
        For internal use only. This happens after bootstrap services cleanup but before RIBean.cleanupAfterBoot().
        See Also:
        Bootstrap.endInitialization()
      • fireProcessInjectionTarget

        public <X> jakarta.enterprise.inject.spi.InjectionTarget<X> fireProcessInjectionTarget​(jakarta.enterprise.inject.spi.AnnotatedType<X> annotatedType)
        Specified by:
        fireProcessInjectionTarget in interface org.jboss.weld.manager.api.WeldManager
      • fireProcessInjectionTarget

        public <X> jakarta.enterprise.inject.spi.InjectionTarget<X> fireProcessInjectionTarget​(jakarta.enterprise.inject.spi.AnnotatedType<X> annotatedType,
                                                                                               jakarta.enterprise.inject.spi.InjectionTarget<X> injectionTarget)
        Specified by:
        fireProcessInjectionTarget in interface org.jboss.weld.manager.api.WeldManager
      • instance

        public jakarta.enterprise.inject.Instance<Object> instance()
        Specified by:
        instance in interface org.jboss.weld.manager.api.WeldManager
      • event

        public org.jboss.weld.events.WeldEvent<Object> event()
      • getInstance

        public <T> org.jboss.weld.inject.WeldInstance<Object> getInstance​(jakarta.enterprise.context.spi.CreationalContext<?> ctx)
      • createBeanAttributes

        public <T> jakarta.enterprise.inject.spi.BeanAttributes<T> createBeanAttributes​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
        Specified by:
        createBeanAttributes in interface jakarta.enterprise.inject.spi.BeanManager
      • createBeanAttributes

        public jakarta.enterprise.inject.spi.BeanAttributes<?> createBeanAttributes​(jakarta.enterprise.inject.spi.AnnotatedMember<?> member)
        Specified by:
        createBeanAttributes in interface jakarta.enterprise.inject.spi.BeanManager
      • internalCreateBeanAttributes

        public <X> jakarta.enterprise.inject.spi.BeanAttributes<?> internalCreateBeanAttributes​(jakarta.enterprise.inject.spi.AnnotatedMember<X> member)
      • createBean

        public <T> jakarta.enterprise.inject.spi.Bean<T> createBean​(jakarta.enterprise.inject.spi.BeanAttributes<T> attributes,
                                                                    Class<T> beanClass,
                                                                    jakarta.enterprise.inject.spi.InjectionTargetFactory<T> injectionTargetFactory)
        Specified by:
        createBean in interface jakarta.enterprise.inject.spi.BeanManager
      • createBean

        public <T,​X> jakarta.enterprise.inject.spi.Bean<T> createBean​(jakarta.enterprise.inject.spi.BeanAttributes<T> attributes,
                                                                            Class<X> beanClass,
                                                                            jakarta.enterprise.inject.spi.ProducerFactory<X> producerFactory)
        Specified by:
        createBean in interface jakarta.enterprise.inject.spi.BeanManager
      • createInjectionPoint

        public FieldInjectionPointAttributes<?,​?> createInjectionPoint​(jakarta.enterprise.inject.spi.AnnotatedField<?> field)
        Specified by:
        createInjectionPoint in interface jakarta.enterprise.inject.spi.BeanManager
      • createInjectionPoint

        public ParameterInjectionPointAttributes<?,​?> createInjectionPoint​(jakarta.enterprise.inject.spi.AnnotatedParameter<?> parameter)
        Specified by:
        createInjectionPoint in interface jakarta.enterprise.inject.spi.BeanManager
      • getExtension

        public <T extends jakarta.enterprise.inject.spi.Extension> T getExtension​(Class<T> extensionClass)
        Specified by:
        getExtension in interface jakarta.enterprise.inject.spi.BeanManager
      • createInterceptionFactory

        public <T> jakarta.enterprise.inject.spi.InterceptionFactory<T> createInterceptionFactory​(jakarta.enterprise.context.spi.CreationalContext<T> ctx,
                                                                                                  Class<T> clazz)
        Specified by:
        createInterceptionFactory in interface jakarta.enterprise.inject.spi.BeanManager
      • getEvent

        public jakarta.enterprise.event.Event<Object> getEvent()
        Specified by:
        getEvent in interface jakarta.enterprise.inject.spi.BeanManager
      • areQualifiersEquivalent

        public boolean areQualifiersEquivalent​(Annotation qualifier1,
                                               Annotation qualifier2)
        Specified by:
        areQualifiersEquivalent in interface jakarta.enterprise.inject.spi.BeanManager
      • areInterceptorBindingsEquivalent

        public boolean areInterceptorBindingsEquivalent​(Annotation interceptorBinding1,
                                                        Annotation interceptorBinding2)
        Specified by:
        areInterceptorBindingsEquivalent in interface jakarta.enterprise.inject.spi.BeanManager
      • getQualifierHashCode

        public int getQualifierHashCode​(Annotation qualifier)
        Specified by:
        getQualifierHashCode in interface jakarta.enterprise.inject.spi.BeanManager
      • getInterceptorBindingHashCode

        public int getInterceptorBindingHashCode​(Annotation interceptorBinding)
        Specified by:
        getInterceptorBindingHashCode in interface jakarta.enterprise.inject.spi.BeanManager
      • getLocalInjectionTargetFactory

        public <T> InjectionTargetFactoryImpl<T> getLocalInjectionTargetFactory​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
        Creates an InjectionTargetFactory for a given type. The factory will be using this BeanManager.
      • getInjectionTargetFactory

        public <T> org.jboss.weld.manager.api.WeldInjectionTargetFactory<T> getInjectionTargetFactory​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
        Creates an InjectionTargetFactory for a given type. The BeanManager for the InjectionTarget will be inferred using CDI11Deployment.getBeanDeploymentArchive(Class).
        Specified by:
        getInjectionTargetFactory in interface jakarta.enterprise.inject.spi.BeanManager
        Specified by:
        getInjectionTargetFactory in interface org.jboss.weld.manager.api.WeldManager
      • getProducerFactory

        public <X> FieldProducerFactory<X> getProducerFactory​(jakarta.enterprise.inject.spi.AnnotatedField<? super X> field,
                                                              jakarta.enterprise.inject.spi.Bean<X> declaringBean)
        Specified by:
        getProducerFactory in interface jakarta.enterprise.inject.spi.BeanManager
      • getProducerFactory

        public <X> MethodProducerFactory<X> getProducerFactory​(jakarta.enterprise.inject.spi.AnnotatedMethod<? super X> method,
                                                               jakarta.enterprise.inject.spi.Bean<X> declaringBean)
        Specified by:
        getProducerFactory in interface jakarta.enterprise.inject.spi.BeanManager
      • createInjectionTargetBuilder

        public <T> org.jboss.weld.manager.api.WeldInjectionTargetBuilder<T> createInjectionTargetBuilder​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
        Specified by:
        createInjectionTargetBuilder in interface org.jboss.weld.manager.api.WeldManager
      • createInstance

        public org.jboss.weld.inject.WeldInstance<Object> createInstance()
        Specified by:
        createInstance in interface jakarta.enterprise.inject.spi.BeanManager
      • unwrap

        public BeanManagerImpl unwrap()
        Specified by:
        unwrap in interface org.jboss.weld.manager.api.WeldManager
      • fireRequestContextInitialized

        public void fireRequestContextInitialized​(Object payload)
      • fireRequestContextBeforeDestroyed

        public void fireRequestContextBeforeDestroyed​(Object payload)
      • fireRequestContextDestroyed

        public void fireRequestContextDestroyed​(Object payload)
      • addValidationFailureCallback

        public void addValidationFailureCallback​(BiConsumer<Exception,​org.jboss.weld.bootstrap.api.Environment> callback)
      • validationFailed

        public void validationFailed​(Exception failure,
                                     org.jboss.weld.bootstrap.api.Environment environment)
      • getScopes

        public Collection<Class<? extends Annotation>> getScopes()
        Specified by:
        getScopes in interface org.jboss.weld.manager.api.WeldManager