Author: alessio.soldano(a)jboss.com
Date: 2012-05-24 12:58:38 -0400 (Thu, 24 May 2012)
New Revision: 16315
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3497/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3497/META-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3497/META-INF/jboss-webservices.xml
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
Log:
[JBWS-3497] Allow configuring cxf work queues using properties from jboss-webservices.xml
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2012-05-24
16:32:55 UTC (rev 16314)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/Constants.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -32,4 +32,11 @@
{
public static final String DEPLOYMENT_BUS = "deployment-bus";
public static final String JBOSSWS_CXF_SPRING_DD = "jbossws-cxf.xml";
+
+ public static final String CXF_QUEUE_PREFIX = "cxf.queue.";
+ public static final String CXF_QUEUE_MAX_QUEUE_SIZE_PROP = "maxQueueSize";
+ public static final String CXF_QUEUE_INITIAL_THREADS_PROP =
"initialThreads";
+ public static final String CXF_QUEUE_HIGH_WATER_MARK_PROP =
"highWaterMark";
+ public static final String CXF_QUEUE_LOW_WATER_MARK_PROP = "lowWaterMark";
+ public static final String CXF_QUEUE_DEQUEUE_TIMEOUT_PROP =
"dequeueTimeout";
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2012-05-24
16:32:55 UTC (rev 16314)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -21,7 +21,9 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.cxf.Bus;
import org.apache.cxf.binding.soap.SoapTransportFactory;
@@ -31,12 +33,17 @@
import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.resource.ResourceResolver;
import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.workqueue.AutomaticWorkQueue;
+import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
+import org.apache.cxf.workqueue.WorkQueueManager;
import org.apache.cxf.ws.policy.PolicyEngine;
import org.apache.cxf.ws.policy.selector.MaximalAlternativeSelector;
import org.jboss.ws.api.binding.BindingCustomization;
-import org.jboss.ws.common.Constants;
+import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData;
+import org.jboss.wsf.stack.cxf.client.Constants;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.interceptor.EnableOneWayDecoupledFaultInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
@@ -72,8 +79,9 @@
* @param soapTransportFactory The SoapTransportFactory to configure, if any
* @param resolver The ResourceResolver to configure, if any
* @param configurer The JBossWSCXFConfigurer to install in the bus, if
any
+ * @param dep The current JBossWS-SPI Deployment
*/
- public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer)
+ public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer, Deployment dep)
{
bus.setProperty(org.jboss.wsf.stack.cxf.client.Constants.DEPLOYMENT_BUS, true);
busHolderListener = new BusHolderLifeCycleListener();
@@ -92,6 +100,11 @@
{
bus.getExtension(PolicyEngine.class).setAlternativeSelector(new
MaximalAlternativeSelector());
}
+
+ if (dep != null)
+ {
+ setAdditionalWorkQueues(bus,
dep.getAttachment(JBossWebservicesMetaData.class));
+ }
}
@@ -143,11 +156,70 @@
{
DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
factory.setBus(bus);
- dfm.registerDestinationFactory(Constants.NS_SOAP11, factory);
- dfm.registerDestinationFactory(Constants.NS_SOAP12, factory);
+ dfm.registerDestinationFactory(org.jboss.ws.common.Constants.NS_SOAP11,
factory);
+ dfm.registerDestinationFactory(org.jboss.ws.common.Constants.NS_SOAP12,
factory);
}
}
+
+ /**
+ * Adds work queues parsing simple values of properties in jboss-webservices.xml:
+ * cxf.queue.<queue-name>.<parameter> = value
+ * e.g.
+ * cxf.queue.default.maxQueueSize = 500
+ *
+ * See constants in {@link org.jboss.wsf.stack.cxf.client.Constants}.
+ *
+ * @param bus
+ * @param wsmd
+ */
+ protected static void setAdditionalWorkQueues(Bus bus, JBossWebservicesMetaData wsmd)
+ {
+ if (wsmd != null) {
+ Map<String, String> props = wsmd.getProperties();
+ if (props != null && !props.isEmpty()) {
+ Map<String, Map<String, String>> queuesMap = new
HashMap<String, Map<String,String>>();
+ for (final String k : props.keySet()) {
+ if (k.startsWith(Constants.CXF_QUEUE_PREFIX)) {
+ String sk = k.substring(Constants.CXF_QUEUE_PREFIX.length());
+ int i = sk.indexOf(".");
+ if (i > 0) {
+ String queueName = sk.substring(0, i);
+ String queueProp = sk.substring(i+1);
+ Map<String, String> m = queuesMap.get(queueName);
+ if (m == null) {
+ m = new HashMap<String, String>();
+ queuesMap.put(queueName, m);
+ }
+ m.put(queueProp, props.get(k));
+ }
+ }
+ }
+ WorkQueueManager mgr = bus.getExtension(WorkQueueManager.class);
+ for (String queueName : queuesMap.keySet()) {
+ AutomaticWorkQueue q = createWorkQueue(queueName,
queuesMap.get(queueName));
+ mgr.addNamedWorkQueue(queueName, q);
+ }
+ }
+ }
+ }
+ private static AutomaticWorkQueue createWorkQueue(String name, Map<String,
String> props) {
+ int mqs = parseInt(props.get(Constants.CXF_QUEUE_MAX_QUEUE_SIZE_PROP), 256);
+ int initialThreads = parseInt(props.get(Constants.CXF_QUEUE_INITIAL_THREADS_PROP),
0);
+ int highWaterMark = parseInt(props.get(Constants.CXF_QUEUE_HIGH_WATER_MARK_PROP),
25);
+ int lowWaterMark = parseInt(props.get(Constants.CXF_QUEUE_LOW_WATER_MARK_PROP),
5);
+ long dequeueTimeout =
parseLong(props.get(Constants.CXF_QUEUE_DEQUEUE_TIMEOUT_PROP), 2 * 60 * 1000L);
+ return new AutomaticWorkQueueImpl(mqs, initialThreads, highWaterMark, lowWaterMark,
dequeueTimeout, name);
+ }
+
+ private static int parseInt(String prop, int defaultValue) {
+ return prop != null ? Integer.parseInt(prop) : defaultValue;
+ }
+
+ private static long parseLong(String prop, long defaultValue) {
+ return prop != null ? Long.parseLong(prop) : defaultValue;
+ }
+
/**
* Return the hold bus
*
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2012-05-24
16:32:55 UTC (rev 16314)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -40,6 +40,7 @@
import org.apache.cxf.ws.rm.RMManager;
import org.jboss.ws.api.binding.BindingCustomization;
import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringBusFactory;
@@ -83,13 +84,13 @@
* @param configurer The JBossWSCXFConfigurer to install in the bus, if
any
*/
@Override
- public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer)
+ public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer, Deployment dep)
{
if (configured)
{
throw new IllegalStateException(BundleUtils.getMessage(bundle,
"BUS_IS_ALREADY_CONFIGURED"));
}
- super.configure(soapTransportFactory, resolver, configurer);
+ super.configure(soapTransportFactory, resolver, configurer, dep);
for (DDEndpoint dde : metadata.getEndpoints())
{
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2012-05-24
16:32:55 UTC (rev 16314)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -41,6 +41,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.api.binding.BindingCustomization;
import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
@@ -121,15 +122,16 @@
* @param soapTransportFactory The SoapTransportFactory to configure, if any
* @param resolver The ResourceResolver to configure, if any
* @param configurer The JBossWSCXFConfigurer to install in the bus, if
any
+ * @param dep The current JBossWS-SPI Deployment
*/
@Override
- public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer)
+ public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer, Deployment dep)
{
if (configured)
{
throw new IllegalStateException(BundleUtils.getMessage(bundle,
"BUS_IS_ALREADY_CONFIGURED"));
}
- super.configure(soapTransportFactory, resolver, configurer);
+ super.configure(soapTransportFactory, resolver, configurer, dep);
if (additionalLocations != null)
{
for (URL jbossCxfXml : additionalLocations)
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2012-05-24
16:32:55 UTC (rev 16314)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -110,7 +110,7 @@
}
Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class),
new WSDLFilePublisher(aDep), dep.getService().getEndpoints(),
aDep.getRootFile());
- holder.configure(new SoapTransportFactoryExt(), resolver, configurer);
+ holder.configure(new SoapTransportFactoryExt(), resolver, configurer, dep);
dep.addAttachment(BusHolder.class, holder);
}
finally
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-05-24
16:32:55 UTC (rev 16314)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2012-05-24
16:58:38 UTC (rev 16315)
@@ -194,6 +194,19 @@
</classes>
</war>
+ <!-- jaxws-cxf-jbws3497 -->
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-cxf-jbws3497.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/jbws3497/Endpoint*.class"/>
+ </fileset>
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/cxf/jbws3497/META-INF">
+ <include name="**/*" />
+ </metainf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.apache.cxf"/>
+ </manifest>
+ </jar>
+
<!-- jaxws-cxf-logging -->
<jar destfile="${tests.output.dir}/test-libs/jaxws-cxf-logging.jar">
<fileset dir="${tests.output.dir}/test-classes">
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2012-05-24
16:32:55 UTC (rev 16314)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -63,7 +63,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null);
+ holder.configure(null, null, null, null);
holder.close();
assertEquals("preShutdown method on listener should be called exactly once;
number of actual calls: "
+ listener.getCount(), 1, listener.getCount());
@@ -74,7 +74,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null);
+ holder.configure(null, null, null, null);
bus.shutdown(true);
holder.close();
assertEquals("preShutdown method on listener should be called exactly once;
number of actual calls: "
@@ -86,7 +86,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null);
+ holder.configure(null, null, null, null);
assertEquals("preShutdown method on listener shouldn't be called before
holder is closed: number of actual calls: "
+ listener.getCount(), 0, listener.getCount());
holder.close();
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOne.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.ws.jaxws.cxf.jbws3497;
+
+import javax.jws.Oneway;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface EndpointOne
+{
+ String echo(String input);
+
+ @Oneway
+ void echoOneWay(String input);
+
+ int getCount();
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/EndpointOneImpl.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.ws.jaxws.cxf.jbws3497;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.ejb.Stateless;
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.workqueue.AutomaticWorkQueue;
+import org.apache.cxf.workqueue.WorkQueueManager;
+import org.jboss.logging.Logger;
+
+@WebService(name = "EndpointOne", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3497", serviceName = "ServiceOne")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+@Stateless
+public class EndpointOneImpl
+{
+ private static AtomicInteger count = new AtomicInteger(0);
+
+ @WebMethod
+ public String echo(String input)
+ {
+ Bus bus = BusFactory.getThreadDefaultBus(false);
+ AutomaticWorkQueue queue =
bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
+ //this is just a verification, so going the dirty way...
+ Long qs = null;
+ Integer it = null;
+ try
+ {
+ qs = (Long) queue.getClass().getMethod("getMaxSize").invoke(queue);
+ it = (Integer)
queue.getClass().getMethod("getHighWaterMark").invoke(queue);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ if (qs != 10)
+ {
+ throw new RuntimeException("Expected max queue size '10' but got
'" + qs + "'!");
+ }
+ if (it != 8)
+ {
+ throw new RuntimeException("Expected highWaterMark '8' but got
'" + it + "'!");
+ }
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ count.incrementAndGet();
+ return input;
+ }
+
+ @WebMethod
+ @Oneway
+ public void echoOneWay(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echoOneWay: " + input);
+ count.incrementAndGet();
+ }
+
+ @WebMethod
+ public int getCount()
+ {
+ return count.get();
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3497/JBWS3497TestCase.java 2012-05-24
16:58:38 UTC (rev 16315)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.test.ws.jaxws.cxf.jbws3497;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * [JBWS-3497] Add ability to configure the queue depth on the asynchronous (@Oneway)
work queue.
+ *
+ * @author alessio.soldano(a)jboss.com
+ *
+ */
+public class JBWS3497TestCase extends JBossWSTest
+{
+ private String endpointOneURL = "http://" + getServerHost() +
":8080/jaxws-cxf-jbws3497/ServiceOne/EndpointOne";
+ private String targetNS = "http://org.jboss.ws.jaxws.cxf/jbws3497";
+
+ private EndpointOne portOne;
+
+ protected int defaultSize = 200;
+
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(JBWS3497TestCase.class,
"jaxws-cxf-jbws3497.jar");
+ }
+
+ public void testAccess() throws Exception
+ {
+ initPorts();
+ int count1 = portOne.getCount();
+ Object retObj = portOne.echo("Hello");
+ assertEquals("Hello", retObj);
+ assertEquals(1, portOne.getCount() - count1);
+ }
+
+ //Disabled as there's no easy way for knowing the server is logging WARN messages
saying the @OneWay processing queue is full.
+ //Manually enable this test if willing to check (and try modifying
'cxf.queue.default.maxQueueSize' prop value in jboss-webservices.xml);
+ //otherwise the EndpointOne implementation simply checks the related
AutomaticWorkQueue is properly configured.
+ public void _testConcurrentOneWayInvocations() throws Exception
+ {
+ runConcurrentTests(true);
+ }
+
+ private void runConcurrentTests(boolean oneway) throws Exception
+ {
+ initPorts();
+ final int size = defaultSize;
+ int count1 = portOne.getCount();
+ ExecutorService es = Executors.newFixedThreadPool(size);
+ List<Callable<Boolean>> callables = new
ArrayList<Callable<Boolean>>(size*3);
+ for (int i = 0; i < size*3; i++)
+ {
+ callables.add(new CallableOne(portOne, oneway, i));
+ }
+ List<Future<Boolean>> futures = es.invokeAll(callables);
+ for (Future<Boolean> f : futures)
+ {
+ assertTrue(f.get());
+ }
+ if (oneway) {
+ Thread.sleep(3000);
+ }
+ assertEquals(size*3, portOne.getCount() - count1);
+ }
+
+ private void initPorts() throws MalformedURLException
+ {
+ URL wsdlOneURL = new URL(endpointOneURL + "?wsdl");
+ QName serviceOneName = new QName(targetNS, "ServiceOne");
+ Service serviceOne = Service.create(wsdlOneURL, serviceOneName);
+ portOne = (EndpointOne)serviceOne.getPort(EndpointOne.class);
+ }
+
+ private static class CallableOne implements Callable<Boolean>
+ {
+ private EndpointOne port;
+ private boolean oneway;
+ private int seqNum;
+
+ public CallableOne(EndpointOne port, boolean oneway, int seqNum)
+ {
+ this.port = port;
+ this.oneway = oneway;
+ this.seqNum = seqNum;
+ }
+
+ public Boolean call() throws Exception
+ {
+ String arg = "Foo" + seqNum;
+ if (oneway)
+ {
+ port.echoOneWay(arg);
+ return true;
+ }
+ else
+ {
+ String result = port.echo(arg);
+ return arg.equals(result);
+ }
+ }
+ }
+
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3497/META-INF/jboss-webservices.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3497/META-INF/jboss-webservices.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3497/META-INF/jboss-webservices.xml 2012-05-24
16:58:38 UTC (rev 16315)
@@ -0,0 +1,17 @@
+<?xml version="1.1" encoding="UTF-8"?>
+<webservices
+
xmlns="http://www.jboss.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="1.2"
+
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee">
+
+ <property>
+ <name>cxf.queue.default.maxQueueSize</name>
+ <value>10</value>
+ </property>
+ <property>
+ <name>cxf.queue.default.highWaterMark</name>
+ <value>8</value>
+ </property>
+
+</webservices>
\ No newline at end of file