[jboss-cvs] JBossAS SVN: r82768 - in projects/ejb3/trunk/common/src: main/java/org/jboss/ejb3/common/proxy/spi and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 12 07:48:48 EST 2009


Author: wolfc
Date: 2009-01-12 07:48:47 -0500 (Mon, 12 Jan 2009)
New Revision: 82768

Added:
   projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/MultiMethod.java
Modified:
   projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/plugins/async/AsyncProcessor.java
   projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/spi/ChainedProcessingInvocationHandler.java
   projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/unit/AsyncTestCase.java
Log:
EJBTHREE-1681: resetting the ChainedProcessingInvocationHandler a bit more

Modified: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/plugins/async/AsyncProcessor.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/plugins/async/AsyncProcessor.java	2009-01-12 12:23:21 UTC (rev 82767)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/plugins/async/AsyncProcessor.java	2009-01-12 12:48:47 UTC (rev 82768)
@@ -78,6 +78,9 @@
       // Are we trying to get the future result?
       if (this.isGetFutureResultInvocation(method))
       {
+         // FIXME: stop-gap solution. We have a return value, stop moving forward.
+         chain.reset();
+         
          // Return the future result
          return this.getFutureResult();
       }

Modified: projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/spi/ChainedProcessingInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/spi/ChainedProcessingInvocationHandler.java	2009-01-12 12:23:21 UTC (rev 82767)
+++ projects/ejb3/trunk/common/src/main/java/org/jboss/ejb3/common/proxy/spi/ChainedProcessingInvocationHandler.java	2009-01-12 12:48:47 UTC (rev 82768)
@@ -117,7 +117,10 @@
       else
       {
          // Invoke upon the next handler in the chain
-         returnValue = this.getHandlerChain()[this.nextHandlerIndex++].invoke(this, proxy, method, args);
+         // FIXME: This is just a stop-gap solution for the broken ChainedProcessingInvocationHandler construct
+         int currentHandlerIndex = this.nextHandlerIndex;
+         this.nextHandlerIndex++;
+         returnValue = this.getHandlerChain()[currentHandlerIndex].invoke(this, proxy, method, args);
       }
 
       // Return

Added: projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/MultiMethod.java
===================================================================
--- projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/MultiMethod.java	                        (rev 0)
+++ projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/MultiMethod.java	2009-01-12 12:48:47 UTC (rev 82768)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.common.proxy;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MultiMethod
+{
+   String method1(int i);
+   
+   String method2(int i);
+}

Modified: projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/unit/AsyncTestCase.java
===================================================================
--- projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/unit/AsyncTestCase.java	2009-01-12 12:23:21 UTC (rev 82767)
+++ projects/ejb3/trunk/common/src/test/java/org/jboss/ejb3/test/common/proxy/unit/AsyncTestCase.java	2009-01-12 12:48:47 UTC (rev 82768)
@@ -32,6 +32,7 @@
 import org.jboss.ejb3.common.proxy.plugins.async.AsyncUtils;
 import org.jboss.ejb3.test.common.proxy.Addable;
 import org.jboss.ejb3.test.common.proxy.CalculatorServiceBean;
+import org.jboss.ejb3.test.common.proxy.MultiMethod;
 import org.jboss.logging.Logger;
 import org.junit.Test;
 
@@ -116,6 +117,45 @@
       }
    }
    
+   @Test
+   public void testMultiMethod() throws Exception
+   {
+      MultiMethod bean = new MultiMethod() {
+         public String method1(int i)
+         {
+            return "1:" + i;
+         }
+
+         public String method2(int i)
+         {
+            return "2:" + i;
+         }
+      };
+      
+      MultiMethod asyncBean = AsyncUtils.mixinAsync(bean);
+      
+      {
+         asyncBean.method1(3);
+         
+         Future<?> futureResult = AsyncUtils.getFutureResult(asyncBean);
+         
+         String actual = (String) futureResult.get(2, TimeUnit.SECONDS);
+         
+         assertEquals("1:3", actual);
+      }
+      
+      // invoke another async method on the same reference
+      {
+         asyncBean.method2(4);
+         
+         Future<?> futureResult = AsyncUtils.getFutureResult(asyncBean);
+         
+         String actual = (String) futureResult.get(2, TimeUnit.SECONDS);
+         
+         assertEquals("2:4", actual);
+      }
+   }
+   
    // --------------------------------------------------------------------------------||
    // Internal Helper Methods --------------------------------------------------------||
    // --------------------------------------------------------------------------------||




More information about the jboss-cvs-commits mailing list