Skip to content
Permalink
Browse files
CXF-5543 Refactoring JMSEndpoint to not be generated from xsd, not us…
…ing vm activemq for tests as it is sometimes using kahadb

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1568249 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cschneider committed Feb 14, 2014
1 parent fa17e74 commit 080bd762e7e09f7fe1d1fa2d7c55bc6626f539d9
Show file tree
Hide file tree
Showing 27 changed files with 854 additions and 1,171 deletions.
@@ -157,14 +157,6 @@
<extensionArg>-Xdv</extensionArg>
</extensionArgs>
</xsdOption>
<xsdOption>
<xsd>${basedir}/src/main/resources/schemas/wsdl/jms-uri.xsd</xsd>
<bindingFile>${basedir}/src/main/resources/schemas/wsdl/jms-uri.xjb</bindingFile>
<catalog>${basedir}/src/main/build-resources/catalog.cat</catalog>
<deleteDirs>
<deleteDir>${basedir}/target/generated/src/main/java/org/apache/cxf/wsdl</deleteDir>
</deleteDirs>
</xsdOption>
<xsdOption>
<xsd>${basedir}/src/main/resources/schemas/wsdl/spec/jms-spec-wsdl.xsd</xsd>
<bindingFile>${basedir}/src/main/resources/schemas/wsdl/spec/jms-spec-wsdl.xjb</bindingFile>
@@ -49,7 +49,7 @@ public class JMSConfiguration {
private boolean messageIdEnabled = true;
private boolean messageTimestampEnabled = true;
private boolean pubSubNoLocal;
private Long clientReceiveTimeout = 0L;
private Long clientReceiveTimeout = 60000L;
private Long serverReceiveTimeout;
private boolean explicitQosEnabled;
private int deliveryMode = Message.DEFAULT_DELIVERY_MODE;
@@ -201,12 +201,12 @@ public static JMSListenerContainer createTargetDestinationListener(EndpointInfo
Session session = null;
try {
Connection connection = createConnection(jmsConfig);
connection.start();
session = connection.createSession(jmsConfig.isSessionTransacted(), Session.AUTO_ACKNOWLEDGE);
Destination destination = jmsConfig.getTargetDestination(session);
MessageListenerContainer container = new MessageListenerContainer(connection, destination, listenerHandler);
container.setMessageSelector(jmsConfig.getMessageSelector());
container.start();
connection.start();
return container;
} catch (JMSException e) {
throw JMSUtil.convertJmsException(e);
@@ -51,7 +51,6 @@
import org.apache.cxf.security.SecurityContext;
import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
import org.apache.cxf.transport.jms.uri.JMSEndpoint;
import org.apache.cxf.transport.jms.uri.JMSEndpointParser;
import org.apache.cxf.transport.jms.util.JMSMessageConverter;
import org.apache.cxf.transport.jms.util.JMSUtil;

@@ -203,8 +202,8 @@ private static void populateIncomingMessageProperties(Message jmsMessage,
inMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
}
try {
JMSEndpoint endpoint = JMSEndpointParser.createEndpoint(jmsMessage
.getStringProperty(JMSSpecConstants.REQUESTURI_FIELD));
String requestURI = jmsMessage.getStringProperty(JMSSpecConstants.REQUESTURI_FIELD);
JMSEndpoint endpoint = new JMSEndpoint(requestURI);
if (endpoint.getParameter(JMSSpecConstants.TARGETSERVICE_PARAMETER_NAME) != null) {
headers.put(JMSSpecConstants.TARGET_SERVICE_IN_REQUESTURI,
Collections.singletonList("true"));
@@ -30,15 +30,12 @@

import org.apache.cxf.Bus;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.Configurer;
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.spec.JMSSpecConstants;
import org.apache.cxf.transport.jms.uri.JMSEndpoint;
import org.apache.cxf.transport.jms.uri.JMSEndpointParser;
import org.apache.cxf.transport.jms.uri.JMSURIConstants;
import org.apache.cxf.transport.jms.util.JMSDestinationResolver;
import org.apache.cxf.transport.jms.util.JndiHelper;
import org.apache.cxf.transport.jms.wsdl.DeliveryModeType;
@@ -131,9 +128,7 @@ protected JMSEndpoint getExtensorsAndConfig(Bus bus,
JMSEndpoint endpoint = null;
String adr = target == null ? endpointInfo.getAddress() : target.getAddress().getValue();
try {
endpoint = StringUtils.isEmpty(adr) || "jms://".equals(adr) || !adr.startsWith("jms")
? new JMSEndpoint()
: JMSEndpointParser.createEndpoint(adr);
endpoint = new JMSEndpoint(adr);
} catch (RuntimeException ex) {
throw ex;
} catch (Exception e) {
@@ -195,21 +190,16 @@ protected JMSConfiguration configureEndpoint(boolean isConduit, JMSEndpoint endp
jmsConfig = new JMSConfiguration();
}

if (endpoint.isSetDeliveryMode()) {
int deliveryMode = endpoint.getDeliveryMode()
.equals(JMSURIConstants.DELIVERYMODE_PERSISTENT)
? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
jmsConfig.setDeliveryMode(deliveryMode);
}
int deliveryMode = endpoint.getDeliveryMode()
== org.apache.cxf.transport.jms.uri.JMSEndpoint.DeliveryModeType.PERSISTENT
? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
jmsConfig.setDeliveryMode(deliveryMode);

if (endpoint.isSetPriority()) {
int priority = endpoint.getPriority();
jmsConfig.setPriority(priority);
}
jmsConfig.setPriority(endpoint.getPriority());

if (jmsConfig.isUsingEndpointInfo()) {
JndiHelper jt = new JndiHelper(JMSOldConfigHolder.getInitialContextEnv(endpoint));
boolean pubSubDomain = endpoint.getJmsVariant().contains(JMSURIConstants.TOPIC);
boolean pubSubDomain = endpoint.getJmsVariant().contains(JMSEndpoint.TOPIC);
JNDIConfiguration jndiConfig = new JNDIConfiguration();
jndiConfig.setJndiConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
jmsConfig.setJndiTemplate(jt);
@@ -218,9 +208,7 @@ protected JMSConfiguration configureEndpoint(boolean isConduit, JMSEndpoint endp
jndiConfig.setConnectionPassword(endpoint.getPassword());

jmsConfig.setJndiConfig(jndiConfig);
if (endpoint.isSetReconnectOnException()) {
jmsConfig.setReconnectOnException(endpoint.isReconnectOnException());
}
jmsConfig.setReconnectOnException(endpoint.isReconnectOnException());
jmsConfig.setDurableSubscriptionName(serverBehavior.getDurableSubscriberName());
jmsConfig.setExplicitQosEnabled(true);
if (jmsConfig.getMessageSelector() == null) {
@@ -262,17 +250,11 @@ protected JMSConfiguration configureEndpoint(boolean isConduit, JMSEndpoint endp
if (sessionPool.isSetLowWaterMark()) {
jmsConfig.setConcurrentConsumers(sessionPool.getLowWaterMark());
}
if (endpoint.isSetTimeToLive()) {
long timeToLive = endpoint.getTimeToLive();
jmsConfig.setTimeToLive(timeToLive);
}
if (endpoint.isSetUseJMS11()) {
LOG.log(Level.WARNING, "Use of jms:endpoint[@useJms11] is no longer supported");
}
jmsConfig.setTimeToLive(endpoint.getTimeToLive());
if (serverBehavior.isSetTransactional()) {
jmsConfig.setSessionTransacted(serverBehavior.isTransactional());
}
boolean useJndi = endpoint.getJmsVariant().contains(JMSURIConstants.JNDI);
boolean useJndi = endpoint.getJmsVariant().contains(JMSEndpoint.JNDI);
if (useJndi) {
// Setup Destination jndi destination resolver
final JMSDestinationResolver jndiDestinationResolver = new JMSDestinationResolver();
@@ -314,9 +296,9 @@ private static void setReplyDestination(JMSConfiguration jmsConfig, JMSEndpoint
private static void mapAddressToEndpoint(AddressType address, JMSEndpoint endpoint) {
boolean pubSubDomain = DestinationStyleType.TOPIC == address.getDestinationStyle();
if (address.isSetDestinationStyle()) {
endpoint.setJmsVariant(pubSubDomain ? JMSURIConstants.TOPIC : JMSURIConstants.QUEUE);
endpoint.setJmsVariant(pubSubDomain ? JMSEndpoint.TOPIC : JMSEndpoint.QUEUE);
} else {
endpoint.setJmsVariant(JMSURIConstants.QUEUE);
endpoint.setJmsVariant(JMSEndpoint.QUEUE);
}
if (address.isSetJndiConnectionFactoryName()) {
endpoint.setJndiConnectionFactoryName(address.getJndiConnectionFactoryName());
@@ -335,7 +317,7 @@ private static void mapAddressToEndpoint(AddressType address, JMSEndpoint endpoi
}
boolean useJndi = address.isSetJndiDestinationName();
if (useJndi) {
endpoint.setJmsVariant(pubSubDomain ? JMSURIConstants.JNDI_TOPIC : JMSURIConstants.JNDI);
endpoint.setJmsVariant(pubSubDomain ? JMSEndpoint.JNDI_TOPIC : JMSEndpoint.JNDI);
endpoint.setDestinationName(address.getJndiDestinationName());
endpoint.setReplyToName(address.getJndiReplyDestinationName());
} else {
@@ -366,22 +348,22 @@ private void retrieveWSDLInformation(JMSEndpoint endpoint, EndpointInfo ei) {
jndiContextParameterType.getValue().trim());
}

if (!endpoint.isSetJndiConnectionFactoryName()) {
if (endpoint.getJndiConnectionFactoryName() == null) {
JndiConnectionFactoryNameType jndiConnectionFactoryNameType = getWSDLExtensor(
ei, JndiConnectionFactoryNameType.class);
if (jndiConnectionFactoryNameType != null) {
endpoint.setJndiConnectionFactoryName(jndiConnectionFactoryNameType.getValue().trim());
}
}
if (!endpoint.isSetJndiInitialContextFactory()) {
if (endpoint.getJndiInitialContextFactory() == null) {
JndiInitialContextFactoryType jndiInitialContextFactoryType =
getWSDLExtensor(ei, JndiInitialContextFactoryType.class);
if (jndiInitialContextFactoryType != null) {
endpoint.setJndiInitialContextFactory(jndiInitialContextFactoryType.getValue().trim());
}
}

if (!endpoint.isSetJndiURL()) {
if (endpoint.getJndiURL() == null) {
JndiURLType jndiURLType = getWSDLExtensor(ei, JndiURLType.class);
if (jndiURLType != null) {
endpoint.setJndiURL(jndiURLType.getValue().trim());
@@ -392,7 +374,7 @@ private void retrieveWSDLInformation(JMSEndpoint endpoint, EndpointInfo ei) {
DeliveryModeType deliveryModeType = getWSDLExtensor(ei, DeliveryModeType.class);
if (deliveryModeType != null) {
String deliveryMode = deliveryModeType.getValue().trim();
endpoint.setDeliveryMode(org.apache.cxf.transport.jms.uri.DeliveryModeType
endpoint.setDeliveryMode(org.apache.cxf.transport.jms.uri.JMSEndpoint.DeliveryModeType
.valueOf(deliveryMode));
}
}
@@ -404,21 +386,21 @@ private void retrieveWSDLInformation(JMSEndpoint endpoint, EndpointInfo ei) {
}
}

if (!endpoint.isSetTimeToLive()) {
if (endpoint.getTimeToLive() == 0) {
TimeToLiveType timeToLiveType = getWSDLExtensor(ei, TimeToLiveType.class);
if (timeToLiveType != null) {
endpoint.setTimeToLive(timeToLiveType.getValue());
}
}

if (!endpoint.isSetReplyToName()) {
if (endpoint.getReplyToName() == null) {
ReplyToNameType replyToNameType = getWSDLExtensor(ei, ReplyToNameType.class);
if (replyToNameType != null) {
endpoint.setReplyToName(replyToNameType.getValue());
}
}

if (!endpoint.isSetTopicReplyToName()) {
if (endpoint.getTopicReplyToName() == null) {
TopicReplyToNameType topicReplyToNameType = getWSDLExtensor(ei, TopicReplyToNameType.class);
if (topicReplyToNameType != null) {
endpoint.setTopicReplyToName(topicReplyToNameType.getValue());
@@ -449,10 +431,10 @@ public <T> T getWSDLExtensor(EndpointInfo ei, Class<T> cls) {

public static Properties getInitialContextEnv(JMSEndpoint endpoint) {
Properties env = new Properties();
if (endpoint.isSetJndiInitialContextFactory()) {
if (endpoint.getJndiInitialContextFactory() != null) {
env.put(Context.INITIAL_CONTEXT_FACTORY, endpoint.getJndiInitialContextFactory());
}
if (endpoint.isSetJndiURL()) {
if (endpoint.getJndiURL() != null) {
env.put(Context.PROVIDER_URL, endpoint.getJndiURL());
}
for (Map.Entry<String, String> ent : endpoint.getJndiParameters().entrySet()) {

0 comments on commit 080bd76

Please sign in to comment.