This is an automated email from the ASF dual-hosted git repository.
tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/deltaspike.git
The following commit(s) were added to refs/heads/master by this push:
new 02e33e5 DELTASPIKE-1398 - fixed delegation and change it to more
agressive use of CDI.current. This also fixes the mem leak as our caching isn't
used anymore.
02e33e5 is described below
commit 02e33e5125b995a184e7678f0938ad107e98cd2e
Author: Thomas Andraschko <[email protected]>
AuthorDate: Thu Dec 12 13:24:38 2019 +0100
DELTASPIKE-1398 - fixed delegation and change it to more agressive use of
CDI.current. This also fixes the mem leak as our caching isn't used anymore.
---
.../core/api/provider/BeanManagerProvider.java | 41 ++++++++++++++++------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git
a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
index ee16477..117f13f 100644
---
a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
+++
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java
@@ -76,9 +76,8 @@ public class BeanManagerProvider implements Extension
Method resolvedCdiBeanManagerMethod = null;
//only init methods if a cdi 1.1+ container is available and the
delegation-mode isn't deactivated.
//deactivation is e.g. useful if owb is used in "parallel mode" in a
weld-based server.
- if (cdiClass != null &&
!CoreBaseConfig.BeanManagerIntegration.DELEGATE_LOOKUP)
+ if (cdiClass != null &&
CoreBaseConfig.BeanManagerIntegration.DELEGATE_LOOKUP)
{
-
try
{
resolvedCdiCurrentMethod =
cdiClass.getDeclaredMethod("current");
@@ -135,6 +134,12 @@ public class BeanManagerProvider implements Extension
*/
public static boolean isActive()
{
+ // CDI#current delegation enabled, skip everything
+ if (CDI_CURRENT_METHOD != null && CDI_CURRENT_BEAN_MANAGER_METHOD !=
null)
+ {
+ return bmpSingleton != null;
+ }
+
return bmpSingleton != null &&
bmpSingleton.bmInfos.containsKey(ClassUtils.getClassLoader(null));
}
@@ -180,6 +185,12 @@ public class BeanManagerProvider implements Extension
{
setBeanManagerProvider(this);
+ // CDI#current delegation enabled, skip everything
+ if (CDI_CURRENT_METHOD != null && CDI_CURRENT_BEAN_MANAGER_METHOD !=
null)
+ {
+ return;
+ }
+
BeanManagerInfo bmi =
getBeanManagerInfo(ClassUtils.getClassLoader(null));
bmi.loadTimeBm = beanManager;
}
@@ -194,6 +205,12 @@ public class BeanManagerProvider implements Extension
*/
public BeanManager getBeanManager()
{
+ // CDI#current delegation enabled, skip everything
+ if (CDI_CURRENT_METHOD != null && CDI_CURRENT_BEAN_MANAGER_METHOD !=
null)
+ {
+ return resolveBeanManagerViaStaticHelper();
+ }
+
BeanManagerInfo bmi =
getBeanManagerInfo(ClassUtils.getClassLoader(null));
if (!bmi.booted)
@@ -223,14 +240,6 @@ public class BeanManagerProvider implements Extension
// first we look for a BeanManager from JNDI
result = resolveBeanManagerViaJndi();
- // needs to be here to get a better performance and
- // even in ee7 containers we can't rely on that lookup as
a primary strategy
- // (esp. in case of EAR based applications)
- if (result == null)
- {
- result = resolveBeanManagerViaStaticHelper();
- }
-
if (result == null)
{
// if none found, we take the one we got from the
Extension loading
@@ -264,6 +273,12 @@ public class BeanManagerProvider implements Extension
*/
public void cleanupFinalBeanManagers(@Observes AfterDeploymentValidation
adv)
{
+ // CDI#current delegation enabled, skip everything
+ if (CDI_CURRENT_METHOD != null && CDI_CURRENT_BEAN_MANAGER_METHOD !=
null)
+ {
+ return;
+ }
+
for (BeanManagerInfo bmi : bmpSingleton.bmInfos.values())
{
bmi.finalBm = null;
@@ -283,6 +298,12 @@ public class BeanManagerProvider implements Extension
*/
public void cleanupStoredBeanManagerOnShutdown(@Observes BeforeShutdown
beforeShutdown)
{
+ // CDI#current delegation enabled, skip everything
+ if (CDI_CURRENT_METHOD != null && CDI_CURRENT_BEAN_MANAGER_METHOD !=
null)
+ {
+ return;
+ }
+
if (bmpSingleton == null)
{
// this happens if there has been a failure at startup