[jboss-cvs] JBossAS SVN: r96307 - in projects/ejb3/trunk/interceptors: src/main/java/org/jboss/ejb3/interceptors/container and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 12 09:01:15 EST 2009


Author: wolfc
Date: 2009-11-12 09:01:14 -0500 (Thu, 12 Nov 2009)
New Revision: 96307

Added:
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HandelseInterceptor.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/Hobby.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasad.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasadBean.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/SparloggHandelse.java
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/unit/
   projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/unit/AdvisedBeanTestCase.java
   projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1950/
   projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1950/jboss-aop.xml
Modified:
   projects/ejb3/trunk/interceptors/pom.xml
   projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ContainerMethodInvocation.java
Log:
EJBTHREE-1950: make container invocation invoke the raw method instead of the generated method

Modified: projects/ejb3/trunk/interceptors/pom.xml
===================================================================
--- projects/ejb3/trunk/interceptors/pom.xml	2009-11-12 13:57:15 UTC (rev 96306)
+++ projects/ejb3/trunk/interceptors/pom.xml	2009-11-12 14:01:14 UTC (rev 96307)
@@ -22,6 +22,38 @@
   <build>
     <plugins>
       <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>aopc</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <property name="cp" refid="maven.test.classpath"/>
+                
+                <echo message="aopc in action"/>
+                
+                <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpath="${cp}"/>
+                
+                <aopc compilerclasspath="${cp}" verbose="true">
+                  <aoppath path="${basedir}/src/test/resources/ejbthree1950/jboss-aop.xml"/>
+                  <!--
+                  <classpath path="${project.build.directory}/tests-classes"/>
+                  <src path="${project.build.directory}/tests-classes"/>
+                  -->
+                  <classpath path="${project.build.testOutputDirectory}"/>
+                  <src path="${project.build.testOutputDirectory}"/>
+                  <include name="**/*FasadBean.class"/>
+                </aopc>
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>

Modified: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ContainerMethodInvocation.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ContainerMethodInvocation.java	2009-11-12 13:57:15 UTC (rev 96306)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/container/ContainerMethodInvocation.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -83,6 +83,17 @@
       super(newchain);
    }
 
+   /**
+    * Because ContainerMethodInvocation are virtual invocation the actual
+    * method is the advised method. This allows beans which are really advised to
+    * properly execute through their interceptors (EJBTHREE-1950).
+    */
+   @Override
+   public Method getActualMethod()
+   {
+      return getMethod();
+   }
+   
    public BeanContext<?> getBeanContext()
    {
       return beanContext;

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HandelseInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HandelseInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HandelseInterceptor.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1950;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class HandelseInterceptor implements Interceptor
+{
+   private static final Logger log = Logger.getLogger(HandelseInterceptor.class);
+   
+   public String getName()
+   {
+      return "SLK";
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      // Bortsett från avverkning vi också lemlästa resultatet
+      log.info("invoke");
+      Hobby hobby = (Hobby) invocation.invokeNext();
+      hobby.setBeskrivning(hobby.getBeskrivning() + " avlyssnas");
+      return hobby;
+   }
+}

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/Hobby.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/Hobby.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/Hobby.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1950;
+
+import java.io.Serializable;
+
+/**
+ * Ett falskt enhet Bean.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Hobby implements Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   private Long id;
+   private String namn;
+   private String beskrivning;
+   
+   public String getBeskrivning()
+   {
+      return beskrivning;
+   }
+   
+   public void setBeskrivning(String beskrivning)
+   {
+      this.beskrivning = beskrivning;
+   }
+   
+   public Long getId()
+   {
+      return id;
+   }
+   
+   public void setId(Long id)
+   {
+      this.id = id;
+   }
+   
+   public String getNamn()
+   {
+      return namn;
+   }
+   
+   public void setNamn(String namn)
+   {
+      this.namn = namn;
+   }
+   
+   @Override
+   public String toString()
+   {
+      return super.toString() + "{id=" + id + ",namn=" + namn + "}";
+   }
+}

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasad.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasad.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasad.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1950;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface HobbyFasad
+{
+   Hobby skapaHobby1(String namn, String beskrivning);
+   Hobby skapaHobby2(String namn, String beskrivning);
+}

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasadBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasadBean.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/HobbyFasadBean.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1950;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class HobbyFasadBean implements HobbyFasad
+{
+   private static long id = 0;
+   
+   @SparloggHandelse
+   public Hobby skapaHobby1(String namn, String beskrivning)
+   {
+      Hobby hobby = new Hobby();
+      hobby.setId(id++);
+      hobby.setNamn(namn);
+      hobby.setBeskrivning(beskrivning);
+      return hobby;
+   }
+
+   public Hobby skapaHobby2(String namn, String beskrivning)
+   {
+      // I en riktig böna inte gör detta, använd getBusinessObject
+      return skapaHobby1(namn, beskrivning);
+   }
+}

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/SparloggHandelse.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/SparloggHandelse.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/SparloggHandelse.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1950;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Retention(RUNTIME)
+public @interface SparloggHandelse {
+
+}

Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/unit/AdvisedBeanTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/unit/AdvisedBeanTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1950/unit/AdvisedBeanTestCase.java	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1950.unit;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.aspects.common.AOPDeployer;
+import org.jboss.ejb3.interceptors.proxy.ProxyContainer;
+import org.jboss.ejb3.interceptors.test.ejbthree1950.Hobby;
+import org.jboss.ejb3.interceptors.test.ejbthree1950.HobbyFasad;
+import org.jboss.ejb3.interceptors.test.ejbthree1950.HobbyFasadBean;
+import org.jboss.logging.Logger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * What if the bean class is already advised via aopc?
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AdvisedBeanTestCase
+{
+   private static final Logger log = Logger.getLogger(AdvisedBeanTestCase.class);
+   
+   private static AOPDeployer deployer1 = new AOPDeployer("proxy/jboss-aop.xml");
+   private static AOPDeployer deployer2 = new AOPDeployer("ejbthree1950/jboss-aop.xml");
+   
+   @AfterClass
+   public static void afterClass()
+   {
+      log.info(deployer2.undeploy());
+      log.info(deployer1.undeploy());
+   }
+   
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      log.info(deployer1.deploy());
+      log.info(deployer2.deploy());
+   }
+   
+   @Test
+   public void testContainerInvocation() throws Throwable
+   {
+      ProxyContainer<HobbyFasadBean> container = new ProxyContainer<HobbyFasadBean>("AdvisedBeanTestCase", "InterceptorContainer", HobbyFasadBean.class);
+      Class<?> interfaces[] = { HobbyFasad.class };
+      HobbyFasad bean = container.constructProxy(interfaces);
+      String name = "testContainerInvocation";
+      String description = "Invocation via a proxy container";
+      Hobby result = bean.skapaHobby1(name, description);
+      assertEquals(description + " avlyssnas", result.getBeskrivning());
+   }
+   
+   @Test
+   public void testContainerInvocation2() throws Throwable
+   {
+      ProxyContainer<HobbyFasadBean> container = new ProxyContainer<HobbyFasadBean>("AdvisedBeanTestCase", "InterceptorContainer", HobbyFasadBean.class);
+      Class<?> interfaces[] = { HobbyFasad.class };
+      HobbyFasad bean = container.constructProxy(interfaces);
+      String name = "testContainerInvocation";
+      String description = "Invocation via a proxy container";
+      Hobby result = bean.skapaHobby2(name, description);
+      assertEquals(description + " avlyssnas", result.getBeskrivning());
+   }
+   
+   @Test
+   public void testNormalInvocation()
+   {
+      HobbyFasad bean = new HobbyFasadBean();
+      String name = "testNormalInvocation";
+      String description = "Normal invocation test";
+      Hobby result = bean.skapaHobby1(name, description);
+      assertEquals(description + " avlyssnas", result.getBeskrivning());
+   }
+}

Added: projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1950/jboss-aop.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1950/jboss-aop.xml	                        (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1950/jboss-aop.xml	2009-11-12 14:01:14 UTC (rev 96307)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop xmlns="urn:jboss:aop-beans:1.0">
+   <interceptor name="SLK" class="org.jboss.ejb3.interceptors.test.ejbthree1950.HandelseInterceptor" />
+
+   <bind pointcut="all(@org.jboss.ejb3.interceptors.test.ejbthree1950.SparloggHandelse)">
+      <interceptor-ref name="SLK" />
+   </bind>
+</aop>




More information about the jboss-cvs-commits mailing list