cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [5/7] cxf git commit: Move property handling to respective classes
Date Tue, 25 Apr 2017 15:06:09 GMT
Move property handling to respective classes


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/bc4cd1ed
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/bc4cd1ed
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/bc4cd1ed

Branch: refs/heads/master
Commit: bc4cd1ed8ea06ca7e0a05c5d2ee898bb937b3663
Parents: 62fd990
Author: Christian Schneider <chris@die-schneider.net>
Authored: Mon Apr 24 18:25:12 2017 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Apr 25 16:10:47 2017 +0200

----------------------------------------------------------------------
 .../transport/jms/JMSMessageHeadersType.java    | 36 ++++++++++++
 .../cxf/transport/jms/JMSMessageUtils.java      | 62 +-------------------
 .../cxf/transport/jms/JMSPropertyType.java      | 30 ++++++++++
 3 files changed, 67 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/bc4cd1ed/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageHeadersType.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageHeadersType.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageHeadersType.java
index 6224fe8..333f582 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageHeadersType.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageHeadersType.java
@@ -21,6 +21,11 @@ package org.apache.cxf.transport.jms;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+import org.apache.cxf.transport.jms.spec.JMSSpecConstants;
+
 //CHECKSTYLE:OFF
 public class JMSMessageHeadersType {
     protected List<JMSPropertyType> property;
@@ -289,5 +294,36 @@ public class JMSMessageHeadersType {
         return soapjmsIsFault;
     }
 
+    /**
+     * @param jmsMessage
+     * @param messageProperties
+     */
+    public void writeTo(Message jmsMessage)
+        throws JMSException {
+
+        setProp(jmsMessage, JMSSpecConstants.TARGETSERVICE_FIELD, soapjmsTargetService);
+        setProp(jmsMessage, JMSSpecConstants.BINDINGVERSION_FIELD, soapjmsBindingVersion);
+        setProp(jmsMessage, JMSSpecConstants.CONTENTTYPE_FIELD, soapjmsContentType);
+        setProp(jmsMessage, JMSSpecConstants.CONTENTENCODING_FIELD, soapjmsContentEncoding);
+        setProp(jmsMessage, JMSSpecConstants.SOAPACTION_FIELD, soapjmssoapAction);
+        setProp(jmsMessage, JMSSpecConstants.REQUESTURI_FIELD, soapjmsRequestURI);
+
+        if (isSetSOAPJMSIsFault()) {
+            jmsMessage.setBooleanProperty(JMSSpecConstants.ISFAULT_FIELD, isSOAPJMSIsFault());
+        }
+
+        if (isSetProperty()) {
+            for (JMSPropertyType prop : getProperty()) {
+                prop.writeTo(jmsMessage);
+            }
+        }
+    }
+    
+    private static void setProp(Message jmsMessage, String name, String value) throws JMSException
{
+        if (value != null) {
+            jmsMessage.setStringProperty(name, value);
+        }
+    }
+
 }
 //CHECKSTYLE:ON
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/bc4cd1ed/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageUtils.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageUtils.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageUtils.java
index 6ea346a..04a8e6c 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageUtils.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSMessageUtils.java
@@ -296,7 +296,7 @@ final class JMSMessageUtils {
         JMSMessageUtils.prepareJMSMessageHeaderProperties(messageProperties, outMessage,
jmsConfig);
         JMSMessageUtils.prepareJMSMessageProperties(messageProperties, outMessage,
                                                     jmsConfig.getTargetService(), jmsConfig.getRequestURI());
-        JMSMessageUtils.setJMSMessageProperties(jmsMessage, messageProperties);
+        messageProperties.writeTo(jmsMessage);
         jmsMessage.setJMSCorrelationID(correlationId);
         return jmsMessage;
     }
@@ -313,66 +313,6 @@ final class JMSMessageUtils {
     }
 
     /**
-     * @param jmsMessage
-     * @param messageProperties
-     */
-    static void setJMSMessageProperties(Message jmsMessage, JMSMessageHeadersType messageProperties)
-        throws JMSException {
-
-        if (messageProperties == null) {
-            return;
-        }
-
-        setProp(jmsMessage, JMSSpecConstants.TARGETSERVICE_FIELD, messageProperties.getSOAPJMSTargetService());
-        setProp(jmsMessage, JMSSpecConstants.BINDINGVERSION_FIELD, messageProperties.getSOAPJMSBindingVersion());
-        setProp(jmsMessage, JMSSpecConstants.CONTENTTYPE_FIELD, messageProperties.getSOAPJMSContentType());
-        setProp(jmsMessage, JMSSpecConstants.CONTENTENCODING_FIELD, messageProperties.getSOAPJMSContentEncoding());
-        setProp(jmsMessage, JMSSpecConstants.SOAPACTION_FIELD, messageProperties.getSOAPJMSSOAPAction());
-        setProp(jmsMessage, JMSSpecConstants.REQUESTURI_FIELD, messageProperties.getSOAPJMSRequestURI());
-
-        if (messageProperties.isSetSOAPJMSIsFault()) {
-            jmsMessage.setBooleanProperty(JMSSpecConstants.ISFAULT_FIELD, messageProperties
-                .isSOAPJMSIsFault());
-        }
-
-        if (messageProperties.isSetProperty()) {
-            for (JMSPropertyType prop : messageProperties.getProperty()) {
-                Object o = prop.getValue();
-                if (o != null) {
-                    Class<?> cls = o.getClass();
-                    if (cls == String.class) {
-                        jmsMessage.setStringProperty(prop.getName(), (String)o);
-                    } else if (cls == Integer.TYPE || cls == Integer.class) {
-                        jmsMessage.setIntProperty(prop.getName(), (Integer)o);
-                    } else if (cls == Double.TYPE || cls == Double.class) {
-                        jmsMessage.setDoubleProperty(prop.getName(), (Double)o);
-                    } else if (cls == Float.TYPE || cls == Float.class) {
-                        jmsMessage.setFloatProperty(prop.getName(), (Float)o);
-                    } else if (cls == Long.TYPE || cls == Long.class) {
-                        jmsMessage.setLongProperty(prop.getName(), (Long)o);
-                    } else if (cls == Boolean.TYPE || cls == Boolean.class) {
-                        jmsMessage.setBooleanProperty(prop.getName(), (Boolean)o);
-                    } else if (cls == Short.TYPE || cls == Short.class) {
-                        jmsMessage.setShortProperty(prop.getName(), (Short)o);
-                    } else if (cls == Byte.TYPE || cls == Byte.class) {
-                        jmsMessage.setShortProperty(prop.getName(), (Byte)o);
-                    } else {
-                        jmsMessage.setObjectProperty(prop.getName(), o);
-                    }
-                } else {
-                    jmsMessage.setStringProperty(prop.getName(), null);
-                }
-            }
-        }
-    }
-
-    private static void setProp(Message jmsMessage, String name, String value) throws JMSException
{
-        if (value != null) {
-            jmsMessage.setStringProperty(name, value);
-        }
-    }
-
-    /**
      * @param messageProperteis
      * @param outMessage
      * @param jmsConfig

http://git-wip-us.apache.org/repos/asf/cxf/blob/bc4cd1ed/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSPropertyType.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSPropertyType.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSPropertyType.java
index 36d25dc..cdaacfb 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSPropertyType.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSPropertyType.java
@@ -18,6 +18,9 @@
  */
 package org.apache.cxf.transport.jms;
 
+import javax.jms.JMSException;
+import javax.jms.Message;
+
 public class JMSPropertyType {
     private String name;
     private Object value;
@@ -34,5 +37,32 @@ public class JMSPropertyType {
     public Object getValue() {
         return value;
     }
+    
+    public void writeTo(Message jmsMessage) throws JMSException {
+        if (value == null) {
+            jmsMessage.setStringProperty(name, null);
+            return;
+        }
+        Class<?> cls = value.getClass();
+        if (cls == String.class) {
+            jmsMessage.setStringProperty(name, (String)value);
+        } else if (cls == Integer.TYPE || cls == Integer.class) {
+            jmsMessage.setIntProperty(name, (Integer)value);
+        } else if (cls == Double.TYPE || cls == Double.class) {
+            jmsMessage.setDoubleProperty(name, (Double)value);
+        } else if (cls == Float.TYPE || cls == Float.class) {
+            jmsMessage.setFloatProperty(name, (Float)value);
+        } else if (cls == Long.TYPE || cls == Long.class) {
+            jmsMessage.setLongProperty(name, (Long)value);
+        } else if (cls == Boolean.TYPE || cls == Boolean.class) {
+            jmsMessage.setBooleanProperty(name, (Boolean)value);
+        } else if (cls == Short.TYPE || cls == Short.class) {
+            jmsMessage.setShortProperty(name, (Short)value);
+        } else if (cls == Byte.TYPE || cls == Byte.class) {
+            jmsMessage.setShortProperty(name, (Byte)value);
+        } else {
+            jmsMessage.setObjectProperty(name, value);
+        }
+    }
 }
 


Mime
View raw message