[jboss-svn-commits] JBL Code SVN: r30511 - in labs/jbossesb/branches/JBESB_4_7_CP: qa/junit/src/org/jboss/soa/esb/server and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Dec 7 10:42:50 EST 2009


Author: kevin.conner at jboss.com
Date: 2009-12-07 10:42:49 -0500 (Mon, 07 Dec 2009)
New Revision: 30511

Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/jca/EndpointProxy.java
   labs/jbossesb/branches/JBESB_4_7_CP/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java
Log:
Handle different JCA invocation path: JBESB-3001

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/jca/EndpointProxy.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/jca/EndpointProxy.java	2009-12-07 14:07:46 UTC (rev 30510)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/soa/esb/listeners/jca/EndpointProxy.java	2009-12-07 15:42:49 UTC (rev 30511)
@@ -70,6 +70,11 @@
     * The old classloader of the thread
     */
    protected ClassLoader oldClassLoader = null;
+   
+   /**
+    * The flag indicating that beforeDelivery was invoked.
+    */
+   protected boolean beforeDeliveryInvoked ;
 
    /**
     * Any transaction we started
@@ -156,7 +161,7 @@
          log.trace("MessageEndpoint " + getProxyString(proxy) + " released");
 
       // Tidyup any outstanding delivery
-      if (oldClassLoader != null)
+      if (beforeDeliveryInvoked)
       {
          try
          {
@@ -172,8 +177,9 @@
    protected void before(Object proxy, Method method, Object[] args) throws Throwable
    {
       // Called out of sequence
-      if (oldClassLoader != null)
+      if (beforeDeliveryInvoked)
          throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(proxy));
+      beforeDeliveryInvoked = true ;
 
       if (trace)
          log.trace("MessageEndpoint " + getProxyString(proxy) + " released");
@@ -203,8 +209,9 @@
    protected void after(Object proxy) throws Throwable
    {
       // Called out of sequence
-      if (oldClassLoader == null)
+      if (!beforeDeliveryInvoked)
          throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(proxy));
+      beforeDeliveryInvoked = false ;
 
       // Finish this delivery committing if we can
       try
@@ -226,15 +233,24 @@
       if (trace)
          log.trace("MessageEndpoint " + getProxyString(proxy) + " delivering");
 
+      final Thread currentThread = Thread.currentThread() ;
+      final ClassLoader contextClassLoader = currentThread.getContextClassLoader() ;
+
       // Mark delivery if beforeDelivery was invoked
-      if (oldClassLoader != null)
+      if (beforeDeliveryInvoked)
+      {
          delivered = true;
+      }
+      else
+      {
+         currentThread.setContextClassLoader(loader) ;
+      }
 
       boolean commit = true;
       try
       {
          // Check for starting a transaction
-         if (oldClassLoader == null)
+         if (!beforeDeliveryInvoked)
          {
             boolean isTransacted = messageEndpointFactory.isDeliveryTransacted(method);
             startTransaction("delivery", proxy, method, args, isTransacted);
@@ -256,8 +272,9 @@
       finally
       {
          // No before/after delivery, end any transaction and release the lock
-         if (oldClassLoader == null)
+         if (!beforeDeliveryInvoked)
          {
+            currentThread.setContextClassLoader(contextClassLoader) ;
             try
             {
                // Finish any transaction we started

Modified: labs/jbossesb/branches/JBESB_4_7_CP/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java	2009-12-07 14:07:46 UTC (rev 30510)
+++ labs/jbossesb/branches/JBESB_4_7_CP/qa/junit/src/org/jboss/soa/esb/server/MyRedeliveryAction.java	2009-12-07 15:42:49 UTC (rev 30511)
@@ -30,6 +30,7 @@
 import org.jboss.soa.esb.actions.ActionPipelineProcessor;
 import org.jboss.soa.esb.actions.ActionProcessingException;
 import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.lifecycle.LifecycleResourceManager;
 import org.jboss.soa.esb.message.Message;
 
 /**
@@ -52,7 +53,14 @@
         System.out.println("Body: " + incomingMessage) ;
         System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
         
-        getRedeliveryMBean().logMessage(incomingMessage);
+        if (LifecycleResourceManager.DEFAULT_IDENTITY.equals(LifecycleResourceManager.getSingleton().getIdentity()))
+        {
+            getRedeliveryMBean().logMessage("Default lifecycle identity used by JCA");
+        }
+        else
+        {
+            getRedeliveryMBean().logMessage(incomingMessage);
+        }
         // Throw an error every second message
         if ((count++ & 1) == 0)
         {



More information about the jboss-svn-commits mailing list