cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [3/7] cxf git commit: Small refactoring of JMS property handling
Date Tue, 25 Apr 2017 15:06:07 GMT
Small refactoring of JMS property handling


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

Branch: refs/heads/master
Commit: 4a714ebe08842ad898343c55203f6cde4ccebf45
Parents: 7fb37af
Author: Christian Schneider <chris@die-schneider.net>
Authored: Mon Apr 24 16:38:32 2017 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Apr 25 16:10:47 2017 +0200

----------------------------------------------------------------------
 .../cxf/transport/jms/JMSMessageUtils.java      | 36 ++++++++------------
 .../cxf/transport/jms/JMSPropertyType.java      | 26 ++++----------
 .../cxf/transport/jms/JMSDestinationTest.java   |  4 +--
 .../cxf/systest/jms/JMSClientServerTest.java    |  8 ++---
 .../cxf/systest/jms/TwoWayJMSImplBase.java      |  4 +--
 .../systest/jms/security/TwoWayJMSImplBase.java |  4 +--
 6 files changed, 26 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4a714ebe/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 5e82e9c..31ba9f8 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
@@ -135,10 +135,7 @@ final class JMSMessageUtils {
         while (enm.hasMoreElements()) {
             String name = enm.nextElement();
             String val = message.getStringProperty(name);
-            JMSPropertyType prop = new JMSPropertyType();
-            prop.setName(name);
-            prop.setValue(val);
-            props.add(prop);
+            props.add(new JMSPropertyType(name, val));
 
             protHeaders.put(name, Collections.singletonList(val));
             if (name.equals(org.apache.cxf.message.Message.CONTENT_TYPE)
@@ -498,28 +495,25 @@ final class JMSMessageUtils {
         }
         if (headers != null) {
             for (Map.Entry<String, List<String>> ent : headers.entrySet()) {
-                JMSPropertyType prop = asJmsProperty(ent);
+                JMSPropertyType prop = asJmsProperty(ent.getKey(), ent.getValue());
                 messageProperties.getProperty().add(prop);
             }
         }
     }
 
-    private static JMSPropertyType asJmsProperty(Map.Entry<String, List<String>>
ent) {
-        JMSPropertyType prop = new JMSPropertyType();
-        prop.setName(ent.getKey());
-        if (ent.getValue().size() > 1) {
-            StringBuilder b = new StringBuilder();
-            for (String s : ent.getValue()) {
-                if (b.length() > 0) {
-                    b.append(',');
-                }
-                b.append(s);
+    private static JMSPropertyType asJmsProperty(String key, List<String> value) {
+        return new JMSPropertyType(key, join(value, ','));
+    }
+    
+    private static String join(List<String> valueList, char seperator) {
+        StringBuilder b = new StringBuilder();
+        for (String s : valueList) {
+            if (b.length() > 0) {
+                b.append(seperator);
             }
-            prop.setValue(b.toString());
-        } else {
-            prop.setValue(ent.getValue().get(0));
+            b.append(s);
         }
-        return prop;
+        return b.toString();
     }
 
     private static String getSoapAction(JMSMessageHeadersType messageProperties,
@@ -558,9 +552,7 @@ final class JMSMessageUtils {
                                                   String key) {
         Object value = message.get(key);
         if (value != null) {
-            JMSPropertyType prop = new JMSPropertyType();
-            prop.setName(key);
-            prop.setValue(value.toString());
+            JMSPropertyType prop = new JMSPropertyType(key, value.toString());
             messageProperties.getProperty().add(prop);
         }
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a714ebe/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 3d9a8f5..36d25dc 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
@@ -19,32 +19,20 @@
 package org.apache.cxf.transport.jms;
 
 public class JMSPropertyType {
-    protected String name;
-    protected Object value;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
+    private String name;
+    private Object value;
+    
+    public JMSPropertyType(String name, Object value) {
         this.name = name;
+        this.value = value;
     }
 
-    public boolean isSetName() {
-        return this.name != null;
+    public String getName() {
+        return name;
     }
 
     public Object getValue() {
         return value;
     }
-
-    public void setValue(Object value) {
-        this.value = value;
-    }
-
-    public boolean isSetValue() {
-        return this.value != null;
-    }
-    
 }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a714ebe/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 8deb424..67369d4 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
@@ -259,9 +259,7 @@ public class JMSDestinationTest extends AbstractJMSTester {
         final Message outMessage = new MessageImpl();
         setupMessageHeader(outMessage, null);
 
-        JMSPropertyType excludeProp = new JMSPropertyType();
-        excludeProp.setName(customPropertyName);
-        excludeProp.setValue(customPropertyName);
+        JMSPropertyType excludeProp = new JMSPropertyType(customPropertyName, customPropertyName);
 
         JMSMessageHeadersType headers = (JMSMessageHeadersType)outMessage
             .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS);

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a714ebe/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 05b7c96..0f7dae6 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
@@ -558,13 +558,9 @@ public class JMSClientServerTest extends AbstractBusClientServerTestBase
{
         JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
         requestHeader.setJMSCorrelationID("JMS_SAMPLE_CORRELATION_ID");
         requestHeader.setJMSExpiration(3600000L);
-        JMSPropertyType propType = new JMSPropertyType();
-        propType.setName(testReturnPropertyName);
-        propType.setValue("mustReturn");
+        JMSPropertyType propType = new JMSPropertyType(testReturnPropertyName, "mustReturn");
         requestHeader.getProperty().add(propType);
-        propType = new JMSPropertyType();
-        propType.setName(testIgnoredPropertyName);
-        propType.setValue("mustNotReturn");
+        propType = new JMSPropertyType(testIgnoredPropertyName, "mustNotReturn");
         requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
 
         String greeting = greeter.greetMe("Milestone-");

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a714ebe/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/TwoWayJMSImplBase.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/TwoWayJMSImplBase.java
b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/TwoWayJMSImplBase.java
index 64fdbd3..3787eee 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/TwoWayJMSImplBase.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/TwoWayJMSImplBase.java
@@ -58,9 +58,7 @@ public class TwoWayJMSImplBase implements HelloWorldPortType {
         //System.out.println("Reached here :" + me);
 
         // set reply header custom property
-        JMSPropertyType testProperty = new JMSPropertyType();
-        testProperty.setName("Test_Prop");
-        testProperty.setValue("some return value "  + me);
+        JMSPropertyType testProperty = new JMSPropertyType("Test_Prop", "some return value
"  + me);
 
         //System.out.println("found property in request headers at index: "
         //                   + headers.getProperty().indexOf(testProperty));

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a714ebe/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/security/TwoWayJMSImplBase.java
----------------------------------------------------------------------
diff --git a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/security/TwoWayJMSImplBase.java
b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/security/TwoWayJMSImplBase.java
index 7752b81..d6ca0da 100644
--- a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/security/TwoWayJMSImplBase.java
+++ b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/security/TwoWayJMSImplBase.java
@@ -58,9 +58,7 @@ public class TwoWayJMSImplBase implements HelloWorldPortType {
         //System.out.println("Reached here :" + me);
 
         // set reply header custom property
-        JMSPropertyType testProperty = new JMSPropertyType();
-        testProperty.setName("Test_Prop");
-        testProperty.setValue("some return value "  + me);
+        JMSPropertyType testProperty = new JMSPropertyType("Test_Prop", "some return value
"  + me);
 
         //System.out.println("found property in request headers at index: "
         //                   + headers.getProperty().indexOf(testProperty));


Mime
View raw message