Package org.apache.webbeans.util
Class WebBeansUtil
- java.lang.Object
-
- org.apache.webbeans.util.WebBeansUtil
-
public final class WebBeansUtil extends Object
Contains some utility methods used in the all project.
-
-
Constructor Summary
Constructors Constructor Description WebBeansUtil(WebBeansContext webBeansContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckGenericType(Class<?> clazz, Class<? extends Annotation> scope)Checks the generic type requirements.static voidcheckInjectionPointNamedQualifier(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)voidcheckManagedBean(Class<?> clazz)Returns true if this class can be candidate for simple web bean, false otherwise.<X> voidcheckManagedBeanCondition(jakarta.enterprise.inject.spi.AnnotatedType<X> type)Checks the implementation class for checking conditions.voidcheckManagedBeanCondition(Class<?> clazz)static voidcheckNullInstance(Object instance, Class<?> scopeType, String errorMessage, Object... errorMessageArgs)static booleancheckObtainsInjectionPointConditions(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)Returns true if instance injection point false otherwise.static voidcheckProducerGenericType(jakarta.enterprise.inject.spi.Bean<?> bean, Member member)Check producer method/field bean return type.voidcheckSerializableScopeType(Class<? extends Annotation> scopeType, boolean isSerializable, String errorMessage, Object... errorMessageArgs)voidcheckTypeVariables(jakarta.enterprise.util.TypeLiteral<?> subtype)<T> ManagedBean<T>defineManagedBeanWithoutFireEvents(jakarta.enterprise.inject.spi.AnnotatedType<T> type)This method will be used inAfterBeanDiscovery.addBean(jakarta.enterprise.inject.spi.Bean)}<T> GProcessAnnotatedTypefireProcessAnnotatedTypeEvent(jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)ReturnsProcessAnnotatedTypeevent.<T> ProcessBeanAttributesImpl<T>fireProcessBeanAttributes(jakarta.enterprise.inject.spi.Annotated annotatedType, Class<?> type, jakarta.enterprise.inject.spi.BeanAttributes<T> ba)GProcessInjectionPointfireProcessInjectionPointEvent(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)<T> GProcessInjectionTargetfireProcessInjectionTargetEvent(InjectionTargetImpl<T> injectionTarget, jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)ReturnsProcessInjectionTargetevent.<T> GProcessInjectionTargetfireProcessInjectionTargetEventForJavaEeComponents(Class<T> componentClass)ReturnsProcessInjectionTargetevent.<T> jakarta.enterprise.inject.spi.Producer<T>fireProcessProducerEvent(jakarta.enterprise.inject.spi.Producer<T> producer, jakarta.enterprise.inject.spi.AnnotatedMember<?> annotatedMember)voidfireProcessProducerFieldBeanEvent(Map<ProducerFieldBean<?>,jakarta.enterprise.inject.spi.AnnotatedField<?>> annotatedFields)voidfireProcessProducerMethodBeanEvent(Map<ProducerMethodBean<?>,jakarta.enterprise.inject.spi.AnnotatedMethod<?>> annotatedMethods, jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)<T> GProcessSyntheticAnnotatedTypefireProcessSyntheticAnnotatedTypeEvent(jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)ReturnsProcessAnnotatedTypeevent.<T> BeanMetadataBean<T>getBeanMetadataBean()Creates a new bean metadata bean.ConversationBeangetConversationBean()Returns new conversation bean instance.static ClassLoadergetCurrentClassLoader()Gets current classloader with current thread.<T> DecoratorMetadataBean<T>getDecoratorMetadataBean()Creates a new decorator metadata bean.<T> EventBean<T>getEventBean()Creates a new event bean.EventMetadataBeangetEventMetadataBean()Creates a new event bean.<T> jakarta.enterprise.inject.spi.AnnotatedConstructor<T>getInjectedConstructor(jakarta.enterprise.inject.spi.AnnotatedType<T> type)InjectionPointBeangetInjectionPointBean()Returns a new injected point bean instance.<T> InstanceBean<T>getInstanceBean()Creates a new instance bean.<T> InterceptedOrDecoratedBeanMetadataBean<T>getInterceptedOrDecoratedBeanMetadataBean()Creates a new metadata bean.InterceptionFactoryBeangetInterceptionFactoryBean()<T> InterceptorMetadataBean<T>getInterceptorMetadataBean()Creates a new interceptor metadata bean.BeanManagerBeangetManagerBean()Creates a new manager bean instance.static jakarta.enterprise.inject.spi.Bean<?>getMostSpecializedBean(jakarta.enterprise.inject.spi.BeanManager manager, jakarta.enterprise.inject.spi.Bean<?> component)<T> Constructor<T>getNoArgConstructor(Class<T> clazz)static StringgetPassivationId(jakarta.enterprise.context.spi.Contextual<?> contextual)PrincipalBeangetPrincipalBean()Creates a new bean metadata bean.RequestContextControllerBeangetRequestContextControllerBean()Creates a new bean for Request Context Controllerjakarta.enterprise.inject.spi.Interceptor<?>getRequestContextInterceptorBean()Creates a new bean for Request Context Interceptor.jakarta.annotation.PrioritygetStereotypePriority(Class<? extends Annotation> stereotype, Set<Class<? extends Annotation>> stereotypes)voidinspectDefinitionErrorStack(String logMessage)voidinspectDeploymentErrorStack(String logMessage)static booleanisAlternative(jakarta.enterprise.inject.spi.Annotated annotated, Set<Class<? extends Annotation>> stereotypes)booleanisAnnotatedTypeDecoratorOrInterceptor(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)Return true if this annotated type represents a decorator.booleanisBeanEnabled(jakarta.enterprise.inject.spi.AnnotatedType<?> at, Set<Class<? extends Annotation>> stereotypes)booleanisBeanEnabled(jakarta.enterprise.inject.spi.BeanAttributes<?> beanAttributes, jakarta.enterprise.inject.spi.AnnotatedType<?> at, Set<Class<? extends Annotation>> stereotypes)static booleanisCdiInterceptor(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)booleanisConstructorOk(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)Check that simple web beans class has compatible constructor.booleanisContainerEventType(Class<?> type)booleanisContainerEventType(Object event)static booleanisDecorator(jakarta.enterprise.inject.spi.AnnotatedType<?> annotatedType)static booleanisDefaultExtensionBeanEventType(Class<?> clazz)static booleanisDefaultExtensionProducerOrObserverEventType(Class<?> clazz)static booleanisDependent(jakarta.enterprise.inject.spi.Bean<?> bean)static booleanisExtensionBeanEventType(Type type)static booleanisExtensionProducerOrObserverEventType(Type type)booleanisPassivationCapableDependency(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)booleanisStereotypeWithPriority(Class<? extends Annotation> stereotype, Set<Class<? extends Annotation>> stereotypes)voidsetBeanEnableFlagForProducerBean(InjectionTargetBean<?> parent, AbstractProducerBean<?> producer, Annotation[] annotations)voidsetInjectionTargetBeanEnableFlag(InjectionTargetBean<?> bean)Sets bean enabled flag.booleansupportsJavaEeComponentInjections(Class<?> clazz)Returns true if given class supports injections, false otherwise.static voidthrowRuntimeExceptions(Exception e)voidvalidate(Set<jakarta.enterprise.inject.spi.InjectionPoint> injectionPoints, jakarta.enterprise.inject.spi.Bean<?> bean)voidvalidateBeanInjection(jakarta.enterprise.inject.spi.Bean<?> bean)voidvalidEventType(Type eventType, Type metadataType)
-
-
-
Constructor Detail
-
WebBeansUtil
public WebBeansUtil(WebBeansContext webBeansContext)
-
-
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 instancemember- 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
-
checkManagedBeanCondition
public void checkManagedBeanCondition(Class<?> clazz) throws WebBeansConfigurationException
- Throws:
WebBeansConfigurationException
-
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 WebBeansConfigurationExceptionCheck 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)
ReturnsProcessAnnotatedTypeevent.- Type Parameters:
T- bean type- Parameters:
annotatedType- bean class- Returns:
- event
-
fireProcessSyntheticAnnotatedTypeEvent
public <T> GProcessSyntheticAnnotatedType fireProcessSyntheticAnnotatedTypeEvent(jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)
ReturnsProcessAnnotatedTypeevent.- Type Parameters:
T- bean type- Parameters:
annotatedType- bean class- Returns:
- event
-
fireProcessInjectionPointEvent
public GProcessInjectionPoint fireProcessInjectionPointEvent(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint)
- Parameters:
injectionPoint- the originalInjectionPoint- Returns:
- fired
ProcessInjectionPointevent
-
fireProcessInjectionTargetEvent
public <T> GProcessInjectionTarget fireProcessInjectionTargetEvent(InjectionTargetImpl<T> injectionTarget, jakarta.enterprise.inject.spi.AnnotatedType<T> annotatedType)
ReturnsProcessInjectionTargetevent.- Type Parameters:
T- bean type- Returns:
- event
-
fireProcessInjectionTargetEventForJavaEeComponents
public <T> GProcessInjectionTarget fireProcessInjectionTargetEventForJavaEeComponents(Class<T> componentClass)
ReturnsProcessInjectionTargetevent.- 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)
-
isStereotypeWithPriority
public boolean isStereotypeWithPriority(Class<? extends Annotation> stereotype, 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)
-
setBeanEnableFlagForProducerBean
public void setBeanEnableFlagForProducerBean(InjectionTargetBean<?> parent, AbstractProducerBean<?> producer, Annotation[] annotations)
-
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- theBeanto check- Returns:
- the uniqueId if it is
PassivationCapableand enabled
-
defineManagedBeanWithoutFireEvents
public <T> ManagedBean<T> defineManagedBeanWithoutFireEvents(jakarta.enterprise.inject.spi.AnnotatedType<T> type)
This method will be used inAfterBeanDiscovery.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:
trueif 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:
trueif this AnnotatedType represents a CDI Interceptor defined via aInterceptorannotation
-
checkManagedBeanCondition
public <X> void checkManagedBeanCondition(jakarta.enterprise.inject.spi.AnnotatedType<X> type) throws WebBeansConfigurationExceptionChecks 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)
-
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)
-
getInterceptionFactoryBean
public InterceptionFactoryBean getInterceptionFactoryBean()
-
-