You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2013/09/26 17:30:58 UTC

svn commit: r1526574 - /qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java

Author: rgodfrey
Date: Thu Sep 26 15:30:58 2013
New Revision: 1526574

URL: http://svn.apache.org/r1526574
Log:
QPID-5177 : Add support for default outcome, and assume default outcome is ACCEPTED if there are no supported outcomes

Modified:
    qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java

Modified: qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java?rev=1526574&r1=1526573&r2=1526574&view=diff
==============================================================================
--- qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java (original)
+++ qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java Thu Sep 26 15:30:58 2013
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.amqp_1_0.client;
 
+import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor;
 import org.apache.qpid.amqp_1_0.messaging.SectionEncoder;
 import org.apache.qpid.amqp_1_0.transport.DeliveryStateHandler;
 import org.apache.qpid.amqp_1_0.transport.LinkEndpoint;
@@ -28,6 +29,7 @@ import org.apache.qpid.amqp_1_0.transpor
 import org.apache.qpid.amqp_1_0.type.*;
 import org.apache.qpid.amqp_1_0.type.Source;
 import org.apache.qpid.amqp_1_0.type.Target;
+import org.apache.qpid.amqp_1_0.type.codec.AMQPDescribedTypeRegistry;
 import org.apache.qpid.amqp_1_0.type.messaging.*;
 import org.apache.qpid.amqp_1_0.type.transaction.TransactionalState;
 import org.apache.qpid.amqp_1_0.type.transport.*;
@@ -49,6 +51,7 @@ public class Sender implements DeliveryS
     private boolean _closed;
     private Error _error;
     private Runnable _remoteErrorTask;
+    private Outcome _defaultOutcome;
 
     public Sender(final Session session, final String linkName, final String targetAddr, final String sourceAddr)
             throws SenderCreationException, ConnectionClosedException
@@ -186,6 +189,35 @@ public class Sender implements DeliveryS
                 super.remoteDetached(endpoint, detach);
             }
         });
+        final org.apache.qpid.amqp_1_0.type.messaging.Source remoteSource =
+                (org.apache.qpid.amqp_1_0.type.messaging.Source) getSource();
+        _defaultOutcome = remoteSource.getDefaultOutcome();
+        if(_defaultOutcome == null)
+        {
+            if(remoteSource.getOutcomes() == null || remoteSource.getOutcomes().length == 0)
+            {
+                _defaultOutcome = new Accepted();
+            }
+            else if(remoteSource.getOutcomes().length == 1)
+            {
+
+                final AMQPDescribedTypeRegistry describedTypeRegistry = _endpoint.getSession()
+                        .getConnection()
+                        .getDescribedTypeRegistry();
+
+                DescribedTypeConstructor constructor = describedTypeRegistry
+                        .getConstructor(remoteSource.getOutcomes()[0]);
+                if(constructor != null)
+                {
+                    Object impliedOutcome = constructor.construct(Collections.EMPTY_LIST);
+                    if(impliedOutcome instanceof Outcome)
+                    {
+                        _defaultOutcome = (Outcome) impliedOutcome;
+                    }
+                }
+
+            }
+        }
     }
 
     public Source getSource()
@@ -369,7 +401,9 @@ public class Sender implements DeliveryS
             OutcomeAction action;
             if((action = _outcomeActions.remove(deliveryTag)) != null)
             {
-                action.onOutcome(deliveryTag, (Outcome) state);
+
+                final Outcome outcome = (Outcome) state;
+                action.onOutcome(deliveryTag, (outcome == null && settled) ? _defaultOutcome : outcome);
             }
             if(!Boolean.TRUE.equals(settled))
             {
@@ -379,10 +413,10 @@ public class Sender implements DeliveryS
         else if(state instanceof TransactionalState)
         {
             OutcomeAction action;
-
             if((action = _outcomeActions.remove(deliveryTag)) != null)
             {
-                action.onOutcome(deliveryTag, ((TransactionalState) state).getOutcome());
+                final Outcome outcome = ((TransactionalState) state).getOutcome();
+                action.onOutcome(deliveryTag, outcome == null ? _defaultOutcome : outcome);
             }
 
         }



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