You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2011/04/29 15:41:57 UTC
Re: svn commit: r1097729 - in /cxf/trunk/rt: databinding/aegis/src/test/java/org/apache/cxf/aegis/ databinding/jibx/src/test/java/org/apache/cxf/jibx/ databinding/sdo/src/test/java/org/apache/cxf/sdo/ databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbe...
Willem,
I think there needs to be two "enhancements" to this before it's really
finished:
1) JAX-WS provides API's for setting an Executor to use on the clients. I
think it would be best to use that Executor if the user has set it. I think
that's pretty easy as I think it saves it on the Exchange
(message.getExchange().get(Executor.class)). Not 100% sure on that, but I
think that's it.
2) If the user hasn't set one, it would be good to check for a configured
named workqueue before grabbing the default workqueue. We do this in JMS if
you need an example. For example, they could configure a workqueue
specifically for a named service. If not, maybe just look for a workqueue
named "local.transport.default". Then use the default. That allows some
level of local configuration and isolation from the rest of the stuff running.
Definitely not a -1 on this commit, but I think the above two issues should be
addressed as part of this new functionality.
Dan
On Friday, April 29, 2011 4:43:53 AM ningjiang@apache.org wrote:
> Author: ningjiang
> Date: Fri Apr 29 08:43:53 2011
> New Revision: 1097729
>
> URL: http://svn.apache.org/viewvc?rev=1097729&view=rev
> Log:
> CXF-3473 Let CXF LocalConduit and LocalDestination handler the request with
> Executor
>
> Modified:
>
> cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/Abstract
> AegisTest.java
> cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/AbstractJi
> bxTest.java
> cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOT
> est.java
> cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/Ab
> stractXmlBeansTest.java
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJax
> WsTest.java
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredE
> ndpointTest.java
> cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/
> AbstractSimpleFrontendTest.java
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalConduit.java
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalDestination.java
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalTransportFactory.java
> cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local
> /LocalTransportFactoryTest.java
> cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyAnnota
> tionTest.java
>
> Modified:
> cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/Abstract
> AegisTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/
> org/apache/cxf/aegis/AbstractAegisTest.java?rev=1097729&r1=1097728&r2=10977
> 29&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/Abstract
> AegisTest.java (original) +++
> cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/Abstract
> AegisTest.java Fri Apr 29 08:43:53 2011 @@ -95,7 +95,7 @@ public abstract
> class AbstractAegisTest
>
> dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID,
> soapDF);
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/local",
> soapDF);
>
> - localTransport = new LocalTransportFactory();
> + localTransport = new LocalTransportFactory(bus);
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
> localTransport);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http"
> , localTransport);
> dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat",
> localTransport);
>
> Modified:
> cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/AbstractJi
> bxTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/test/java/o
> rg/apache/cxf/jibx/AbstractJibxTest.java?rev=1097729&r1=1097728&r2=1097729&
> view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/AbstractJi
> bxTest.java (original) +++
> cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/AbstractJi
> bxTest.java Fri Apr 29 08:43:53 2011 @@ -60,7 +60,7 @@ public abstract
> class AbstractJibxTest e
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/",
> soapDF);
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/local",
> soapDF);
>
> - localTransport = new LocalTransportFactory();
> + localTransport = new LocalTransportFactory(bus);
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
> localTransport);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http"
> , localTransport);
> dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat",
> localTransport);
>
> Modified:
> cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOT
> est.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/test/java/or
> g/apache/cxf/sdo/AbstractSDOTest.java?rev=1097729&r1=1097728&r2=1097729&vie
> w=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOT
> est.java (original) +++
> cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOT
> est.java Fri Apr 29 08:43:53 2011 @@ -78,7 +78,7 @@ public abstract class
> AbstractSDOTest ex
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/",
> soapDF);
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/local",
> soapDF);
>
> - localTransport = new LocalTransportFactory();
> + localTransport = new LocalTransportFactory(bus);
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
> localTransport);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http"
> , localTransport);
> dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat",
> localTransport);
>
> Modified:
> cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/Ab
> stractXmlBeansTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/test/ja
> va/org/apache/cxf/xmlbeans/AbstractXmlBeansTest.java?rev=1097729&r1=1097728
> &r2=1097729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/Ab
> stractXmlBeansTest.java (original) +++
> cxf/trunk/rt/databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbeans/Ab
> stractXmlBeansTest.java Fri Apr 29 08:43:53 2011 @@ -78,7 +78,7 @@ public
> abstract class AbstractXmlBeansTe
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/",
> soapDF);
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/local",
> soapDF);
>
> - localTransport = new LocalTransportFactory();
> + localTransport = new LocalTransportFactory(bus);
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
> localTransport);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http"
> , localTransport);
> dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat",
> localTransport);
>
> Modified:
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJax
> WsTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org
> /apache/cxf/jaxws/AbstractJaxWsTest.java?rev=1097729&r1=1097728&r2=1097729&
> view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJax
> WsTest.java (original) +++
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJax
> WsTest.java Fri Apr 29 08:43:53 2011 @@ -67,7 +67,7 @@ public abstract
> class AbstractJaxWsTest
>
> dfm.registerDestinationFactory(SoapBindingConstants.SOAP12_BINDING_ID,
> soapDF);
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/local",
> soapDF);
>
> - localTransport = new LocalTransportFactory();
> + localTransport = new LocalTransportFactory(bus);
> localTransport.setUriPrefixes(new
> HashSet<String>(Arrays.asList("http", "local")));
> dfm.registerDestinationFactory(LocalTransportFactory.TRANSPORT_ID,
> localTransport);
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/http",
> localTransport);
>
> Modified:
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredE
> ndpointTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org
> /apache/cxf/jaxws/ConfiguredEndpointTest.java?rev=1097729&r1=1097728&r2=109
> 7729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredE
> ndpointTest.java (original) +++
> cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredE
> ndpointTest.java Fri Apr 29 08:43:53 2011 @@ -340,7 +340,7 @@ public class
> ConfiguredEndpointTest exte
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/",
> soapDF);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/",
> soapDF);
>
> - LocalTransportFactory localTransport = new
> LocalTransportFactory(); + LocalTransportFactory localTransport =
> new LocalTransportFactory(bus);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
> localTransport);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http"
> , localTransport); }
>
> Modified:
> cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/
> AbstractSimpleFrontendTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/test/java/or
> g/apache/cxf/service/factory/AbstractSimpleFrontendTest.java?rev=1097729&r1
> =1097728&r2=1097729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/
> AbstractSimpleFrontendTest.java (original) +++
> cxf/trunk/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/
> AbstractSimpleFrontendTest.java Fri Apr 29 08:43:53 2011 @@ -47,7 +47,7 @@
> public abstract class AbstractSimpleFron
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/",
> soapTF);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/",
> soapTF);
>
> - LocalTransportFactory localTransport = new
> LocalTransportFactory(); + LocalTransportFactory localTransport =
> new LocalTransportFactory(bus);
> localTransport.getUriPrefixes().add("http");
>
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http"
> , localTransport);
> dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http",
> localTransport);
>
> Modified:
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalConduit.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/o
> rg/apache/cxf/transport/local/LocalConduit.java?rev=1097729&r1=1097728&r2=1
> 097729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalConduit.java (original) +++
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalConduit.java Fri Apr 29 08:43:53 2011 @@ -137,8 +137,11 @@ public
> class LocalConduit extends Abstra
>
> destination.getMessageObserver().onMessage(inMsg); }
> };
> -
> - new Thread(receiver).start();
> + if (transportFactory.getExecutor() != null) {
> + transportFactory.getExecutor().execute(receiver);
> + } else {
> + new Thread(receiver).start();
> + }
> }
> };
> message.setContent(OutputStream.class, cout);
>
> Modified:
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalDestination.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/o
> rg/apache/cxf/transport/local/LocalDestination.java?rev=1097729&r1=1097728&
> r2=1097729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalDestination.java (original) +++
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalDestination.java Fri Apr 29 08:43:53 2011 @@ -97,8 +97,11 @@ public
> class LocalDestination extends Ab
>
> conduit.getMessageObserver().onMessage(m); }
> };
> -
> - new Thread(receiver).start();
> + if (localDestinationFactory.getExecutor() !=
> null) { +
> localDestinationFactory.getExecutor().execute(receiver); +
> } else {
> + new Thread(receiver).start();
> + }
> }
> };
>
>
> Modified:
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalTransportFactory.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/o
> rg/apache/cxf/transport/local/LocalTransportFactory.java?rev=1097729&r1=109
> 7728&r2=1097729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalTransportFactory.java (original) +++
> cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local
> /LocalTransportFactory.java Fri Apr 29 08:43:53 2011 @@ -26,6 +26,7 @@
> import java.util.HashSet;
> import java.util.List;
> import java.util.Map;
> import java.util.Set;
> +import java.util.concurrent.Executor;
> import java.util.logging.Logger;
>
> import javax.annotation.Resource;
> @@ -41,6 +42,7 @@ import org.apache.cxf.transport.Conduit;
> import org.apache.cxf.transport.ConduitInitiator;
> import org.apache.cxf.transport.Destination;
> import org.apache.cxf.transport.DestinationFactory;
> +import org.apache.cxf.workqueue.WorkQueueManager;
> import org.apache.cxf.ws.addressing.AttributedURIType;
> import org.apache.cxf.ws.addressing.EndpointReferenceType;
>
> @@ -70,6 +72,7 @@ public class LocalTransportFactory exten
> private Set<String> messageFilterProperties;
> private Set<String> messageIncludeProperties;
> private Set<String> uriPrefixes = new HashSet<String>(URI_PREFIXES);
> + private volatile Executor executor;
>
> public LocalTransportFactory() {
> this(null);
> @@ -116,6 +119,24 @@ public class LocalTransportFactory exten
> void remove(LocalDestination destination) {
> destinations.remove(destination);
> }
> +
> + public Executor getExecutor() {
> + if (executor == null && bus != null) {
> + synchronized (this) {
> + if (executor == null) {
> + WorkQueueManager manager =
> bus.getExtension(WorkQueueManager.class); + if (manager
> != null) {
> + executor = manager.getAutomaticWorkQueue();
> + }
> + }
> + }
> + }
> + return executor;
> + }
> +
> + public void setExecutor(Executor executor) {
> + this.executor = executor;
> + }
>
> public Conduit getConduit(EndpointInfo ei) throws IOException {
> return new LocalConduit(this,
> (LocalDestination)getDestination(ei));
>
> Modified:
> cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local
> /LocalTransportFactoryTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/test/java/o
> rg/apache/cxf/transport/local/LocalTransportFactoryTest.java?rev=1097729&r1
> =1097728&r2=1097729&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local
> /LocalTransportFactoryTest.java (original) +++
> cxf/trunk/rt/transports/local/src/test/java/org/apache/cxf/transport/local
> /LocalTransportFactoryTest.java Fri Apr 29 08:43:53 2011 @@ -25,6 +25,8 @@
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.OutputStream;
>
> +import org.apache.cxf.Bus;
> +import org.apache.cxf.BusFactory;
> import org.apache.cxf.message.Message;
> import org.apache.cxf.message.MessageImpl;
> import org.apache.cxf.service.model.EndpointInfo;
> @@ -47,7 +49,9 @@ public class LocalTransportFactoryTest e
> }
>
> private void testInvocation(boolean isDirectDispatch) throws Exception
> { - LocalTransportFactory factory = new LocalTransportFactory(); +
> // Need to create a DefaultBus
> + Bus bus = BusFactory.getDefaultBus();
> + LocalTransportFactory factory = new LocalTransportFactory(bus);
>
> EndpointInfo ei = new EndpointInfo(null,
> "http://schemas.xmlsoap.org/soap/http"); AddressType a = new
> AddressType();
>
> Modified:
> cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyAnnota
> tionTest.java URL:
> http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apac
> he/cxf/ws/policy/PolicyAnnotationTest.java?rev=1097729&r1=1097728&r2=109772
> 9&view=diff
> ==========================================================================
> ==== ---
> cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyAnnota
> tionTest.java (original) +++
> cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyAnnota
> tionTest.java Fri Apr 29 08:43:53 2011 @@ -67,7 +67,7 @@ public class
> PolicyAnnotationTest extend
> "http://cxf.apache.org/transports/http/configuration",
> "http://cxf.apache.org/bindings/xformat");
>
> - LocalTransportFactory f = new LocalTransportFactory();
> + LocalTransportFactory f = new LocalTransportFactory(bus);
> f.getUriPrefixes().add("http");
> f.setTransportIds(tp);
> f.setBus(bus);
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com
Re: svn commit: r1097729 - in /cxf/trunk/rt: databinding/aegis/src/test/java/org/apache/cxf/aegis/
databinding/jibx/src/test/java/org/apache/cxf/jibx/ databinding/sdo/src/test/java/org/apache/cxf/sdo/
databinding/xmlbeans/src/test/java/org/apache/cxf/xmlbe...
Posted by Willem Jiang <wi...@gmail.com>.
Hi Dan,
Thanks for your inputs, these help user to configure the executor
better, I will commit these enhancements shortly.
Willem
On 4/29/11 9:41 PM, Daniel Kulp wrote:
>
> Willem,
>
> I think there needs to be two "enhancements" to this before it's really
> finished:
>
> 1) JAX-WS provides API's for setting an Executor to use on the clients. I
> think it would be best to use that Executor if the user has set it. I think
> that's pretty easy as I think it saves it on the Exchange
> (message.getExchange().get(Executor.class)). Not 100% sure on that, but I
> think that's it.
>
> 2) If the user hasn't set one, it would be good to check for a configured
> named workqueue before grabbing the default workqueue. We do this in JMS if
> you need an example. For example, they could configure a workqueue
> specifically for a named service. If not, maybe just look for a workqueue
> named "local.transport.default". Then use the default. That allows some
> level of local configuration and isolation from the rest of the stuff running.
>
>
> Definitely not a -1 on this commit, but I think the above two issues should be
> addressed as part of this new functionality.
>
> Dan
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com