cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1343561 - in /cxf/trunk: rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/ rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/ rt/transports/jms/s...
Date Tue, 29 May 2012 07:08:48 GMT
Author: ningjiang
Date: Tue May 29 07:08:47 2012
New Revision: 1343561

URL: http://svn.apache.org/viewvc?rev=1343561&view=rev
Log:
CXF-4345 Supports to set the messageType from the jms URI

Modified:
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointParser.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSURIConstants.java
    cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms-uri.xsd
    cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
    cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSOldConfigHolder.java
Tue May 29 07:08:47 2012
@@ -231,7 +231,12 @@ public class JMSOldConfigHolder {
                 if (runtimePolicy.isSetMessageType()) {
                     jmsConfig.setMessageType(runtimePolicy.getMessageType().value());
                 } else if (address == null) {
-                    jmsConfig.setMessageType(JMSConstants.BYTE_MESSAGE_TYPE);
+                    if (endpoint.getMessageType() == null) {
+                        // Using the byte message type by default
+                        jmsConfig.setMessageType(JMSConstants.BYTE_MESSAGE_TYPE);
+                    } else {
+                        jmsConfig.setMessageType(endpoint.getMessageType().value());
+                    }
                 }
             }
             jmsConfig.setPubSubDomain(pubSubDomain);

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/spec/JMSSpecConstants.java
Tue May 29 07:08:47 2012
@@ -40,7 +40,7 @@ public final class JMSSpecConstants {
     public static final String JNDIINITIALCONTEXTFACTORY_PARAMETER_NAME = "jndiInitialContextFactory";
     public static final String JNDIURL_PARAMETER_NAME = "jndiURL";
     public static final String JNDICONTEXTPARAMETER_PARAMETER_NAME = "jndiContextParameter";
-
+    
     // JMS Message Header properties
     public static final String DELIVERYMODE_PARAMETER_NAME = "deliveryMode";
     // Expiration Time
@@ -68,7 +68,6 @@ public final class JMSSpecConstants {
     public static final String CONTENTENCODING_FIELD = SOAP_JMS_PREFIX + CONTENTENCODING_PARAMETER_NAME;
     public static final String ISFAULT_FIELD = SOAP_JMS_PREFIX + ISFAULT_PARAMETER_NAME;
     
-    //
     public static final String JMS_MESSAGE_TYPE = "JMSMessageType";
     public static final String TARGET_SERVICE_IN_REQUESTURI = "target.service.inrequesturi";
     public static final String MALFORMED_REQUESTURI = "malformed.requesturi";

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
Tue May 29 07:08:47 2012
@@ -22,6 +22,8 @@ package org.apache.cxf.transport.jms.uri
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+
 /**
  * 
  */
@@ -47,7 +49,10 @@ public class JMSEndpoint extends JMSEndp
             + ":" + destinationName;
         boolean first = true;
         for (String key : parameters.keySet()) {
-            if ("targetService".equals(key)) {
+            // now we just skip the MESSAGE_TYPE_PARAMETER_NAME 
+            // and TARGETSERVICE_PARAMETER_NAME
+            if (JMSSpecConstants.TARGETSERVICE_PARAMETER_NAME.equals(key) 
+                || JMSURIConstants.MESSAGE_TYPE_PARAMETER_NAME.equals(key)) {
                 continue;
             }
             String value = parameters.get(key);

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointParser.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointParser.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpointParser.java
Tue May 29 07:08:47 2012
@@ -88,6 +88,8 @@ public final class JMSEndpointParser {
                                                 JMSURIConstants.JNDIINITIALCONTEXTFACTORY_PARAMETER_NAME);
         String jndiUrl = getAndRemoveParameter(parameters, JMSURIConstants.JNDIURL_PARAMETER_NAME);
 
+        String messageType = getAndRemoveParameter(parameters, JMSURIConstants.MESSAGE_TYPE_PARAMETER_NAME);
+        
         if (deliveryMode != null) {
             endpoint.setDeliveryMode(DeliveryModeType.valueOf(deliveryMode));
         }
@@ -116,6 +118,9 @@ public final class JMSEndpointParser {
         if (jndiUrl != null) {
             endpoint.setJndiURL(jndiUrl);
         }
+        if (messageType != null) {
+            endpoint.setMessageType(MessageType.fromValue(messageType));
+        }
 
         for (String key : parameters.keySet()) {
             String value = parameters.get(key);

Modified: cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSURIConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSURIConstants.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSURIConstants.java
(original)
+++ cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSURIConstants.java
Tue May 29 07:08:47 2012
@@ -44,6 +44,8 @@ public final class JMSURIConstants {
     public static final String TIMETOLIVE_PARAMETER_NAME = "timeToLive";
     public static final String PRIORITY_PARAMETER_NAME = "priority";
     public static final String REPLYTONAME_PARAMETER_NAME = "replyToName";
+    // The new configuration to set the message type of jms message body
+    public static final String MESSAGE_TYPE_PARAMETER_NAME = "messageType";
 
     // default parameters
     public static final DeliveryModeType DELIVERYMODE_DEFAULT = DELIVERYMODE_PERSISTENT;

Modified: cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms-uri.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms-uri.xsd?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms-uri.xsd (original)
+++ cxf/trunk/rt/transports/jms/src/main/resources/schemas/wsdl/jms-uri.xsd Tue May 29 07:08:47
2012
@@ -36,6 +36,14 @@
 			<xs:enumeration value="NON_PERSISTENT" />
 		</xs:restriction>
 	</xs:simpleType>
+	
+	<xs:simpleType name="messageType">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="byte" />
+		    <xs:enumeration value="binary" />
+			<xs:enumeration value="text" />
+		</xs:restriction>
+	</xs:simpleType>
 
 	<xs:simpleType name="priorityType">
 		<xs:restriction base="xs:int">
@@ -61,6 +69,7 @@
 		<xs:attribute name="jmsVariant" type="xs:string" />
 		<xs:attribute name="destinationName" type="xs:string" />
 		<xs:attribute name="deliveryMode" type="jms:deliveryModeType" />
+		<xs:attribute name="messageType" type="jms:messageType" default="byte"/>
 		<xs:attribute name="timeToLive" type="xs:long" />
 		<xs:attribute name="priority" type="jms:priorityType" />
 		<xs:attribute name="replyToName" type="xs:string" />

Modified: cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
(original)
+++ cxf/trunk/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/uri/JMSEndpointTest.java
Tue May 29 07:08:47 2012
@@ -21,7 +21,6 @@ package org.apache.cxf.transport.jms.uri
 
 import java.util.Map;
 
-
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -131,8 +130,8 @@ public class JMSEndpointTest extends Ass
                                                + "&timeToLive=100" + "&priority=5"
+ "&replyToName=foo.bar2");
         assertTrue(endpoint instanceof JMSQueueEndpoint);
         assertEquals(endpoint.getParameters().size(), 0);
-        assertEquals(endpoint.getDeliveryMode(),
-                     JMSURIConstants.DELIVERYMODE_NON_PERSISTENT);
+        assertEquals(endpoint.getDeliveryMode().toString(),
+                     JMSURIConstants.DELIVERYMODE_NON_PERSISTENT.toString());
         assertEquals(endpoint.getTimeToLive(), 100);
         assertEquals(endpoint.getPriority(), 5);
         assertEquals(endpoint.getReplyToName(), "foo.bar2");
@@ -155,13 +154,29 @@ public class JMSEndpointTest extends Ass
         assertTrue(requestUri.startsWith("jms:jndi:Foo.Bar?"));
         assertTrue(requestUri.contains("foo=bar"));
         assertTrue(requestUri.contains("foo2=bar2"));
-        // Cheching what's the request uri should not have
+        // Checking what's the request uri should not have
         assertFalse(requestUri.contains("jndiInitialContextFactory"));
         assertFalse(requestUri.contains("targetService"));
         assertFalse(requestUri.contains("replyToName"));
         assertFalse(requestUri.contains("priority=3"));
     }
     
+    @Test
+    public void testRequestUriWithMessageType() throws Exception {
+        JMSEndpoint endpoint = resolveEndpoint("jms:queue:Foo.Bar?messageType=text");
+        assertTrue(endpoint instanceof JMSQueueEndpoint);
+        assertEquals("text", endpoint.getMessageType().value());
+        
+        endpoint = resolveEndpoint("jms:queue:Foo.Bar");
+        assertTrue(endpoint instanceof JMSQueueEndpoint);
+        assertEquals("byte", endpoint.getMessageType().value());
+        
+        endpoint = resolveEndpoint("jms:queue:Foo.Bar?messageType=binary");
+        assertTrue(endpoint instanceof JMSQueueEndpoint);
+        assertEquals("binary", endpoint.getMessageType().value());
+        
+    }
+    
     private JMSEndpoint resolveEndpoint(String uri) throws Exception {
         return JMSEndpointParser.createEndpoint(uri);
     }

Modified: cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java?rev=1343561&r1=1343560&r2=1343561&view=diff
==============================================================================
--- cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
(original)
+++ cxf/trunk/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
Tue May 29 07:08:47 2012
@@ -1194,11 +1194,25 @@ public class JMSClientServerTest extends
     
     @Test 
     public void testSpecNoWsdlService() throws Exception {
+        specNoWsdlService(null);
+    }
+    
+    @Test
+    public void testSpecNoWsdlServiceWithDifferentMessageType() throws Exception {
+        specNoWsdlService("text");
+        specNoWsdlService("byte");
+        specNoWsdlService("binary");
+    }
+    
+    private void specNoWsdlService(String messageType) throws Exception {
         String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue3"
             + "?jndiInitialContextFactory"
             + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
             + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=tcp://localhost:"
             + JMS_PORT;
+        if (messageType != null) {
+            address = address + "&messageType=" + messageType;
+        }
 
         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
         factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);



Mime
View raw message