You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/01/06 18:37:47 UTC

[2/2] qpid-proton git commit: PROTON-792: Revert "PROTON-711: add support (disabled by default) for using a byte value for destination type annotations during inbound transformation"

PROTON-792: Revert "PROTON-711: add support (disabled by default) for using a byte value for destination type annotations during inbound transformation"

This reverts commit 960eeff9eefa5b8dc52de356d1118ae0b017a319.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/4191590e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4191590e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4191590e

Branch: refs/heads/master
Commit: 4191590ec121027b0590242a42bdae2032b3126d
Parents: 7ecef79
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Jan 6 17:09:36 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Jan 6 17:31:57 2015 +0000

----------------------------------------------------------------------
 .../qpid/proton/jms/InboundTransformer.java     | 84 +++++------------
 .../jms/JMSMappingInboundTransformerTest.java   | 97 +++-----------------
 2 files changed, 35 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4191590e/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
index cef10c4..0374e6a 100644
--- a/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
+++ b/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
@@ -53,22 +53,12 @@ public abstract class InboundTransformer {
     int defaultPriority = javax.jms.Message.DEFAULT_PRIORITY;
     long defaultTtl = javax.jms.Message.DEFAULT_TIME_TO_LIVE;
 
-    private boolean useByteDestinationTypeAnnotations = false;
-
     public InboundTransformer(JMSVendor vendor) {
         this.vendor = vendor;
     }
 
     abstract public Message transform(EncodedMessage amqpMessage) throws Exception;
 
-    public boolean isUseByteDestinationTypeAnnotations() {
-        return useByteDestinationTypeAnnotations;
-    }
-
-    public void setUseByteDestinationTypeAnnotations(boolean useByteDestinationTypeAnnotations) {
-        this.useByteDestinationTypeAnnotations = useByteDestinationTypeAnnotations;
-    }
-
     public int getDefaultDeliveryMode() {
         return defaultDeliveryMode;
     }
@@ -140,16 +130,8 @@ public abstract class InboundTransformer {
             }
         }
 
-        Class<? extends Destination> toAttributes = null;
-        Class<? extends Destination> replyToAttributes = null;
-
-        if (isUseByteDestinationTypeAnnotations()){
-            toAttributes = Queue.class;
-            replyToAttributes = Queue.class;
-        } else {
-            toAttributes = Destination.class;
-            replyToAttributes = Destination.class;
-        }
+        Class<? extends Destination> toAttributes = Destination.class;
+        Class<? extends Destination> replyToAttributes = Destination.class;
 
         final MessageAnnotations ma = amqp.getMessageAnnotations();
         if( ma!=null ) {
@@ -158,9 +140,9 @@ public abstract class InboundTransformer {
                 if( "x-opt-jms-type".equals(key.toString()) && entry.getValue() != null ) {
                     jms.setJMSType(entry.getValue().toString());
                 } else if( "x-opt-to-type".equals(key.toString()) ) {
-                    toAttributes = toClassFromAttributes(entry.getValue());
+                    toAttributes = toClassFromAttributes(entry.getValue().toString());
                 } else if( "x-opt-reply-type".equals(key.toString()) ) {
-                    replyToAttributes = toClassFromAttributes(entry.getValue());
+                    replyToAttributes = toClassFromAttributes(entry.getValue().toString());
                 } else {
                     setProperty(jms, prefixVendor + prefixMessageAnnotations + key, entry.getValue());
                 }
@@ -264,49 +246,29 @@ public abstract class InboundTransformer {
         return Collections.unmodifiableSet(s);
     }
 
-    Class<? extends Destination> toClassFromAttributes(Object value)
+    Class<? extends Destination> toClassFromAttributes(String value)
     {
-        if(isUseByteDestinationTypeAnnotations()) {
-            if(value instanceof Byte) {
-                switch ((Byte) value) {
-                    case JMSVendor.QUEUE_TYPE:
-                        return Queue.class;
-                    case JMSVendor.TOPIC_TYPE:
-                        return Topic.class;
-                    case JMSVendor.TEMP_QUEUE_TYPE:
-                        return TemporaryQueue.class;
-                    case JMSVendor.TEMP_TOPIC_TYPE:
-                        return TemporaryTopic.class;
-                    default:
-                        return Queue.class;
-                }
-            }
+        if( value ==null ) {
+            return null;
+        }
+        HashSet<String> attributes = new HashSet<String>();
+        for( String x: value.split("\\s*,\\s*") ) {
+            attributes.add(x);
+        }
 
+        if( QUEUE_ATTRIBUTES.equals(attributes) ) {
             return Queue.class;
-        } else {
-            if( value == null ) {
-                return null;
-            }
-            String valueString = value.toString();
-            HashSet<String> attributes = new HashSet<String>();
-            for( String x: valueString.split("\\s*,\\s*") ) {
-                attributes.add(x);
-            }
-
-            if( QUEUE_ATTRIBUTES.equals(attributes) ) {
-                return Queue.class;
-            }
-            if( TOPIC_ATTRIBUTES.equals(attributes) ) {
-                return Topic.class;
-            }
-            if( TEMP_QUEUE_ATTRIBUTES.equals(attributes) ) {
-                return TemporaryQueue.class;
-            }
-            if( TEMP_TOPIC_ATTRIBUTES.equals(attributes) ) {
-                return TemporaryTopic.class;
-            }
-            return Destination.class;
         }
+        if( TOPIC_ATTRIBUTES.equals(attributes) ) {
+            return Topic.class;
+        }
+        if( TEMP_QUEUE_ATTRIBUTES.equals(attributes) ) {
+            return TemporaryQueue.class;
+        }
+        if( TEMP_TOPIC_ATTRIBUTES.equals(attributes) ) {
+            return TemporaryTopic.class;
+        }
+        return Destination.class;
     }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4191590e/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformerTest.java
----------------------------------------------------------------------
diff --git a/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformerTest.java b/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformerTest.java
index 2413310..42a99ca 100644
--- a/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformerTest.java
+++ b/contrib/proton-jms/src/test/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformerTest.java
@@ -60,78 +60,41 @@ public class JMSMappingInboundTransformerTest
     // ======= JMSDestination Handling =========
     // =========================================
 
-    // --- String type annotation ---
     @Test
     public void testTransformWithNoToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl(null, Destination.class, false);
+        doTransformWithToTypeDestinationTypeAnnotationTestImpl(null, Destination.class);
     }
 
     @Test
     public void testTransformWithQueueStringToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class, false);
+        doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class);
     }
 
     @Test
     public void testTransformWithTemporaryQueueStringToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class, false);
+        doTransformWithToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class);
     }
 
     @Test
     public void testTransformWithTopicStringToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class, false);
+        doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class);
     }
 
     @Test
     public void testTransformWithTemporaryTopicStringToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class, false);
+        doTransformWithToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class);
     }
 
-    // --- byte type annotation ---
-
-    @Test
-    public void testTransformWithNoToTypeDestinationTypeAnnotationUsingByteAnnotation() throws Exception
-    {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl(null, Queue.class, true);
-    }
-
-    @Test
-    public void testTransformWithQueueByteToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.QUEUE_TYPE, Queue.class, true);
-    }
-
-    @Test
-    public void testTransformWithTemporaryQueueByteToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_QUEUE_TYPE, TemporaryQueue.class, true);
-    }
-
-    @Test
-    public void testTransformWithTopicByteToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TOPIC_TYPE, Topic.class, true);
-    }
-
-    @Test
-    public void testTransformWithTemporaryTopicByteToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_TOPIC_TYPE, TemporaryTopic.class, true);
-    }
-
-    private void doTransformWithToTypeDestinationTypeAnnotationTestImpl(Object toTypeAnnotationValue, Class<? extends Destination> expectedClass, boolean byteType) throws Exception
+    private void doTransformWithToTypeDestinationTypeAnnotationTestImpl(Object toTypeAnnotationValue, Class<? extends Destination> expectedClass) throws Exception
     {
         TextMessage mockTextMessage = createMockTextMessage();
         JMSVendor mockVendor = createMockVendor(mockTextMessage);
         JMSMappingInboundTransformer transformer = new JMSMappingInboundTransformer(mockVendor);
-        if(byteType)
-        {
-            transformer.setUseByteDestinationTypeAnnotations(true);
-        }
 
         String toAddress = "toAddress";
         Message amqp = Message.Factory.create();
@@ -157,77 +120,41 @@ public class JMSMappingInboundTransformerTest
     // ======= JMSReplyTo Handling =========
     // =====================================
 
-    // --- String type annotation ---
     @Test
     public void testTransformWithNoReplyToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(null,Destination.class, false);
+        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(null,Destination.class);
     }
 
     @Test
     public void testTransformWithQueueStringReplyToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class, false);
+        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue", Queue.class);
     }
 
     @Test
     public void testTransformWithTemporaryQueueStringReplyToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class, false);
+        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("queue,temporary", TemporaryQueue.class);
     }
 
     @Test
     public void testTransformWithTopicStringReplyToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class, false);
+        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic", Topic.class);
     }
 
     @Test
     public void testTransformWithTemporaryTopicStringReplyToTypeDestinationTypeAnnotation() throws Exception
     {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class, false);
+        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl("topic,temporary", TemporaryTopic.class);
     }
 
-    // --- byte type annotation ---
-    @Test
-    public void testTransformWithNoReplyToTypeDestinationTypeAnnotationUsingByteAnnotation() throws Exception
-    {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(null,Queue.class, true);
-    }
-
-    @Test
-    public void testTransformWithQueueByteReplyToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.QUEUE_TYPE, Queue.class, true);
-    }
-
-    @Test
-    public void testTransformWithTemporaryQueueByteReplyToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_QUEUE_TYPE, TemporaryQueue.class, true);
-    }
-
-    @Test
-    public void testTransformWithTopicByteReplyToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TOPIC_TYPE, Topic.class, true);
-    }
-
-    @Test
-    public void testTransformWithTemporaryTopicByteReplyToTypeDestinationTypeAnnotation() throws Exception
-    {
-        doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(JMSVendor.TEMP_TOPIC_TYPE, TemporaryTopic.class, true);
-    }
-
-    private void doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(Object replyToTypeAnnotationValue, Class<? extends Destination> expectedClass, boolean byteType) throws Exception
+    private void doTransformWithReplyToTypeDestinationTypeAnnotationTestImpl(Object replyToTypeAnnotationValue, Class<? extends Destination> expectedClass) throws Exception
     {
         TextMessage mockTextMessage = createMockTextMessage();
         JMSVendor mockVendor = createMockVendor(mockTextMessage);
         JMSMappingInboundTransformer transformer = new JMSMappingInboundTransformer(mockVendor);
-        if(byteType)
-        {
-            transformer.setUseByteDestinationTypeAnnotations(true);
-        }
 
         String replyToAddress = "replyToAddress";
         Message amqp = Message.Factory.create();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org