Class WebBeansUtil


  • public final class WebBeansUtil
    extends Object
    Contains some utility methods used in the all project.
    • Constructor Detail

    • Method Detail

      • getCurrentClassLoader

        public static ClassLoader getCurrentClassLoader()
        Gets current classloader with current thread.
        Returns:
        Current class loader instance
      • checkGenericType

        public static void checkGenericType​(Class<?> clazz,
                                            Class<? extends Annotation> scope)
        Checks the generic type requirements.
      • checkProducerGenericType

        public static void checkProducerGenericType​(jakarta.enterprise.inject.spi.Bean<?> bean,
                                                    Member member)
        Check producer method/field bean return type.
        Parameters:
        bean - producer bean instance
        member - related member instance
      • checkManagedBean

        public void checkManagedBean​(Class<?> clazz)
        Returns true if this class can be candidate for simple web bean, false otherwise.
        Parameters:
        clazz - implementation class
        Throws:
        WebBeansConfigurationException - if any configuration exception occurs
      • supportsJavaEeComponentInjections

        public boolean supportsJavaEeComponentInjections​(Class<?> clazz)
        Returns true if given class supports injections, false otherwise.

        Each plugin is asked with given class that supports injections or not.

        Parameters:
        clazz - scanned class
        Returns:
        true if given class supports injections
      • isConstructorOk

        public boolean isConstructorOk​(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)
                                throws WebBeansConfigurationException
        Check that simple web beans class has compatible constructor.
        Parameters:
        annotatedType - web beans annotatedType
        Throws:
        WebBeansConfigurationException - if the web beans has incompatible constructor
      • getInjectedConstructor

        public <T> jakarta.enterprise.inject.spi.AnnotatedConstructor<T> getInjectedConstructor​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
      • getManagerBean

        public BeanManagerBean getManagerBean()
        Creates a new manager bean instance.
        Returns:
        new manager bean instance
      • getRequestContextControllerBean

        public RequestContextControllerBean getRequestContextControllerBean()
        Creates a new bean for Request Context Controller
        Returns:
        new request context controller bean instance
      • getRequestContextInterceptorBean

        public jakarta.enterprise.inject.spi.Interceptor<?> getRequestContextInterceptorBean()
        Creates a new bean for Request Context Interceptor.
        Returns:
        new request context interceptor bean instance
      • getInstanceBean

        public <T> InstanceBean<T> getInstanceBean()
        Creates a new instance bean.
        Returns:
        new instance bean
      • getEventBean

        public <T> EventBean<T> getEventBean()
        Creates a new event bean.
        Returns:
        new event bean
      • getEventMetadataBean

        public EventMetadataBean getEventMetadataBean()
        Creates a new event bean.
        Returns:
        new event bean
      • getBeanMetadataBean

        public <T> BeanMetadataBean<T> getBeanMetadataBean()
        Creates a new bean metadata bean.
        Returns:
        new bean
      • getPrincipalBean

        public PrincipalBean getPrincipalBean()
        Creates a new bean metadata bean.
        Returns:
        new bean
      • getInterceptorMetadataBean

        public <T> InterceptorMetadataBean<T> getInterceptorMetadataBean()
        Creates a new interceptor metadata bean.
        Returns:
        new bean
      • getDecoratorMetadataBean

        public <T> DecoratorMetadataBean<T> getDecoratorMetadataBean()
        Creates a new decorator metadata bean.
        Returns:
        new bean
      • getInterceptedOrDecoratedBeanMetadataBean

        public <T> InterceptedOrDecoratedBeanMetadataBean<T> getInterceptedOrDecoratedBeanMetadataBean()
        Creates a new metadata bean.
        Returns:
        new bean
      • getConversationBean

        public ConversationBean getConversationBean()
        Returns new conversation bean instance. The name is explicitly specified in 6.7.2 and is not the normal default name.
        Returns:
        new conversation bean
      • getInjectionPointBean

        public InjectionPointBean getInjectionPointBean()
        Returns a new injected point bean instance.
        Returns:
        new injected point bean
      • getNoArgConstructor

        public <T> Constructor<T> getNoArgConstructor​(Class<T> clazz)
      • checkObtainsInjectionPointConditions

        public static boolean checkObtainsInjectionPointConditions​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)
        Returns true if instance injection point false otherwise.
        Parameters:
        injectionPoint - injection point definition
        Returns:
        true if instance injection point
      • checkNullInstance

        public static void checkNullInstance​(Object instance,
                                             Class<?> scopeType,
                                             String errorMessage,
                                             Object... errorMessageArgs)
      • checkSerializableScopeType

        public void checkSerializableScopeType​(Class<? extends Annotation> scopeType,
                                               boolean isSerializable,
                                               String errorMessage,
                                               Object... errorMessageArgs)
      • getMostSpecializedBean

        public static jakarta.enterprise.inject.spi.Bean<?> getMostSpecializedBean​(jakarta.enterprise.inject.spi.BeanManager manager,
                                                                                   jakarta.enterprise.inject.spi.Bean<?> component)
      • fireProcessAnnotatedTypeEvent

        public <T> GProcessAnnotatedType fireProcessAnnotatedTypeEvent​(jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)
        Returns ProcessAnnotatedType event.
        Type Parameters:
        T - bean type
        Parameters:
        annotatedType - bean class
        Returns:
        event
      • fireProcessSyntheticAnnotatedTypeEvent

        public <T> GProcessSyntheticAnnotatedType fireProcessSyntheticAnnotatedTypeEvent​(jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)
        Returns ProcessAnnotatedType event.
        Type Parameters:
        T - bean type
        Parameters:
        annotatedType - bean class
        Returns:
        event
      • fireProcessInjectionPointEvent

        public GProcessInjectionPoint fireProcessInjectionPointEvent​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)
        Parameters:
        injectionPoint - the original InjectionPoint
        Returns:
        fired ProcessInjectionPoint event
      • fireProcessInjectionTargetEvent

        public <T> GProcessInjectionTarget fireProcessInjectionTargetEvent​(InjectionTargetImpl<T> injectionTarget,
                                                                           jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)
        Returns ProcessInjectionTarget event.
        Type Parameters:
        T - bean type
        Returns:
        event
      • fireProcessInjectionTargetEventForJavaEeComponents

        public <T> GProcessInjectionTarget fireProcessInjectionTargetEventForJavaEeComponents​(Class<T> componentClass)
        Returns ProcessInjectionTarget event.
        Type Parameters:
        T - bean type
        Returns:
        event
      • fireProcessProducerEvent

        public <T> jakarta.enterprise.inject.spi.Producer<T> fireProcessProducerEvent​(jakarta.enterprise.inject.spi.Producer<T> producer,
                                                                                      jakarta.enterprise.inject.spi.AnnotatedMember<?> annotatedMember)
      • fireProcessProducerMethodBeanEvent

        public void fireProcessProducerMethodBeanEvent​(Map<ProducerMethodBean<?>,​jakarta.enterprise.inject.spi.AnnotatedMethod<?>> annotatedMethods,
                                                       jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)
      • fireProcessProducerFieldBeanEvent

        public void fireProcessProducerFieldBeanEvent​(Map<ProducerFieldBean<?>,​jakarta.enterprise.inject.spi.AnnotatedField<?>> annotatedFields)
      • checkInjectionPointNamedQualifier

        public static void checkInjectionPointNamedQualifier​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)
      • setInjectionTargetBeanEnableFlag

        public void setInjectionTargetBeanEnableFlag​(InjectionTargetBean<?> bean)
        Sets bean enabled flag.
        Parameters:
        bean - bean instance
      • isBeanEnabled

        public boolean isBeanEnabled​(jakarta.enterprise.inject.spi.BeanAttributes<?> beanAttributes,
                                     jakarta.enterprise.inject.spi.AnnotatedType<?> at,
                                     Set<Class<? extends Annotation>> stereotypes)
      • isBeanEnabled

        public boolean isBeanEnabled​(jakarta.enterprise.inject.spi.AnnotatedType<?> at,
                                     Set<Class<? extends Annotation>> stereotypes)
      • getStereotypePriority

        public jakarta.annotation.Priority getStereotypePriority​(Class<? extends Annotation> stereotype,
                                                                 Set<Class<? extends Annotation>> stereotypes)
      • isAlternative

        public static boolean isAlternative​(jakarta.enterprise.inject.spi.Annotated annotated,
                                            Set<Class<? extends Annotation>> stereotypes)
      • isExtensionBeanEventType

        public static boolean isExtensionBeanEventType​(Type type)
      • isDefaultExtensionBeanEventType

        public static boolean isDefaultExtensionBeanEventType​(Class<?> clazz)
      • isExtensionProducerOrObserverEventType

        public static boolean isExtensionProducerOrObserverEventType​(Type type)
      • isDefaultExtensionProducerOrObserverEventType

        public static boolean isDefaultExtensionProducerOrObserverEventType​(Class<?> clazz)
      • isDependent

        public static boolean isDependent​(jakarta.enterprise.inject.spi.Bean<?> bean)
      • inspectDefinitionErrorStack

        public void inspectDefinitionErrorStack​(String logMessage)
      • inspectDeploymentErrorStack

        public void inspectDeploymentErrorStack​(String logMessage)
      • getPassivationId

        public static String getPassivationId​(jakarta.enterprise.context.spi.Contextual<?> contextual)
        Parameters:
        contextual - the Bean to check
        Returns:
        the uniqueId if it is PassivationCapable and enabled
      • defineManagedBeanWithoutFireEvents

        public <T> ManagedBean<T> defineManagedBeanWithoutFireEvents​(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
        This method will be used in AfterBeanDiscovery.addBean(jakarta.enterprise.inject.spi.Bean)}
      • isPassivationCapableDependency

        public boolean isPassivationCapableDependency​(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)
      • throwRuntimeExceptions

        public static void throwRuntimeExceptions​(Exception e)
      • isDecorator

        public static boolean isDecorator​(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)
        Returns:
        true if this annotated type represents a decorator.
      • isAnnotatedTypeDecoratorOrInterceptor

        public boolean isAnnotatedTypeDecoratorOrInterceptor​(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)
        Return true if this annotated type represents a decorator.
        Parameters:
        annotatedType - annotated type
        Returns:
        true if decorator
      • isCdiInterceptor

        public static boolean isCdiInterceptor​(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)
        Returns:
        true if this AnnotatedType represents a CDI Interceptor defined via a Interceptor annotation
      • checkManagedBeanCondition

        public <X> void checkManagedBeanCondition​(jakarta.enterprise.inject.spi.AnnotatedType<X> type)
                                           throws WebBeansConfigurationException
        Checks the implementation class for checking conditions.
        Parameters:
        type - implementation class
        Throws:
        WebBeansConfigurationException - if any configuration exception occurs
      • validate

        public void validate​(Set<jakarta.enterprise.inject.spi.InjectionPoint> injectionPoints,
                             jakarta.enterprise.inject.spi.Bean<?> bean)
      • checkTypeVariables

        public void checkTypeVariables​(jakarta.enterprise.util.TypeLiteral<?> subtype)
      • validEventType

        public void validEventType​(Type eventType,
                                   Type metadataType)
      • isContainerEventType

        public boolean isContainerEventType​(Class<?> type)
      • isContainerEventType

        public boolean isContainerEventType​(Object event)
      • fireProcessBeanAttributes

        public <T> ProcessBeanAttributesImpl<T> fireProcessBeanAttributes​(jakarta.enterprise.inject.spi.Annotated annotatedType,
                                                                          Class<?> type,
                                                                          jakarta.enterprise.inject.spi.BeanAttributes<T> ba)
      • validateBeanInjection

        public void validateBeanInjection​(jakarta.enterprise.inject.spi.Bean<?> bean)