You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2014/02/25 11:44:26 UTC
git commit: CXF-5543 Cleaning up configuration to separate old style
and new style configs
Repository: cxf
Updated Branches:
refs/heads/master 91112f987 -> 98347e4ee
CXF-5543 Cleaning up configuration to separate old style and new style configs
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/98347e4e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/98347e4e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/98347e4e
Branch: refs/heads/master
Commit: 98347e4ee2a790ebe6f308bca835f2bc0932e120
Parents: 91112f9
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Feb 25 11:44:12 2014 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Feb 25 11:44:12 2014 +0100
----------------------------------------------------------------------
.../cxf/transport/jms/JMSConfiguration.java | 104 +---------
.../cxf/transport/jms/JMSOldConfigHolder.java | 191 +++++--------------
.../cxf/transport/jms/uri/JMSEndpoint.java | 49 ++++-
.../transport/jms/uri/JMSEndpointWSDLUtil.java | 119 ++++++++++++
.../jms/util/MessageListenerContainer.java | 51 +++--
.../cxf/transport/jms/util/TestReceiver.java | 18 +-
.../cxf/transport/jms/AbstractJMSTester.java | 3 +
.../cxf/transport/jms/JMSDestinationTest.java | 11 +-
.../apache/cxf/transport/jms/OldConfigTest.java | 10 +-
.../cxf/transport/jms/uri/MyBeanLocator.java | 79 ++++++++
.../jms/uri/URIConfiguredConduitTest.java | 56 ++++--
.../jms/src/test/resources/jms_test_config.xml | 5 +-
.../testsuite/testcases/SoapJmsSpecTest.java | 2 +-
.../cxf/systest/jms/JMSClientServerTest.java | 3 -
.../jms/continuations/jms_test_config.xml | 5 -
.../jms/tx/JMSTransactionClientServerTest.java | 1 -
16 files changed, 402 insertions(+), 305 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
index b0e6323..5fdfa81 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
@@ -18,8 +18,6 @@
*/
package org.apache.cxf.transport.jms;
-import java.util.concurrent.Executor;
-
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -34,8 +32,7 @@ import org.apache.cxf.transport.jms.util.JndiHelper;
@NoJSR250Annotations
public class JMSConfiguration {
/**
- * The use of -1 is to make easier to determine
- * if the setCacheLevel has been called.
+ * Default value to mark as unset
*/
public static final int DEFAULT_VALUE = -1;
@@ -44,10 +41,7 @@ public class JMSConfiguration {
private JndiHelper jndiTemplate;
private ConnectionFactory connectionFactory;
private DestinationResolver destinationResolver = new JMSDestinationResolver();
- private Executor taskExecutor;
private boolean reconnectOnException = true;
- private boolean messageIdEnabled = true;
- private boolean messageTimestampEnabled = true;
private boolean pubSubNoLocal;
private Long clientReceiveTimeout = 60000L;
private Long serverReceiveTimeout;
@@ -57,8 +51,6 @@ public class JMSConfiguration {
private long timeToLive = Message.DEFAULT_TIME_TO_LIVE;
private boolean sessionTransacted;
- private int concurrentConsumers = 1;
- private int maxConcurrentConsumers = 1;
private int maxSuspendedContinuations = DEFAULT_VALUE;
private int reconnectPercentOfMax = 70;
@@ -84,14 +76,9 @@ public class JMSConfiguration {
private boolean replyPubSubDomain;
private Boolean useConduitIdSelector;
private String conduitSelectorPrefix;
- private long recoveryInterval = DEFAULT_VALUE;
- private int cacheLevel = DEFAULT_VALUE;
- private String cacheLevelName;
- private Boolean enforceSpec;
- private boolean acceptMessagesWhileStopping;
private boolean jmsProviderTibcoEms;
- //For jms spec.
+ // For jms spec. Do not configure manually
private String targetService;
private String requestURI;
@@ -109,30 +96,6 @@ public class JMSConfiguration {
}
}
- public String getCacheLevelName() {
- return cacheLevelName;
- }
-
- public void setCacheLevelName(String cacheLevelName) {
- this.cacheLevelName = cacheLevelName;
- }
-
- public int getCacheLevel() {
- return cacheLevel;
- }
-
- public void setCacheLevel(int cacheLevel) {
- this.cacheLevel = cacheLevel;
- }
-
- public long getRecoveryInterval() {
- return recoveryInterval;
- }
-
- public void setRecoveryInterval(long recoveryInterval) {
- this.recoveryInterval = recoveryInterval;
- }
-
public boolean isUsingEndpointInfo() {
return this.usingEndpointInfo;
}
@@ -141,22 +104,6 @@ public class JMSConfiguration {
this.usingEndpointInfo = usingEndpointInfo;
}
- public boolean isMessageIdEnabled() {
- return messageIdEnabled;
- }
-
- public void setMessageIdEnabled(boolean messageIdEnabled) {
- this.messageIdEnabled = messageIdEnabled;
- }
-
- public boolean isMessageTimestampEnabled() {
- return messageTimestampEnabled;
- }
-
- public void setMessageTimestampEnabled(boolean messageTimestampEnabled) {
- this.messageTimestampEnabled = messageTimestampEnabled;
- }
-
public boolean isPubSubNoLocal() {
return pubSubNoLocal;
}
@@ -328,22 +275,6 @@ public class JMSConfiguration {
public void setTransactionManager(Object transactionManager) {
}
- public int getConcurrentConsumers() {
- return concurrentConsumers;
- }
-
- public void setConcurrentConsumers(int concurrentConsumers) {
- this.concurrentConsumers = concurrentConsumers;
- }
-
- public int getMaxConcurrentConsumers() {
- return maxConcurrentConsumers;
- }
-
- public void setMaxConcurrentConsumers(int maxConcurrentConsumers) {
- this.maxConcurrentConsumers = maxConcurrentConsumers;
- }
-
public int getMaxSuspendedContinuations() {
return maxSuspendedContinuations;
}
@@ -360,14 +291,6 @@ public class JMSConfiguration {
this.reconnectPercentOfMax = reconnectPercentOfMax;
}
- public Executor getTaskExecutor() {
- return taskExecutor;
- }
-
- public void setTaskExecutor(Executor taskExecutor) {
- this.taskExecutor = taskExecutor;
- }
-
public void setUseConduitIdSelector(boolean useConduitIdSelector) {
this.useConduitIdSelector = useConduitIdSelector;
}
@@ -407,14 +330,6 @@ public class JMSConfiguration {
this.reconnectOnException = reconnectOnException;
}
- public boolean isAcceptMessagesWhileStopping() {
- return acceptMessagesWhileStopping;
- }
-
- public void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) {
- this.acceptMessagesWhileStopping = acceptMessagesWhileStopping;
- }
-
public ConnectionFactory getConnectionFactory() {
if (connectionFactory == null) {
connectionFactory = JMSFactory.getConnectionFactoryFromJndi(this);
@@ -446,21 +361,6 @@ public class JMSConfiguration {
return requestURI;
}
- public boolean isEnforceSpec() {
- if (!isSetEnforceSpec()) {
- return true;
- }
- return enforceSpec;
- }
-
- public void setEnforceSpec(boolean enforceSpec) {
- this.enforceSpec = enforceSpec;
- }
-
- public boolean isSetEnforceSpec() {
- return this.enforceSpec != null;
- }
-
/** * @return Returns the jmsProviderTibcoEms.
*/
public boolean isJmsProviderTibcoEms() {
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
index 4a2ddcc..eece423 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
@@ -25,11 +25,13 @@ import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.naming.Context;
import org.apache.cxf.Bus;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.EndpointInfo;
@@ -38,15 +40,6 @@ import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
import org.apache.cxf.transport.jms.uri.JMSEndpoint;
import org.apache.cxf.transport.jms.util.JMSDestinationResolver;
import org.apache.cxf.transport.jms.util.JndiHelper;
-import org.apache.cxf.transport.jms.wsdl.DeliveryModeType;
-import org.apache.cxf.transport.jms.wsdl.JndiConnectionFactoryNameType;
-import org.apache.cxf.transport.jms.wsdl.JndiContextParameterType;
-import org.apache.cxf.transport.jms.wsdl.JndiInitialContextFactoryType;
-import org.apache.cxf.transport.jms.wsdl.JndiURLType;
-import org.apache.cxf.transport.jms.wsdl.PriorityType;
-import org.apache.cxf.transport.jms.wsdl.ReplyToNameType;
-import org.apache.cxf.transport.jms.wsdl.TimeToLiveType;
-import org.apache.cxf.transport.jms.wsdl.TopicReplyToNameType;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
public class JMSOldConfigHolder {
@@ -114,30 +107,11 @@ public class JMSOldConfigHolder {
public void setServerBehavior(ServerBehaviorPolicyType serverBehavior) {
this.serverBehavior = serverBehavior;
}
-
- /**
- * Get the extensors from the wsdl and/or configuration that will
- * then be used to configure the JMSConfiguration object
- * @param target
- */
- protected JMSEndpoint getExtensorsAndConfig(Bus bus,
- EndpointInfo endpointInfo,
- EndpointReferenceType target,
- boolean isConduit) throws IOException {
- JMSEndpoint endpoint = null;
- String adr = target == null ? endpointInfo.getAddress() : target.getAddress().getValue();
- try {
- endpoint = new JMSEndpoint(adr);
- } catch (RuntimeException ex) {
- throw ex;
- } catch (Exception e) {
- IOException e2 = new IOException(e.getMessage());
- e2.initCause(e);
- throw e2;
- }
- retrieveWSDLInformation(endpoint, endpointInfo);
-
+ public void initFromExtensorsAndSpring(Bus bus,
+ EndpointInfo endpointInfo,
+ EndpointReferenceType target,
+ boolean isConduit) {
address = endpointInfo.getTraversedExtensor(address, AddressType.class);
clientConfig = endpointInfo.getTraversedExtensor(new ClientConfig(), ClientConfig.class);
runtimePolicy = endpointInfo.getTraversedExtensor(new ClientBehaviorPolicyType(),
@@ -154,16 +128,18 @@ public class JMSOldConfigHolder {
// config. Search for a conduit or destination with name=endpoint name + ".jms-conduit"
// or ".jms-destination"
+ // Add conduit or destination config from spring
Configurer configurer = bus.getExtension(Configurer.class);
if (null != configurer) {
if (name != null) {
configurer.configureBean(name, this);
}
+ String adr = target == null ? endpointInfo.getAddress() : target.getAddress().getValue();
if (adr != null) {
configurer.configureBean(adr, this);
}
}
- return endpoint;
+
}
/**
@@ -177,37 +153,24 @@ public class JMSOldConfigHolder {
EndpointReferenceType target,
boolean isConduit)
throws IOException {
- JMSEndpoint endpoint = getExtensorsAndConfig(bus, endpointInfo, target, isConduit);
-
- return configureEndpoint(isConduit, endpoint);
- }
-
- protected JMSConfiguration configureEndpoint(boolean isConduit, JMSEndpoint endpoint) {
+ JMSEndpoint endpoint = new JMSEndpoint(endpointInfo, target);
+ initFromExtensorsAndSpring(bus, endpointInfo, target, isConduit);
+ ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
if (address != null) {
mapAddressToEndpoint(address, endpoint);
}
if (jmsConfig == null) {
jmsConfig = new JMSConfiguration();
}
-
+
int deliveryMode = endpoint.getDeliveryMode()
== org.apache.cxf.transport.jms.uri.JMSEndpoint.DeliveryModeType.PERSISTENT
? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
jmsConfig.setDeliveryMode(deliveryMode);
-
+
jmsConfig.setPriority(endpoint.getPriority());
-
+
if (jmsConfig.isUsingEndpointInfo()) {
- JndiHelper jt = new JndiHelper(JMSOldConfigHolder.getInitialContextEnv(endpoint));
- boolean pubSubDomain = endpoint.getJmsVariant().contains(JMSEndpoint.TOPIC);
- JNDIConfiguration jndiConfig = new JNDIConfiguration();
- jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
- jmsConfig.setJndiTemplate(jt);
-
- jndiConfig.setConnectionUserName(endpoint.getUsername());
- jndiConfig.setConnectionPassword(endpoint.getPassword());
-
- jmsConfig.setJndiConfig(jndiConfig);
jmsConfig.setReconnectOnException(endpoint.isReconnectOnException());
jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
jmsConfig.setExplicitQosEnabled(true);
@@ -226,6 +189,7 @@ public class JMSOldConfigHolder {
}
}
}
+ boolean pubSubDomain = endpoint.getJmsVariant().contains(JMSEndpoint.TOPIC);
jmsConfig.setPubSubDomain(pubSubDomain);
jmsConfig.setPubSubNoLocal(true);
if (clientConfig.isSetClientReceiveTimeout()) {
@@ -240,23 +204,39 @@ public class JMSOldConfigHolder {
if (serverConfig.isSetServerReceiveTimeout()) {
jmsConfig.setServerReceiveTimeout(serverConfig.getServerReceiveTimeout());
}
- jmsConfig.setEnforceSpec(clientConfig.isEnforceSpec());
jmsConfig.setSubscriptionDurable(serverBehavior.isSetDurableSubscriberName());
jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
jmsConfig.setDurableSubscriptionClientId(serverConfig.getDurableSubscriptionClientId());
- if (sessionPool.isSetHighWaterMark()) {
- jmsConfig.setMaxConcurrentConsumers(sessionPool.getHighWaterMark());
- }
- if (sessionPool.isSetLowWaterMark()) {
- jmsConfig.setConcurrentConsumers(sessionPool.getLowWaterMark());
- }
jmsConfig.setTimeToLive(endpoint.getTimeToLive());
if (serverBehavior.isSetTransactional()) {
jmsConfig.setSessionTransacted(serverBehavior.isTransactional());
}
- boolean useJndi = endpoint.getJmsVariant().contains(JMSEndpoint.JNDI);
- if (useJndi) {
+
+ if (endpoint.getJndiURL() != null) {
+ // Configure Connection Factory using jndi
+ JndiHelper jt = new JndiHelper(JMSOldConfigHolder.getInitialContextEnv(endpoint));
+ jmsConfig.setJndiTemplate(jt);
+ JNDIConfiguration jndiConfig = new JNDIConfiguration();
+ jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
+ jndiConfig.setConnectionUserName(endpoint.getUsername());
+ jndiConfig.setConnectionPassword(endpoint.getPassword());
+ jmsConfig.setJndiConfig(jndiConfig);
+ } else {
+ // Configure ConnectionFactory using locator
+ if (locator != null) {
+ // Lookup connectionFactory in context like blueprint
+ ConnectionFactory cf = locator.getBeanOfType(endpoint.getJndiConnectionFactoryName(),
+ ConnectionFactory.class);
+ if (cf != null) {
+ jmsConfig.setConnectionFactory(cf);
+ }
+ }
+ }
+
+ boolean resolveUsingJndi = endpoint.getJmsVariant().contains(JMSEndpoint.JNDI);
+ if (resolveUsingJndi) {
// Setup Destination jndi destination resolver
+ JndiHelper jt = new JndiHelper(JMSOldConfigHolder.getInitialContextEnv(endpoint));
final JMSDestinationResolver jndiDestinationResolver = new JMSDestinationResolver();
jndiDestinationResolver.setJndiTemplate(jt);
jmsConfig.setDestinationResolver(jndiDestinationResolver);
@@ -274,10 +254,10 @@ public class JMSOldConfigHolder {
}
}
}
-
+
String requestURI = endpoint.getRequestURI();
jmsConfig.setRequestURI(requestURI);
-
+
String targetService = endpoint.getParameter(JMSSpecConstants.TARGETSERVICE_PARAMETER_NAME);
jmsConfig.setTargetService(targetService);
return jmsConfig;
@@ -329,81 +309,16 @@ public class JMSOldConfigHolder {
= address.getJMSNamingProperty().listIterator();
while (listIter.hasNext()) {
JMSNamingPropertyType propertyPair = listIter.next();
- if (null != propertyPair.getValue()) {
- endpoint.putJndiParameter(propertyPair.getName(), propertyPair.getValue());
- }
- }
- }
-
- /**
- * @param endpoint
- * @param ei
- */
- private void retrieveWSDLInformation(JMSEndpoint endpoint, EndpointInfo ei) {
- JndiContextParameterType jndiContextParameterType =
- getWSDLExtensor(ei, JndiContextParameterType.class);
- if (jndiContextParameterType != null
- && endpoint.getJndiParameters().get(jndiContextParameterType.getName()) == null) {
- endpoint.putJndiParameter(jndiContextParameterType.getName().trim(),
- jndiContextParameterType.getValue().trim());
- }
-
- if (endpoint.getJndiConnectionFactoryName() == null) {
- JndiConnectionFactoryNameType jndiConnectionFactoryNameType = getWSDLExtensor(
- ei, JndiConnectionFactoryNameType.class);
- if (jndiConnectionFactoryNameType != null) {
- endpoint.setJndiConnectionFactoryName(jndiConnectionFactoryNameType.getValue().trim());
- }
- }
- if (endpoint.getJndiInitialContextFactory() == null) {
- JndiInitialContextFactoryType jndiInitialContextFactoryType =
- getWSDLExtensor(ei, JndiInitialContextFactoryType.class);
- if (jndiInitialContextFactoryType != null) {
- endpoint.setJndiInitialContextFactory(jndiInitialContextFactoryType.getValue().trim());
- }
- }
-
- if (endpoint.getJndiURL() == null) {
- JndiURLType jndiURLType = getWSDLExtensor(ei, JndiURLType.class);
- if (jndiURLType != null) {
- endpoint.setJndiURL(jndiURLType.getValue().trim());
- }
- }
-
- if (!endpoint.isSetDeliveryMode()) {
- DeliveryModeType deliveryModeType = getWSDLExtensor(ei, DeliveryModeType.class);
- if (deliveryModeType != null) {
- String deliveryMode = deliveryModeType.getValue().trim();
- endpoint.setDeliveryMode(org.apache.cxf.transport.jms.uri.JMSEndpoint.DeliveryModeType
- .valueOf(deliveryMode));
- }
- }
-
- if (!endpoint.isSetPriority()) {
- PriorityType priorityType = getWSDLExtensor(ei, PriorityType.class);
- if (priorityType != null) {
- endpoint.setPriority(priorityType.getValue());
- }
- }
-
- if (endpoint.getTimeToLive() == 0) {
- TimeToLiveType timeToLiveType = getWSDLExtensor(ei, TimeToLiveType.class);
- if (timeToLiveType != null) {
- endpoint.setTimeToLive(timeToLiveType.getValue());
- }
- }
-
- if (endpoint.getReplyToName() == null) {
- ReplyToNameType replyToNameType = getWSDLExtensor(ei, ReplyToNameType.class);
- if (replyToNameType != null) {
- endpoint.setReplyToName(replyToNameType.getValue());
- }
- }
-
- if (endpoint.getTopicReplyToName() == null) {
- TopicReplyToNameType topicReplyToNameType = getWSDLExtensor(ei, TopicReplyToNameType.class);
- if (topicReplyToNameType != null) {
- endpoint.setTopicReplyToName(topicReplyToNameType.getValue());
+ String name = propertyPair.getName();
+ String value = propertyPair.getValue();
+ if (value != null) {
+ if (name.equals(Context.PROVIDER_URL)) {
+ endpoint.setJndiURL(value);
+ } else if (name.equals(Context.INITIAL_CONTEXT_FACTORY)) {
+ endpoint.setJndiInitialContextFactory(value);
+ } else {
+ endpoint.putJndiParameter(propertyPair.getName(), propertyPair.getValue());
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
index 3501f3b..8cc6d5e 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
@@ -25,7 +25,9 @@ import java.util.Map;
import javax.jms.Message;
import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
/**
*
@@ -70,19 +72,43 @@ public class JMSEndpoint {
private Integer priority;
private String replyToName;
private String topicReplyToName;
- private String jndiConnectionFactoryName;
+ private String jndiConnectionFactoryName = "ConnectionFactory";
private String jndiInitialContextFactory;
private String jndiURL;
private String username;
private String password;
private boolean reconnectOnException = true;
+ private String durableSubscriptionName;
+ private long receiveTimeout = 60000L;
/**
* @param uri
* @param subject
*/
public JMSEndpoint(String endpointUri) {
- this();
+ this(null, endpointUri);
+ }
+
+ /**
+ * Get the extensors from the wsdl and/or configuration that will
+ * then be used to configure the JMSConfiguration object
+ * @param target
+ */
+ public JMSEndpoint(EndpointInfo endpointInfo, EndpointReferenceType target) {
+ this(endpointInfo, target == null ? endpointInfo.getAddress() : target.getAddress().getValue());
+ }
+
+ /**
+ * @param uri
+ * @param subject
+ */
+ public JMSEndpoint(EndpointInfo ei, String endpointUri) {
+ this.jmsVariant = JMSEndpoint.QUEUE;
+
+ if (ei != null) {
+ JMSEndpointWSDLUtil.retrieveWSDLInformation(this, ei);
+
+ }
if (!(StringUtils.isEmpty(endpointUri) || "jms://".equals(endpointUri) || !endpointUri.startsWith("jms"))) {
this.endpointUri = endpointUri;
JMSURIParser parsed = new JMSURIParser(endpointUri);
@@ -91,10 +117,6 @@ public class JMSEndpoint {
configureProperties(this, parsed.parseQuery());
}
}
-
- public JMSEndpoint() {
- this.jmsVariant = JMSEndpoint.QUEUE;
- }
/**
* @param endpoint
@@ -339,6 +361,21 @@ public class JMSEndpoint {
public void setReconnectOnException(boolean reconnectOnException) {
this.reconnectOnException = reconnectOnException;
}
+ public String getDurableSubscriptionName() {
+ return durableSubscriptionName;
+ }
+
+ public void setDurableSubscriptionName(String durableSubscriptionName) {
+ this.durableSubscriptionName = durableSubscriptionName;
+ }
+
+ public long getReceiveTimeout() {
+ return receiveTimeout;
+ }
+ public void setReceiveTimeout(long receiveTimeout) {
+ this.receiveTimeout = receiveTimeout;
+ }
+
public enum DeliveryModeType { PERSISTENT, NON_PERSISTENT };
public enum MessageType {
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointWSDLUtil.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointWSDLUtil.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointWSDLUtil.java
new file mode 100644
index 0000000..c6c53ad
--- /dev/null
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointWSDLUtil.java
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.jms.uri;
+
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.jms.wsdl.DeliveryModeType;
+import org.apache.cxf.transport.jms.wsdl.JndiConnectionFactoryNameType;
+import org.apache.cxf.transport.jms.wsdl.JndiContextParameterType;
+import org.apache.cxf.transport.jms.wsdl.JndiInitialContextFactoryType;
+import org.apache.cxf.transport.jms.wsdl.JndiURLType;
+import org.apache.cxf.transport.jms.wsdl.PriorityType;
+import org.apache.cxf.transport.jms.wsdl.ReplyToNameType;
+import org.apache.cxf.transport.jms.wsdl.TimeToLiveType;
+import org.apache.cxf.transport.jms.wsdl.TopicReplyToNameType;
+
+public final class JMSEndpointWSDLUtil {
+ private JMSEndpointWSDLUtil() {
+ }
+
+ /**
+ * Retrieve JMS spec configs from wsdl and write them to the JMSEndpoint
+ * If a property is already set on the JMSEndpoint it will not be overwritten
+ *
+ * @param endpoint
+ * @param ei
+ */
+ static void retrieveWSDLInformation(JMSEndpoint endpoint, EndpointInfo ei) {
+ JndiContextParameterType jndiContextParameterType =
+ getWSDLExtensor(ei, JndiContextParameterType.class);
+ if (jndiContextParameterType != null) {
+ endpoint.putJndiParameter(jndiContextParameterType.getName().trim(),
+ jndiContextParameterType.getValue().trim());
+ }
+
+
+ JndiConnectionFactoryNameType jndiConnectionFactoryNameType
+ = getWSDLExtensor(ei, JndiConnectionFactoryNameType.class);
+ if (jndiConnectionFactoryNameType != null) {
+ endpoint.setJndiConnectionFactoryName(jndiConnectionFactoryNameType.getValue().trim());
+ }
+
+ JndiInitialContextFactoryType jndiInitialContextFactoryType
+ = getWSDLExtensor(ei, JndiInitialContextFactoryType.class);
+ if (jndiInitialContextFactoryType != null) {
+ endpoint.setJndiInitialContextFactory(jndiInitialContextFactoryType.getValue().trim());
+ }
+
+ JndiURLType jndiURLType = getWSDLExtensor(ei, JndiURLType.class);
+ if (jndiURLType != null) {
+ endpoint.setJndiURL(jndiURLType.getValue().trim());
+ }
+
+ DeliveryModeType deliveryModeType = getWSDLExtensor(ei, DeliveryModeType.class);
+ if (deliveryModeType != null) {
+ String deliveryMode = deliveryModeType.getValue().trim();
+ endpoint.setDeliveryMode(org.apache.cxf.transport.jms.uri.JMSEndpoint.DeliveryModeType
+ .valueOf(deliveryMode));
+ }
+
+ PriorityType priorityType = getWSDLExtensor(ei, PriorityType.class);
+ if (priorityType != null) {
+ endpoint.setPriority(priorityType.getValue());
+ }
+
+ TimeToLiveType timeToLiveType = getWSDLExtensor(ei, TimeToLiveType.class);
+ if (timeToLiveType != null) {
+ endpoint.setTimeToLive(timeToLiveType.getValue());
+ }
+
+ ReplyToNameType replyToNameType = getWSDLExtensor(ei, ReplyToNameType.class);
+ if (replyToNameType != null) {
+ endpoint.setReplyToName(replyToNameType.getValue());
+ }
+
+ TopicReplyToNameType topicReplyToNameType = getWSDLExtensor(ei, TopicReplyToNameType.class);
+ if (topicReplyToNameType != null) {
+ endpoint.setTopicReplyToName(topicReplyToNameType.getValue());
+ }
+ }
+
+ public static <T> T getWSDLExtensor(EndpointInfo ei, Class<T> cls) {
+ ServiceInfo si = ei.getService();
+ BindingInfo bi = ei.getBinding();
+
+ Object o = ei.getExtensor(cls);
+ if (o == null && si != null) {
+ o = si.getExtensor(cls);
+ }
+ if (o == null && bi != null) {
+ o = bi.getExtensor(cls);
+ }
+
+ if (o == null) {
+ return null;
+ }
+ if (cls.isInstance(o)) {
+ return cls.cast(o);
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/MessageListenerContainer.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/MessageListenerContainer.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/MessageListenerContainer.java
index 1e7fd95..03f5535 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/MessageListenerContainer.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/MessageListenerContainer.java
@@ -28,6 +28,7 @@ import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
+import javax.jms.Topic;
public class MessageListenerContainer implements JMSListenerContainer {
@@ -41,6 +42,8 @@ public class MessageListenerContainer implements JMSListenerContainer {
private MessageConsumer consumer;
private Session session;
private ExecutorService executor;
+ private String durableSubscriptionName;
+ private boolean pubSubNoLocal;
public MessageListenerContainer(Connection connection,
Destination replyTo,
@@ -62,26 +65,41 @@ public class MessageListenerContainer implements JMSListenerContainer {
public void setMessageSelector(String messageSelector) {
this.messageSelector = messageSelector;
}
+
+ private ExecutorService getExecutor() {
+ if (executor == null) {
+ executor = Executors.newFixedThreadPool(10);
+ }
+ return executor;
+ }
- @Override
- public boolean isRunning() {
- return running;
+ public void setExecutor(ExecutorService executor) {
+ this.executor = executor;
}
- @Override
- public void stop() {
- running = false;
- ResourceCloser.close(consumer);
- ResourceCloser.close(session);
- consumer = null;
- session = null;
+ public void setDurableSubscriptionName(String durableSubscriptionName) {
+ this.durableSubscriptionName = durableSubscriptionName;
+ }
+
+ public void setPubSubNoLocal(boolean pubSubNoLocal) {
+ this.pubSubNoLocal = pubSubNoLocal;
}
@Override
+ public boolean isRunning() {
+ return running;
+ }
+
+ @Override
public void start() {
try {
session = connection.createSession(transacted, acknowledgeMode);
- consumer = session.createConsumer(replyTo, messageSelector);
+ if (durableSubscriptionName != null) {
+ consumer = session.createDurableSubscriber((Topic)replyTo, durableSubscriptionName,
+ messageSelector, pubSubNoLocal);
+ } else {
+ consumer = session.createConsumer(replyTo, messageSelector);
+ }
consumer.setMessageListener(listenerHandler);
running = true;
} catch (JMSException e) {
@@ -90,6 +108,15 @@ public class MessageListenerContainer implements JMSListenerContainer {
}
@Override
+ public void stop() {
+ running = false;
+ ResourceCloser.close(consumer);
+ ResourceCloser.close(session);
+ consumer = null;
+ session = null;
+ }
+
+ @Override
public void shutdown() {
stop();
ResourceCloser.close(connection);
@@ -99,7 +126,7 @@ public class MessageListenerContainer implements JMSListenerContainer {
@Override
public void onMessage(final Message message) {
- executor.execute(new Runnable() {
+ getExecutor().execute(new Runnable() {
@Override
public void run() {
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/TestReceiver.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/TestReceiver.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/TestReceiver.java
index 24a0bd2..fed9b29 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/TestReceiver.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/TestReceiver.java
@@ -29,6 +29,9 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
+/**
+ * Receiver for integration tests. It simulates the server side of the service
+ */
public class TestReceiver {
private ConnectionFactory connectionFactory;
private String receiveQueueName;
@@ -37,6 +40,12 @@ public class TestReceiver {
private Throwable ex;
private boolean forceMessageIdAsCorrelationId;
+ /**
+ *
+ * @param connectionFactory
+ * @param receiveQueueName listen on this queue
+ * @param forceMessageIdAsCorrelationId force the usage of messageId even if correlationId is set
+ */
public TestReceiver(ConnectionFactory connectionFactory,
String receiveQueueName,
boolean forceMessageIdAsCorrelationId) {
@@ -73,7 +82,7 @@ public class TestReceiver {
}
}
- private void receiveAndRespondWithMessageIdAsCorrelationId() {
+ private void receiveAndRespond() {
ResourceCloser closer = new ResourceCloser();
try {
Connection connection = closer.register(connectionFactory.createConnection());
@@ -81,8 +90,9 @@ public class TestReceiver {
Session session = closer.register(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
MessageConsumer consumer = closer.register(session.createConsumer(session
.createQueue(receiveQueueName)));
- final javax.jms.Message inMessage = consumer.receive(1000);
+ final javax.jms.Message inMessage = consumer.receive(10000);
if (inMessage == null) {
+ System.out.println("TestReceiver timed out");
throw new RuntimeException("No message received on destination " + receiveQueueName);
}
requestMessageId = inMessage.getJMSMessageID();
@@ -96,7 +106,7 @@ public class TestReceiver {
if (replyDest != null) {
final MessageProducer producer = closer
.register(session.createProducer(replyDest));
- System.out.println("Sending reply to " + replyDest);
+ System.out.println("Sending reply with correlation id " + correlationId + " to " + replyDest);
producer.send(replyMessage);
}
} catch (Throwable e) {
@@ -110,7 +120,7 @@ public class TestReceiver {
drainQueue();
Executors.newSingleThreadExecutor().execute(new Runnable() {
public void run() {
- receiveAndRespondWithMessageIdAsCorrelationId();
+ receiveAndRespond();
}
});
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
index d133c91..18402a7 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/AbstractJMSTester.java
@@ -85,6 +85,9 @@ public abstract class AbstractJMSTester extends Assert {
protected EndpointInfo setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {
URL wsdlUrl = getClass().getResource(wsdl);
+ if (wsdlUrl == null) {
+ throw new IllegalArgumentException("Wsdl file not found on class path " + wsdl);
+ }
String wsdlURL = wsdlUrl.toString();
assertNotNull(wsdlUrl);
EmbeddedJMSBrokerLauncher.updateWsdlExtensors(bus, wsdlURL);
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
index 976a2d5..04ac878 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSDestinationTest.java
@@ -25,6 +25,7 @@ import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
+import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -116,14 +117,10 @@ public class JMSDestinationTest extends AbstractJMSTester {
.getMessageSelector());
assertEquals("Can't get the right DurableSubscriberName", "cxf_subscriber", jmsConfig
.getDurableSubscriptionName());
-
+
assertEquals("The receiveTimeout should be set", jmsConfig.getReceiveTimeout().longValue(), 1500L);
- assertEquals("The concurrentConsumer should be set", jmsConfig.getConcurrentConsumers(), 3);
- assertEquals("The maxConcurrentConsumer should be set", jmsConfig.getMaxConcurrentConsumers(), 5);
assertEquals("The maxSuspendedContinuations should be set",
jmsConfig.getMaxSuspendedContinuations(), 2);
- assertTrue("The acceptMessagesWhileStopping should be set to true",
- jmsConfig.isAcceptMessagesWhileStopping());
assertNotNull("The connectionFactory should not be null", jmsConfig.getConnectionFactory());
assertTrue("Should get the instance of ActiveMQConnectionFactory",
jmsConfig.getConnectionFactory() instanceof ActiveMQConnectionFactory);
@@ -146,6 +143,8 @@ public class JMSDestinationTest extends AbstractJMSTester {
"HelloWorldQueueBinMsgService", "HelloWorldQueueBinMsgPort");
JMSDestination destination = setupJMSDestination(ei);
+ ConnectionFactory cf = destination.getJmsConfig().getConnectionFactory();
+ assertNotNull("ConnectionFactory should not be null", cf);
assertEquals("Can't get the right DurableSubscriberName", "CXF_subscriber", destination
.getJmsConfig().getDurableSubscriptionName());
@@ -220,7 +219,6 @@ public class JMSDestinationTest extends AbstractJMSTester {
EndpointInfo ei = setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
"HWStaticReplyQBinMsgService", "HWStaticReplyQBinMsgPort");
JMSConduit conduit = setupJMSConduit(ei, true);
- System.out.println(conduit.getJmsConfig().getReplyDestination());
Message outMessage = new MessageImpl();
setupMessageHeader(outMessage);
JMSDestination destination = setupJMSDestination(ei);
@@ -235,7 +233,6 @@ public class JMSDestinationTest extends AbstractJMSTester {
/* 2. Test that replyTo destination set in WSDL IS used
* in spec non-compliant mode */
- conduit.getJmsConfig().setEnforceSpec(false);
sendOneWayMessage(conduit, outMessage);
waitForReceiveDestMessage();
assertTrue("The destination should have got the message ", destMessage != null);
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/OldConfigTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/OldConfigTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/OldConfigTest.java
index 5790906..575659b 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/OldConfigTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/OldConfigTest.java
@@ -20,7 +20,6 @@
package org.apache.cxf.transport.jms;
import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.jms.uri.JMSEndpoint;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,9 +37,10 @@ public class OldConfigTest extends AbstractJMSTester {
EndpointInfo ei = setupServiceInfo("http://cxf.apache.org/hello_world_jms", "/wsdl/jms_test.wsdl",
"HelloWorldService", "HelloWorldPort");
JMSOldConfigHolder holder = new JMSOldConfigHolder();
- JMSEndpoint endpoint = holder.getExtensorsAndConfig(bus, ei, target, false);
- holder.configureEndpoint(false, endpoint);
- Assert.assertEquals("User name does not match." , "testUser", endpoint.getUsername());
- Assert.assertEquals("Password does not match." , "testPassword", endpoint.getPassword());
+ JMSConfiguration config = holder.createJMSConfigurationFromEndpointInfo(bus, ei, target, false);
+ String username = config.getJndiConfig().getConnectionUserName();
+ String password = config.getJndiConfig().getConnectionPassword();
+ Assert.assertEquals("User name does not match." , "testUser", username);
+ Assert.assertEquals("Password does not match." , "testPassword", password);
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
new file mode 100644
index 0000000..fa4d4ff
--- /dev/null
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/MyBeanLocator.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.transport.jms.uri;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
+
+public class MyBeanLocator implements ConfiguredBeanLocator {
+ ConfiguredBeanLocator cbl;
+ Map<String, Object> registry = new HashMap<String, Object>();
+
+ public MyBeanLocator(ConfiguredBeanLocator cbl) {
+ this.cbl = cbl;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getBeanOfType(String name, Class<T> type) {
+ if (registry.containsKey(name)) {
+ return (T)registry.get(name);
+ } else {
+ return cbl.getBeanOfType(name, type);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
+ List<T> result = new ArrayList<T>();
+ for (String name : registry.keySet()) {
+ Object bean = registry.get(name);
+ if (type == registry.get(name).getClass()) {
+ result.add((T)bean);
+ }
+ }
+ return result;
+ }
+
+ public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
+ return cbl.loadBeansOfType(type, listener);
+
+ }
+ public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
+ return cbl.hasConfiguredPropertyValue(beanName, propertyName, value);
+ }
+
+ public List<String> getBeanNamesOfType(Class<?> type) {
+ return cbl.getBeanNamesOfType(type);
+ }
+ public boolean hasBeanOfName(String name) {
+ return cbl.hasBeanOfName(name);
+ }
+
+ public void register(String name, Object object) {
+ registry.put(name, object);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/URIConfiguredConduitTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/URIConfiguredConduitTest.java b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/URIConfiguredConduitTest.java
index b9edfb2..84cebb7 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/URIConfiguredConduitTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/URIConfiguredConduitTest.java
@@ -20,9 +20,10 @@ package org.apache.cxf.transport.jms.uri;
import javax.jms.ConnectionFactory;
-import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.configuration.ConfiguredBeanLocator;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.ExchangeImpl;
import org.apache.cxf.message.Message;
@@ -47,37 +48,58 @@ public class URIConfiguredConduitTest {
private static final String BROKER_URI = "vm://localhost?broker.persistent=false";
private ConnectionFactory connectionFactory;
+ private enum SyncType {
+ sync,
+ async
+ };
+
@Test
public void testSendReceive() throws Exception {
- sendAndReceive(true, "testreply");
+ sendAndReceive(SyncType.sync,
+ "jms:jndi:dynamicQueues/"
+ + SERVICE_QUEUE
+ + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ + "&replyToName=dynamicQueues/testreply"
+ + "&messageType=text"
+ + "&jndiConnectionFactoryName=ConnectionFactory"
+ + "&jndiURL=" + BROKER_URI);
}
-
- public void sendAndReceive(boolean synchronous, String replyDestination) throws Exception {
+
+ @Test
+ public void testSendReceiveCFFromContext() throws Exception {
+ sendAndReceive(SyncType.sync, "jms:queue:" + SERVICE_QUEUE + "?replyToName=testreply"
+ + "&messageType=text"
+ + "&receiveTimeout=10000"
+ + "&jndiConnectionFactoryName=ConnectionFactory");
+ }
+
+ public void sendAndReceive(SyncType syncType, String address) throws Exception {
BusFactory bf = BusFactory.newInstance();
Bus bus = bf.createBus();
BusFactory.setDefaultBus(bus);
- EndpointReferenceType target = new EndpointReferenceType();
- connectionFactory = new PooledConnectionFactory(BROKER_URI);
- TestReceiver receiver = new TestReceiver(connectionFactory, SERVICE_QUEUE, true);
+ // Register bean locator for cf lookup
+ ConfiguredBeanLocator cbl = bus.getExtension(ConfiguredBeanLocator.class);
+ MyBeanLocator registry = new MyBeanLocator(cbl);
+ bus.setExtension(registry, ConfiguredBeanLocator.class);
+
+ connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
+ registry.register("ConnectionFactory", connectionFactory);
+ TestReceiver receiver = new TestReceiver(connectionFactory, SERVICE_QUEUE, false);
receiver.runAsync();
- JMSOldConfigHolder holder = new JMSOldConfigHolder();
EndpointInfo ei = new EndpointInfo();
- String address = "jms:jndi:dynamicQueues/" + SERVICE_QUEUE
- + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- + "&replyToName=dynamicQueues/" + replyDestination
- + "&messageType=text"
- + "&jndiConnectionFactoryName=ConnectionFactory"
- + "&jndiURL=" + BROKER_URI;
ei.setAddress(address);
- JMSConfiguration jmsConfig = holder.createJMSConfigurationFromEndpointInfo(bus, ei , null, true);
- JMSConduit conduit = new JMSConduit(target, jmsConfig, bus);
+ JMSOldConfigHolder holder = new JMSOldConfigHolder();
+ JMSConfiguration jmsConfig = holder.createJMSConfigurationFromEndpointInfo(bus, ei, null, true);
+ JMSConduit conduit = new JMSConduit(new EndpointReferenceType(), jmsConfig, bus);
+
Exchange exchange = new ExchangeImpl();
- exchange.setSynchronous(synchronous);
+ exchange.setSynchronous(syncType == SyncType.sync);
Message message = new MessageImpl();
exchange.setOutMessage(message);
conduit.sendExchange(exchange, "Request");
+
waitForAsyncReply(exchange);
receiver.close();
if (exchange.getInMessage() == null) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/rt/transports/jms/src/test/resources/jms_test_config.xml
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/resources/jms_test_config.xml b/rt/transports/jms/src/test/resources/jms_test_config.xml
index b195b5d..cff8911 100644
--- a/rt/transports/jms/src/test/resources/jms_test_config.xml
+++ b/rt/transports/jms/src/test/resources/jms_test_config.xml
@@ -70,8 +70,5 @@
p:pubSubDomain="false"
p:usingEndpointInfo="false"
p:receiveTimeout="1500"
- p:concurrentConsumers="3"
- p:maxConcurrentConsumers="5"
- p:maxSuspendedContinuations="2"
- p:acceptMessagesWhileStopping="true"/>
+ p:maxSuspendedContinuations="2"/>
</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
index e125406..33adc9b 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/jms/testsuite/testcases/SoapJmsSpecTest.java
@@ -223,7 +223,7 @@ public class SoapJmsSpecTest extends AbstractBusClientServerTestBase {
@Test
public void testReplyToConfig() throws Exception {
- JMSEndpoint endpoint = new JMSEndpoint();
+ JMSEndpoint endpoint = new JMSEndpoint("");
endpoint.setJndiInitialContextFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
endpoint.setJndiURL(broker.getBrokerURL());
endpoint.setJndiConnectionFactoryName("ConnectionFactory");
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
index aada80c..d886cff 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
@@ -60,7 +60,6 @@ import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
import org.apache.cxf.transport.jms.AddressType;
-import org.apache.cxf.transport.jms.JMSConduit;
import org.apache.cxf.transport.jms.JMSConstants;
import org.apache.cxf.transport.jms.JMSMessageHeadersType;
import org.apache.cxf.transport.jms.JMSNamingPropertyType;
@@ -542,8 +541,6 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase {
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays(true);
requestEndpoint = Endpoint.publish("", requestServant);
- Client client = ClientProxy.getClient(greeter);
- ((JMSConduit)client.getConduit()).getJmsConfig().setEnforceSpec(true);
BindingProvider bp = (BindingProvider)greeter;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/jms_test_config.xml
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/jms_test_config.xml b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/jms_test_config.xml
index 6906f33..9f2e373 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/jms_test_config.xml
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/continuations/jms_test_config.xml
@@ -28,8 +28,6 @@
p:connectionFactory-ref="jmsConnectionFactory"
p:targetDestination="test.jmstransport.text"
p:replyDestination="test.jmstransport.text.reply"
- p:concurrentConsumers="1"
- p:maxConcurrentConsumers="1"
p:usingEndpointInfo="false"/>
<jms:destination name="{http://cxf.apache.org/systest/jaxws}HelloContinuationPort.jms-destination">
<jms:jmsConfig-ref>jmsConf2</jms:jmsConfig-ref>
@@ -39,9 +37,6 @@
p:targetDestination="test.jmstransport.text"
p:replyDestination="test.jmstransport.text.reply"
p:timeToLive="10000"
- p:concurrentConsumers="1"
- p:maxConcurrentConsumers="1"
p:maxSuspendedContinuations="1"
- p:cacheLevel="2"
p:usingEndpointInfo="false"/>
</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/98347e4e/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
index e87dd8f..0db5f22 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/tx/JMSTransactionClientServerTest.java
@@ -68,7 +68,6 @@ public class JMSTransactionClientServerTest extends AbstractBusClientServerTestB
jmsConfig.setTargetDestination("greeter.queue.noaop");
jmsConfig.setSessionTransacted(true);
jmsConfig.setPubSubDomain(false);
- jmsConfig.setCacheLevel(3);
JMSConfigFeature jmsConfigFeature = new JMSConfigFeature();
jmsConfigFeature.setJmsConfig(jmsConfig);