tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: better handling of creational contexts for web components
Date Mon, 02 Nov 2015 18:22:23 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 59e366a86 -> 3035c8360


better handling of creational contexts for web components


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3035c836
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3035c836
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3035c836

Branch: refs/heads/master
Commit: 3035c83604755cacf8073d6cbcbd0992bd6ddcf9
Parents: 59e366a
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Mon Nov 2 10:22:16 2015 -0800
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Mon Nov 2 10:22:16 2015 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/openejb/core/WebContext.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3035c836/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
index 55d98c1..073be91 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
@@ -25,7 +25,6 @@ import org.apache.openejb.cdi.ConstructorInjectionBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.WebBeansContext;
 
-import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.naming.Context;
@@ -132,7 +131,7 @@ public class WebContext {
     public <T> Instance newWeakableInstance(final Class<T> beanClass) throws
OpenEJBException {
         final WebBeansContext webBeansContext = getWebBeansContext();
         final ConstructorInjectionBean<Object> beanDefinition = getConstructorInjectionBean(beanClass,
webBeansContext);
-        final CreationalContext<Object> creationalContext;
+        CreationalContext<Object> creationalContext;
         final Object o;
         if (webBeansContext == null) {
             creationalContext = null;
@@ -155,6 +154,9 @@ public class WebContext {
         if (webBeansContext != null) {
             final InjectionTargetBean<Object> bean = InjectionTargetBean.class.cast(beanDefinition);
             bean.getInjectionTarget().inject(beanInstance, creationalContext);
+            if (shouldBeReleased(bean.getScope())) {
+                creationalContexts.put(beanInstance, creationalContext);
+            }
         }
         return new Instance(beanInstance, creationalContext);
     }
@@ -229,9 +231,7 @@ public class WebContext {
                 final InjectionTargetBean<Object> bean = InjectionTargetBean.class.cast(beanDefinition);
                 bean.getInjectionTarget().inject(beanInstance, creationalContext);
 
-                // if the bean is dependent simply cleanup the creational context once it
is created
-                final Class<? extends Annotation> scope = beanDefinition.getScope();
-                if (scope == null || Dependent.class.equals(scope)) {
+                if (shouldBeReleased(beanDefinition.getScope())) {
                     creationalContexts.put(beanInstance, creationalContext);
                 }
             }
@@ -242,6 +242,10 @@ public class WebContext {
         }
     }
 
+    private boolean shouldBeReleased(final Class<? extends Annotation> scope) {
+        return scope == null || !getWebBeansContext().getBeanManagerImpl().isNormalScope(scope);
+    }
+
     public void setBindings(final Map<String, Object> bindings) {
         this.bindings = bindings;
     }


Mime
View raw message