cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r811467 - in /cxf/trunk: integration/jca/src/main/java/org/apache/cxf/jca/outbound/ integration/jca/src/test/java/org/apache/cxf/jca/outbound/ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/
Date Fri, 04 Sep 2009 16:19:57 GMT
Author: dkulp
Date: Fri Sep  4 16:19:57 2009
New Revision: 811467

URL: http://svn.apache.org/viewvc?rev=811467&view=rev
Log:
[CXF-2398] Patch from Seumas applied to fix issues of closing the JCA
proxies.

Modified:
    cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/outbound/ManagedConnectionImpl.java
    cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/outbound/ManagedConnectionImplTest.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java

Modified: cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/outbound/ManagedConnectionImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/outbound/ManagedConnectionImpl.java?rev=811467&r1=811466&r2=811467&view=diff
==============================================================================
--- cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/outbound/ManagedConnectionImpl.java
(original)
+++ cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/outbound/ManagedConnectionImpl.java
Fri Sep  4 16:19:57 2009
@@ -77,6 +77,7 @@
     private boolean isClosed;
     private Bus bus;
     private Object associatedHandle;
+    private Object clientProxy;
     
     public ManagedConnectionImpl(ManagedConnectionFactoryImpl mcf,
             ConnectionRequestInfo connReqInfo, Subject subject) {
@@ -115,6 +116,10 @@
         if (LOG.isLoggable(Level.FINER)) {
             LOG.finer("destroy");
         }
+        
+        Client client = ClientProxy.getClient(clientProxy);
+        client.destroy();
+
         handles.clear();
         isClosed = false;
         bus = null;
@@ -245,31 +250,33 @@
                         createClientProxy(spec), spec));
     }
     
-    private Object createClientProxy(final CXFConnectionSpec spec) {
-        
-        validateConnectionSpec(spec);
-        ClientProxyFactoryBean factory = null;
-
-        if (EndpointUtils.hasWebServiceAnnotation(spec.getServiceClass())) {
-            factory = new JaxWsProxyFactoryBean();
-        } else {
-            factory = new ClientProxyFactoryBean();
-        }
-              
-        factory.setBus(getBus(spec.getBusConfigURL()));
-        factory.setServiceClass(spec.getServiceClass());
-        factory.getServiceFactory().setEndpointName(spec.getEndpointName());
-        factory.getServiceFactory().setServiceName(spec.getServiceName());
-        factory.getServiceFactory().setWsdlURL(spec.getWsdlURL());
-
-        if (spec.getAddress() != null) {
-            factory.setAddress(spec.getAddress());
+    private synchronized Object createClientProxy(final CXFConnectionSpec spec) {
+        if (clientProxy == null) {
+            validateConnectionSpec(spec);
+            ClientProxyFactoryBean factory = null;
+            
+            if (EndpointUtils.hasWebServiceAnnotation(spec.getServiceClass())) {
+                factory = new JaxWsProxyFactoryBean();
+            } else {
+                factory = new ClientProxyFactoryBean();
+            }
+            
+            factory.setBus(getBus(spec.getBusConfigURL()));
+            factory.setServiceClass(spec.getServiceClass());
+            factory.getServiceFactory().setEndpointName(spec.getEndpointName());
+            factory.getServiceFactory().setServiceName(spec.getServiceName());
+            factory.getServiceFactory().setWsdlURL(spec.getWsdlURL());
+            
+            if (spec.getAddress() != null) {
+                factory.setAddress(spec.getAddress());
+            }
+            
+            configureObject(spec.getEndpointName().toString() + ".jaxws-client.proxyFactory",
factory);
+            
+            clientProxy = factory.create();
         }
-        
-        configureObject(spec.getEndpointName().toString() + ".jaxws-client.proxyFactory",
factory);
-
-        return factory.create();
 
+        return clientProxy;
     }
 
     private void validateConnectionSpec(CXFConnectionSpec spec) {
@@ -405,11 +412,6 @@
             event.setConnectionHandle(proxy);
             sendEvent(event);
             
-            ConnectionInvocationHandler ch = 
-                (ConnectionInvocationHandler)Proxy.getInvocationHandler(proxy);         
  
-            Client client = ClientProxy.getClient(ch.target);
-            client.destroy();
-            
             return null;
         }
     }

Modified: cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/outbound/ManagedConnectionImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/outbound/ManagedConnectionImplTest.java?rev=811467&r1=811466&r2=811467&view=diff
==============================================================================
--- cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/outbound/ManagedConnectionImplTest.java
(original)
+++ cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/outbound/ManagedConnectionImplTest.java
Fri Sep  4 16:19:57 2009
@@ -21,6 +21,7 @@
 import javax.security.auth.Subject;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.BusFactory;
 import org.apache.hello_world_soap_http.Greeter;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
@@ -39,6 +40,8 @@
      */
     @Test
     public void testHandleEqualsMethod() throws Exception {
+        BusFactory.setDefaultBus(null);
+        
         IMocksControl control = EasyMock.createNiceControl();
 
         ManagedConnectionFactoryImpl mcf = control.createMock(ManagedConnectionFactoryImpl.class);

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=811467&r1=811466&r2=811467&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
Fri Sep  4 16:19:57 2009
@@ -27,7 +27,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Session;
@@ -41,7 +40,6 @@
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.AbstractConduit;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
-import org.springframework.jms.connection.SingleConnectionFactory;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.core.MessageCreator;
 
@@ -234,12 +232,7 @@
     }
 
     public void close() {
-        if (jmsConfig.getWrappedConnectionFactory() != null) {
-            ConnectionFactory f = jmsConfig.getWrappedConnectionFactory();
-            if (f instanceof SingleConnectionFactory) {
-                ((SingleConnectionFactory)f).destroy();
-            }
-        }
+        jmsConfig.destroyWrappedConnectionFactory();
         LOG.log(Level.FINE, "JMSConduit closed ");
     }
 

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java?rev=811467&r1=811466&r2=811467&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
Fri Sep  4 16:19:57 2009
@@ -447,6 +447,17 @@
     public ConnectionFactory getWrappedConnectionFactory() {
         return wrappedConnectionFactory;
     }
+    
+    public synchronized void destroyWrappedConnectionFactory() {
+        if (wrappedConnectionFactory instanceof SingleConnectionFactory) {
+            ((SingleConnectionFactory)wrappedConnectionFactory).destroy();
+            if (connectionFactory == wrappedConnectionFactory) {
+                connectionFactory = null;
+            }
+            wrappedConnectionFactory = null;
+        }
+    }
+    
     /**
      * Only for tests
      * @return



Mime
View raw message