tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: fixing CleanUpAssembler in case of multiple apps + handling @AroundTimeout for cdi interceptors
Date Fri, 06 Mar 2015 17:09:36 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop 37b5756e6 -> 3e40a2fee


fixing CleanUpAssembler in case of multiple apps + handling @AroundTimeout for cdi interceptors


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

Branch: refs/heads/develop
Commit: 3e40a2fee8139d5c4234cc4c1150ba946d61c34a
Parents: 37b5756
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Fri Mar 6 18:09:26 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Fri Mar 6 18:09:26 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/openejb/BeanContext.java    | 28 ++++++++++++++++++++
 .../tck/cdi/embedded/CleanUpAssembler.java      |  6 ++++-
 tck/cdi-embedded/src/test/resources/failing.xml |  6 +----
 3 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3e40a2fe/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java b/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
index d21b20f..1535f5e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/BeanContext.java
@@ -44,6 +44,7 @@ import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.proxy.DynamicProxyImplFactory;
 import org.apache.openejb.util.proxy.LocalBeanProxyFactory;
 import org.apache.openejb.util.reflection.Reflections;
+import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.component.CdiInterceptorBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.WebBeansContext;
@@ -53,6 +54,7 @@ import org.apache.webbeans.intercept.DecoratorHandler;
 import org.apache.webbeans.intercept.InterceptorResolutionService;
 import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
+import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.xbean.recipe.ConstructionException;
 
 import javax.ejb.ApplicationException;
@@ -70,6 +72,8 @@ import javax.ejb.TimedObject;
 import javax.ejb.Timer;
 import javax.enterprise.context.ConversationScoped;
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
@@ -187,6 +191,30 @@ public class BeanContext extends DeploymentContext {
         clear(Collection.class.cast(Reflections.get(injectionTarget, "preDestroyMethods")));
         clear(Collection.class.cast(Reflections.get(info, "ejbInterceptors")));
         clear(Collection.class.cast(Reflections.get(info, "cdiInterceptors")));
+
+        // OWB doesn't compute AROUND_INVOKE so let's do it
+        final Method timeout = getEjbTimeout();
+        if (timeout != null) {
+            final AnnotatedType annotatedType = cdiEjbBean.getAnnotatedType();
+            final AnnotationManager annotationManager = getWebBeansContext().getAnnotationManager();
+            final Collection<Annotation> annotations = new HashSet<>();
+            annotations.addAll(annotationManager.getInterceptorAnnotations(annotatedType.getAnnotations()));
+            final Set<AnnotatedMethod<?>> methods = annotatedType.getMethods();
+            for (final AnnotatedMethod<?> m : methods) {
+                if (timeout.equals(m.getJavaMember())) {
+                    annotations.addAll(annotationManager.getInterceptorAnnotations(m.getAnnotations()));
+                    break;
+                }
+            }
+            for (final Interceptor<?> timeoutInterceptor : getWebBeansContext().getBeanManagerImpl()
+                    .resolveInterceptors(InterceptionType.AROUND_TIMEOUT, AnnotationUtil.asArray(annotations)))
{
+                if (isEjbInterceptor(timeoutInterceptor)) {
+                    continue;
+                }
+                final InterceptorData data = createInterceptorData(timeoutInterceptor);
+                addCdiMethodInterceptor(timeout, data);
+            }
+        }
     }
 
     private boolean isEjbInterceptor(final Interceptor<?> pc) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/3e40a2fe/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
index 1db29af..c31bd36 100644
--- a/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
+++ b/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/CleanUpAssembler.java
@@ -19,12 +19,16 @@ package org.apache.openejb.tck.cdi.embedded;
 import org.apache.openejb.UndeployException;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
 import org.jboss.cdi.tck.util.ActionSequence;
 
 public class CleanUpAssembler extends Assembler {
     @Override
     public void destroyApplication(final AppInfo appInfo) throws UndeployException {
         super.destroyApplication(appInfo);
-        ActionSequence.reset();
+        if (SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts().isEmpty())
{
+            ActionSequence.reset();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/3e40a2fe/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index 4d6b027..29c6d9b 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -31,11 +31,7 @@
     -Dopenejb.embedded.try-jsp=true
     -->
     <classes>
-      <!--
-      org.jboss.cdi.tck.interceptors.tests.contract.aroundTimeout.bindings.AroundTimeoutOrderInterceptorTest
-      org.jboss.cdi.tck.tests.extensions.lifecycle.processInjectionTarget.ContainerEventTest
-      -->
-      <class name="org.jboss.cdi.tck.tests.deployment.discovery.BeanDiscoveryTest" />
+      <class name="org.jboss.cdi.tck.interceptors.tests.contract.aroundTimeout.bindings.AroundTimeoutOrderInterceptorTest"
/>
     </classes>
   </test>
 </suite>


Mime
View raw message