[weld-commits] Weld SVN: r4215 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 6 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Oct 21 12:17:44 EDT 2009


Author: marius.bogoevici
Date: 2009-10-21 12:17:44 -0400 (Wed, 21 Oct 2009)
New Revision: 4215

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java
Modified:
   core/trunk/bom/pom.xml
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java
   core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml
   core/trunk/tests/unit-tests.xml
Log:
Fix detection and handling of AroundTimeout.

Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/bom/pom.xml	2009-10-21 16:17:44 UTC (rev 4215)
@@ -76,7 +76,7 @@
       <javassist.version>3.11.0.GA</javassist.version>
       <cdi.tck.version>1.0.0-SNAPSHOT</cdi.tck.version>
       <atinject.tck.version>1.0.0-PFD-3</atinject.tck.version>
-      <jboss.interceptor.version>1.0.0-CR3</jboss.interceptor.version>
+      <jboss.interceptor.version>1.0.0-SNAPSHOT</jboss.interceptor.version>
       <slf4j.version>1.5.8</slf4j.version>
    </properties>
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -46,6 +46,7 @@
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.DefinitionException;
 import org.jboss.weld.DeploymentException;
+import org.jboss.weld.ejb.EJBApiAbstraction;
 import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.context.SerializableContextual;
@@ -432,7 +433,7 @@
             builder.interceptPostActivate().with(toSerializableContextualArray(resolvedPostActivateInterceptors));
 
          }
-         List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableBusinessMethods(getAnnotatedItem());
+         List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableMethods(getAnnotatedItem());
          for (WeldMethod<?, ?> method : businessMethods)
          {
             Set<Annotation> methodBindingAnnotations = new HashSet<Annotation>(classBindingAnnotations);
@@ -441,8 +442,17 @@
             {
                if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
                   throw new DeploymentException("Conflicting interceptor bindings found on " + getType() + "." + method.getName() + "()");
-               List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
-               builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+               
+               if (method.isAnnotationPresent(manager.getServices().get(EJBApiAbstraction.class).TIMEOUT_ANNOTATION_CLASS))
+               {
+                  List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_TIMEOUT, methodBindingAnnotations.toArray(new Annotation[]{}));
+                  builder.interceptAroundTimeout(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+               }
+               else
+               {
+                  List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
+                  builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+               }
             }
          }
          InterceptionModel<Class<?>,SerializableContextual<Interceptor<?>,?>> serializableContextualInterceptionModel = builder.build();
@@ -547,7 +557,7 @@
             builder.interceptAll().with(classDeclaredInterceptors);
          }
 
-         List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableBusinessMethods(getAnnotatedItem());
+         List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableMethods(getAnnotatedItem());
          for (WeldMethod<?, ?> method : businessMethods)
          {
             boolean excludeClassInterceptors = method.isAnnotationPresent(InterceptionUtils.getExcludeClassInterceptorsAnnotationClass());
@@ -562,7 +572,10 @@
             }
             if (methodDeclaredInterceptors != null)
             {
-               builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(methodDeclaredInterceptors);
+               if (method.isAnnotationPresent(manager.getServices().get(EJBApiAbstraction.class).TIMEOUT_ANNOTATION_CLASS))
+                  builder.interceptAroundTimeout(((AnnotatedMethod) method).getJavaMember()).with(methodDeclaredInterceptors);
+               else
+                  builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(methodDeclaredInterceptors);
             }
          }
          InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();

Modified: core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -36,12 +36,14 @@
       ENTERPRISE_BEAN_CLASS = classForName("javax.ejb.EnterpriseBean");
       EJB_ANNOTATION_CLASS = annotationTypeForName("javax.ejb.EJB");
       RESOURCE_ANNOTATION_CLASS = annotationTypeForName("javax.annotation.Resource");
-
+      TIMEOUT_ANNOTATION_CLASS = annotationTypeForName("javax.ejb.Timeout");
    }
 
    public final Class<?> ENTERPRISE_BEAN_CLASS;
    public final Class<? extends Annotation> EJB_ANNOTATION_CLASS;
    public final Class<? extends Annotation> RESOURCE_ANNOTATION_CLASS;
+   public final Class<? extends Annotation> TIMEOUT_ANNOTATION_CLASS;
+
    
    public void cleanup() {}
    

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -224,7 +224,7 @@
       }
    }
 
-   public static List<WeldMethod<?,?>> getInterceptableBusinessMethods(WeldClass<?> type)
+   public static List<WeldMethod<?,?>> getInterceptableMethods(WeldClass<?> type)
    {
       List<WeldMethod<?, ?>> annotatedMethods = new ArrayList<WeldMethod<?, ?>>();
       for (WeldMethod<?, ?> annotatedMethod : type.getWeldMethods())

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -18,11 +18,12 @@
 package org.jboss.weld.test.unit.interceptor.ejb;
 
 import javax.ejb.Stateless;
+import javax.ejb.Timeout;
 
 /**
  * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
- at Stateless
+ at Stateless  @TimeBound
 public class BallImpl implements Ball
 {
    @Shot
@@ -34,4 +35,10 @@
    public void pass()
    {
    }
+
+   @Timeout
+   public void finishGame()
+   {
+
+   }
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -32,18 +32,25 @@
       List<javax.enterprise.inject.spi.Interceptor> interceptors =
             new ArrayList<javax.enterprise.inject.spi.Interceptor>(interceptorBindings.getAllInterceptors());
 
-      assert interceptors.size() == 2;
-      List<Class<?>> expectedInterceptors = Arrays.<Class<?>>asList(Goalkeeper.class, Defender.class);
+      assert interceptors.size() == 3;
+      List<Class<?>> expectedInterceptors = Arrays.<Class<?>>asList(Goalkeeper.class, Defender.class, Referee.class);
       assert expectedInterceptors.contains(interceptors.get(0).getBeanClass());
       assert expectedInterceptors.contains(interceptors.get(1).getBeanClass());
+      assert expectedInterceptors.contains(interceptors.get(2).getBeanClass());
 
 
+      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("shoot")).size() == 0;
       assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).size() == 1;
       assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass().equals(Goalkeeper.class);
       
+      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("pass")).size() == 0;
       assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).size() == 1;
       assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass().equals(Defender.class);
 
+      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("finishGame")).size() == 0;
+      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("finishGame")).size() == 1;
+      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("finishGame")).get(0).getBeanClass().equals(Referee.class);
+
    }
 
 }

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.interceptor.ejb;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundTimeout;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Interceptor @TimeBound
+public class Referee
+{
+   public static boolean ballCollected = false;
+
+   @AroundTimeout
+   public Object collectBall(InvocationContext context) throws Exception
+   {
+      ballCollected = true;
+      return context.proceed();
+   }
+}

Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java (from rev 4209, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Shot.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.test.unit.interceptor.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at InterceptorBinding
+ at Retention(RUNTIME)
+ at Target({ElementType.METHOD, ElementType.TYPE})
+ at Documented
+public @interface TimeBound
+{
+}
\ No newline at end of file


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -25,7 +25,7 @@
 /**
  * @author Marius Bogoevici
  */
- at Interceptors(Goalkeeper.class)
+ at Interceptors({Goalkeeper.class, Referee.class})
 public class Ball
 {
    public static boolean played = false;

Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java	2009-10-21 16:17:44 UTC (rev 4215)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.interceptor.ejb3model;
+
+import org.jboss.weld.test.unit.interceptor.ejb.TimeBound;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundTimeout;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Interceptor @TimeBound
+public class Referee
+{
+   public static boolean ballCollected = false;
+
+   @AroundTimeout
+   public Object collectBall(InvocationContext context) throws Exception
+   {
+      ballCollected = true;
+      return context.proceed();
+   }
+}
\ No newline at end of file

Modified: core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml	2009-10-21 16:17:44 UTC (rev 4215)
@@ -2,5 +2,6 @@
   <interceptors>
     <class>org.jboss.weld.test.unit.interceptor.ejb.Goalkeeper</class>
     <class>org.jboss.weld.test.unit.interceptor.ejb.Defender</class>
+    <class>org.jboss.weld.test.unit.interceptor.ejb.Referee</class>
   </interceptors>
 </beans>

Modified: core/trunk/tests/unit-tests.xml
===================================================================
--- core/trunk/tests/unit-tests.xml	2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/unit-tests.xml	2009-10-21 16:17:44 UTC (rev 4215)
@@ -52,6 +52,10 @@
          <package name="org.jboss.weld.test.unit.implementation.producer.method" />
          <package name="org.jboss.weld.test.unit.implementation.proxy" />
          <package name="org.jboss.weld.test.unit.implementation.proxy.enterprise" />
+         <package name="org.jboss.weld.test.unit.interceptor.ejb" />
+         <package name="org.jboss.weld.test.unit.interceptor.ejb3model" />
+         <package name="org.jboss.weld.test.unit.interceptor.passivation" />
+         <package name="org.jboss.weld.test.unit.interceptor.simple" />
          <package name="org.jboss.weld.test.unit.lookup" />
          <package name="org.jboss.weld.test.unit.lookup.circular" />
          <package name="org.jboss.weld.test.unit.lookup.wbri279" />



More information about the weld-commits mailing list