cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r761762 - in /cxf/branches/2.1.x-fixes: ./ integration/jca/src/main/java/org/apache/cxf/jca/inbound/
Date Fri, 03 Apr 2009 19:05:11 GMT
Author: dkulp
Date: Fri Apr  3 19:05:11 2009
New Revision: 761762

URL: http://svn.apache.org/viewvc?rev=761762&view=rev
Log:
Merged revisions 761759 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r761759 | dkulp | 2009-04-03 14:57:29 -0400 (Fri, 03 Apr 2009) | 2 lines
  
  [CXF-2145] JCA proxy concurrency issue patch from Seumas Soltysik and William Tam applied.
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/DispatchMDBInvoker.java
    cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
    cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
    cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBInvoker.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr  3 19:05:11 2009
@@ -1 +1 @@
-/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938
+/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761759

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/DispatchMDBInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/DispatchMDBInvoker.java?rev=761762&r1=761761&r2=761762&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/DispatchMDBInvoker.java
(original)
+++ cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/DispatchMDBInvoker.java
Fri Apr  3 19:05:11 2009
@@ -22,6 +22,7 @@
 import java.util.logging.Logger;
 
 import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.message.Exchange;
@@ -45,23 +46,36 @@
     /**
      * @param messageEndpoint
      */
-    public DispatchMDBInvoker(MessageEndpoint messageEndpoint, String targetJndiName) {
-        super(messageEndpoint);
+    public DispatchMDBInvoker(MessageEndpointFactory factory, String targetJndiName) {
+        super(factory);
         this.targetJndiName = targetJndiName;
     }
     
     @Override
     public Object getServiceObject(Exchange context) {
         Object target = null;
+        MessageEndpoint ep = getMessageEndpoint();
+
+        if (ep == null) {
+            LOG.log(Level.SEVERE, "Failed to obtain MessageEndpoint");
+            return null;
+        }
+        
         try {
-            target = ((DispatchMDBMessageListener)getMessageEndpoint())
+            target = ((DispatchMDBMessageListener)ep)
                 .lookupTargetObject(targetJndiName);
         } catch (Exception e) {
             LOG.log(Level.SEVERE, "Failed to obtain service object " + targetJndiName, e);
             return null;
+        } finally {
+            releaseEndpoint(ep);
         }
         
         return target;
     }
 
+    public void releaseServiceObject(final Exchange context, Object obj) {
+
+    }
+
 }

Modified: cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java?rev=761762&r1=761761&r2=761762&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
(original)
+++ cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/InboundEndpoint.java
Fri Apr  3 19:05:11 2009
@@ -83,10 +83,7 @@
      * @throws Exception
      */
     public void shutdown() throws Exception {
-        if (invoker != null) {
-            invoker.getMessageEndpoint().release();
-            invoker = null;
-        }
+        invoker = null;
         
         if (server != null) {
             server.stop();

Modified: cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java?rev=761762&r1=761761&r2=761762&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
(original)
+++ cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
Fri Apr  3 19:05:11 2009
@@ -25,7 +25,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.resource.spi.UnavailableException;
 import javax.resource.spi.endpoint.MessageEndpoint;
 import javax.resource.spi.endpoint.MessageEndpointFactory;
 import javax.resource.spi.work.Work;
@@ -52,12 +51,9 @@
 public class MDBActivationWork implements Work {
     
     private static final Logger LOG = LogUtils.getL7dLogger(MDBActivationWork.class);
-    private static final int MAX_ATTEMPTS = 5;
-    private static final long RETRY_SLEEP = 5000;
 
     private MDBActivationSpec spec;
     private MessageEndpointFactory endpointFactory;
-    private boolean released;
 
     private Map<String, InboundEndpoint> endpoints;
 
@@ -70,28 +66,31 @@
     }
 
     public void release() {
-        released = true;
+
     }
 
     /**
      * Performs the work
      */
     public void run() {
-        // get message driven bean proxy
-        MessageEndpoint endpoint = getMesssageEndpoint();
-        if (endpoint == null) {
-            // error has been logged.
-            return;
+        MDBInvoker invoker = createInvoker();
+        MessageEndpoint mep = invoker.getMessageEndpoint();
+        if (mep == null) {
+            return;            
         }
-    
-        // get class loader
-        ClassLoader classLoader = endpoint.getClass().getClassLoader();
-        ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();
+        
+        ClassLoader savedClassLoader = null;
+
         try {
+            savedClassLoader = Thread.currentThread().getContextClassLoader();
+            ClassLoader classLoader = mep.getClass().getClassLoader();
             Thread.currentThread().setContextClassLoader(classLoader);
-            activate(endpoint, classLoader);
+            activate(invoker, classLoader);
         } finally {
-            Thread.currentThread().setContextClassLoader(savedClassLoader);
+            invoker.releaseEndpoint(mep);
+            if (savedClassLoader != null) {
+                Thread.currentThread().setContextClassLoader(savedClassLoader);
+            }
         }
     }
     
@@ -99,7 +98,7 @@
      * @param endpoint
      * @param classLoader 
      */
-    private void activate(MessageEndpoint endpoint, ClassLoader classLoader) {
+    private void activate(MDBInvoker invoker, ClassLoader classLoader) {
         Class<?> serviceClass = null;
         if (spec.getServiceInterfaceClass() != null) {
             try {
@@ -128,7 +127,6 @@
             bus = BusFactory.getDefaultBus();
         }
 
-        MDBInvoker invoker = createInvoker(endpoint);
         Server server = createServer(bus, serviceClass, invoker);
         
         if (server == null) {
@@ -231,49 +229,15 @@
      * @param endpoint
      * @return
      */
-    private MDBInvoker createInvoker(MessageEndpoint endpoint) {
+    private MDBInvoker createInvoker() {
         MDBInvoker answer = null;
         if (spec instanceof DispatchMDBActivationSpec) {
-            answer = new DispatchMDBInvoker(endpoint, 
+            answer = new DispatchMDBInvoker(endpointFactory, 
                     ((DispatchMDBActivationSpec)spec).getTargetBeanJndiName());
         } else {
-            answer = new MDBInvoker(endpoint);
+            answer = new MDBInvoker(endpointFactory);
         }
         return answer;
     }
 
-    /**
-     * Invokes endpoint factory to create message endpoint (event driven bean).
-     * It will retry if the event driven bean is not yet available.
-     */
-    private MessageEndpoint getMesssageEndpoint() {
-        MessageEndpoint answer = null;
-        for (int i = 0; i < MAX_ATTEMPTS; i++) {
-            
-            if (released) {
-                LOG.warning("CXF service activation has been stopped.");
-                return null;
-            }
-            
-            try {
-                answer = endpointFactory.createEndpoint(null);
-                break;
-            } catch (UnavailableException e) {
-                LOG.fine("Target endpoint activation in progress.  Will retry.");
-                try {
-                    Thread.sleep(RETRY_SLEEP);
-                } catch (InterruptedException e1) {
-                    // ignore
-                }
-            }
-        }
-        
-        if (answer == null) {
-            LOG.severe("Failed to activate  service endpoint " 
-                    + spec.getDisplayName() 
-                    + " due to unable to endpoint listener.");
-        }
-        
-        return answer;
-    }
 }

Modified: cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBInvoker.java?rev=761762&r1=761761&r2=761762&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBInvoker.java
(original)
+++ cxf/branches/2.1.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBInvoker.java
Fri Apr  3 19:05:11 2009
@@ -18,8 +18,13 @@
  */
 package org.apache.cxf.jca.inbound;
 
+import java.util.logging.Logger;
+
+import javax.resource.spi.UnavailableException;
 import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.service.invoker.AbstractInvoker;
 
@@ -35,26 +40,62 @@
  * (SEI) class.
  */
 public class MDBInvoker extends AbstractInvoker {
-
-    private MessageEndpoint messageEndpoint;
+    private static final Logger LOG = LogUtils.getL7dLogger(MDBInvoker.class);
+    private static final int MAX_ATTEMPTS = 5;
+    private static final long RETRY_SLEEP = 2000;
+    
+    private final MessageEndpointFactory endpointFactory;
 
     /**
      * @param messageEndpoint
      */
-    public MDBInvoker(MessageEndpoint messageEndpoint) {
-        this.messageEndpoint = messageEndpoint;
+    public MDBInvoker(MessageEndpointFactory factory) {
+        endpointFactory = factory;
     }
 
     /**
      * @return the messageEndpoint
      */
     public MessageEndpoint getMessageEndpoint() {
-        return messageEndpoint;
+        return createMessageEndpoint();
+    }
+
+    protected void releaseEndpoint(MessageEndpoint mep) {
+        mep.release();
     }
 
     @Override
     public Object getServiceObject(Exchange context) {
-        return messageEndpoint;
+        return getMessageEndpoint();
+    }
+    
+    public void releaseServiceObject(final Exchange context, Object obj) {
+        if (obj instanceof MessageEndpoint) {
+            MessageEndpoint mep = (MessageEndpoint)obj;
+            releaseEndpoint(mep);
+        }
     }
 
+    /**
+     * Invokes endpoint factory to create message endpoint (event driven bean).
+     * It will retry if the event driven bean is not yet available.
+     */
+    private MessageEndpoint createMessageEndpoint() {
+        MessageEndpoint ep = null;
+        for (int i = 0; i < MAX_ATTEMPTS; i++) {
+            try {
+                ep = endpointFactory.createEndpoint(null);
+                break;
+            } catch (UnavailableException e) {
+                LOG.fine("Target endpoint activation in progress.  Will retry.");
+                try {
+                    Thread.sleep(RETRY_SLEEP);
+                } catch (InterruptedException e1) {
+                    // ignore
+                }
+            }
+        }
+        
+        return ep;
+    }
 }



Mime
View raw message