You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2021/12/13 09:49:45 UTC
[openwebbeans] 02/02: OWB-1397 javax.inject.Scope scopes are not Bean Defining Annotations
This is an automated email from the ASF dual-hosted git repository.
struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
commit d5c77a8e7b980cae8f1bc824bfb34a7290dde021
Author: Mark Struberg <st...@apache.org>
AuthorDate: Mon Dec 13 10:40:15 2021 +0100
OWB-1397 javax.inject.Scope scopes are not Bean Defining Annotations
---
.../corespi/scanner/AbstractMetaDataDiscovery.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
index 777abc4..4ca7624 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
@@ -43,6 +43,7 @@ import org.apache.xbean.finder.filter.Filter;
import org.apache.xbean.finder.util.Files;
import javax.decorator.Decorator;
+import javax.enterprise.context.Dependent;
import javax.interceptor.Interceptor;
import java.io.File;
@@ -68,6 +69,11 @@ public abstract class AbstractMetaDataDiscovery implements BdaScannerService
public static final String META_INF_BEANS_XML = "META-INF/beans.xml";
+ // via constant to also adopt to shading.
+ private static final String DEPENDENT_CLASS = Dependent.class.getName();
+
+ private Map<String, Boolean> annotationCache = new HashMap<>();
+
private BeanArchiveService beanArchiveService;
/**
@@ -364,6 +370,7 @@ public abstract class AbstractMetaDataDiscovery implements BdaScannerService
finder = null;
archive = null;
loader = null;
+ annotationCache.clear();
}
@@ -568,16 +575,22 @@ public abstract class AbstractMetaDataDiscovery implements BdaScannerService
{
String annotationName = annotationInfo.getName();
- // TODO add caches
+ Boolean isBeanAnnotation = annotationCache.get(annotationName);
+ if (isBeanAnnotation != null)
+ {
+ return isBeanAnnotation;
+ }
try
{
Class<? extends Annotation> annotationType = (Class<? extends Annotation>) WebBeansUtil.getCurrentClassLoader().loadClass(annotationName);
- boolean isBeanAnnotation = webBeansContext().getBeanManagerImpl().isScope(annotationType);
+
+ isBeanAnnotation = DEPENDENT_CLASS.equals(annotationName) || webBeansContext().getBeanManagerImpl().isNormalScope(annotationType);
if (!isBeanAnnotation)
{
isBeanAnnotation = webBeansContext().getBeanManagerImpl().isStereotype(annotationType);
}
+ annotationCache.put(annotationName, isBeanAnnotation);
return isBeanAnnotation;
}