qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r628702 - in /incubator/qpid/branches/thegreatmerge/qpid: ./ gentools/src/org/apache/qpid/gentools/ java/broker/src/main/java/org/apache/qpid/server/ java/broker/src/main/java/org/apache/qpid/server/exchange/ java/broker/src/main/java/org/a...
Date Mon, 18 Feb 2008 12:29:15 GMT
Author: aidan
Date: Mon Feb 18 04:29:07 2008
New Revision: 628702

URL: http://svn.apache.org/viewvc?rev=628702&view=rev
Log:
Merged revisions 627552,627789,627794,627817 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1

........
  r627552 | rgodfrey | 2008-02-13 18:10:53 +0000 (Wed, 13 Feb 2008) | 1 line
  
  QPID-790 : Performance Improvements
........
  r627789 | rupertlssmith | 2008-02-14 16:01:15 +0000 (Thu, 14 Feb 2008) | 1 line
  
  QPID-9 : Nested field tables implemented. Also wrote a test that encodes/decodes one to check it works.
........
  r627794 | rgodfrey | 2008-02-14 16:24:11 +0000 (Thu, 14 Feb 2008) | 1 line
  
  QPID-790 : Performance Improvements
........
  r627817 | gsim | 2008-02-14 18:02:04 +0000 (Thu, 14 Feb 2008) | 3 lines
  
  Fixed typo in output statement.
........

Added:
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/DeferredDataBlock.java
      - copied unchanged from r627817, incubator/qpid/branches/M2.1/java/common/src/main/java/org/apache/qpid/framing/DeferredDataBlock.java
Modified:
    incubator/qpid/branches/thegreatmerge/qpid/   (props changed)
    incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
    incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfo.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java
    incubator/qpid/branches/thegreatmerge/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
    incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java
    incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java
    incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MessageTestHelper.java
    incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java

Propchange: incubator/qpid/branches/thegreatmerge/qpid/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/gentools/src/org/apache/qpid/gentools/Generator.java Mon Feb 18 04:29:07 2008
@@ -272,7 +272,7 @@
 
             File[] versionTemplateFiles = new File[0];
 
-            System.out.println("Looking for vesrion specific template files in directory: " + versionTemplateDirectory.getAbsoluteFile());
+            System.out.println("Looking for version specific template files in directory: " + versionTemplateDirectory.getAbsoluteFile());
 
             if (versionTemplateDirectory.exists())
             {

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java Mon Feb 18 04:29:07 2008
@@ -34,6 +34,7 @@
 import org.apache.qpid.server.ack.UnacknowledgedMessageMapImpl;
 import org.apache.qpid.server.exchange.MessageRouter;
 import org.apache.qpid.server.exchange.NoRouteException;
+import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.queue.*;
 import org.apache.qpid.server.store.MessageStore;
@@ -202,11 +203,12 @@
         _prefetch_HighWaterMark = prefetchCount;
     }
 
-    public void setPublishFrame(MessagePublishInfo info, AMQProtocolSession publisher) throws AMQException
+    public void setPublishFrame(MessagePublishInfo info, AMQProtocolSession publisher, final Exchange e) throws AMQException
     {
 
         _currentMessage = new AMQMessage(_messageStore.getNewMessageId(), info, _txnContext);
         _currentMessage.setPublisher(publisher);
+        _currentMessage.setExchange(e);
     }
 
     public void publishContentHeader(ContentHeaderBody contentHeaderBody, AMQProtocolSession protocolSession)
@@ -288,7 +290,7 @@
     {
         try
         {
-            _exchanges.routeContent(_currentMessage);
+            _currentMessage.route();            
         }
         catch (NoRouteException e)
         {

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java Mon Feb 18 04:29:07 2008
@@ -238,7 +238,7 @@
     {
         MessagePublishInfo info = payload.getMessagePublishInfo();
 
-        final AMQShortString routingKey = normalize(info.getRoutingKey());
+        final AMQShortString routingKey = info.getRoutingKey();
 
         List<AMQQueue> queues = getMatchedQueues(routingKey);
         // if we have no registered queues we have nothing to do

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java Mon Feb 18 04:29:07 2008
@@ -91,7 +91,8 @@
             }
 
             MessagePublishInfo info = session.getMethodRegistry().getProtocolVersionMethodConverter().convertToInfo(body);
-            channel.setPublishFrame(info, session);
+            info.setExchange(exchange);
+            channel.setPublishFrame(info, session, e);
         }
     }
 

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_8/ProtocolOutputConverterImpl.java Mon Feb 18 04:29:07 2008
@@ -72,7 +72,7 @@
     public void writeDeliver(AMQMessage message, int channelId, long deliveryTag, AMQShortString consumerTag)
             throws AMQException
     {
-        ByteBuffer deliver = createEncodedDeliverFrame(message, channelId, deliveryTag, consumerTag);
+        AMQDataBlock deliver = createEncodedDeliverFrame(message, channelId, deliveryTag, consumerTag);
         AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
                                                                       message.getContentHeaderBody());
 
@@ -127,7 +127,7 @@
         final StoreContext storeContext = message.getStoreContext();
         final long messageId = message.getMessageId();
 
-        ByteBuffer deliver = createEncodedGetOkFrame(message, channelId, deliveryTag, queueSize);
+        AMQDataBlock deliver = createEncodedGetOkFrame(message, channelId, deliveryTag, queueSize);
 
 
         AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
@@ -171,7 +171,7 @@
     }
 
 
-    private ByteBuffer createEncodedDeliverFrame(AMQMessage message, int channelId, long deliveryTag, AMQShortString consumerTag)
+    private AMQDataBlock createEncodedDeliverFrame(AMQMessage message, int channelId, long deliveryTag, AMQShortString consumerTag)
             throws AMQException
     {
         final MessagePublishInfo pb = message.getMessagePublishInfo();
@@ -187,10 +187,10 @@
         AMQFrame deliverFrame = deliverBody.generateFrame(channelId);
 
 
-        return deliverFrame.toByteBuffer();
+        return deliverFrame;
     }
 
-    private ByteBuffer createEncodedGetOkFrame(AMQMessage message, int channelId, long deliveryTag, int queueSize)
+    private AMQDataBlock createEncodedGetOkFrame(AMQMessage message, int channelId, long deliveryTag, int queueSize)
             throws AMQException
     {
         final MessagePublishInfo pb = message.getMessagePublishInfo();
@@ -205,7 +205,7 @@
                                                     queueSize);
         AMQFrame getOkFrame = getOkBody.generateFrame(channelId);
 
-        return getOkFrame.toByteBuffer();
+        return getOkFrame;
     }
 
     public byte getProtocolMinorVersion()
@@ -218,7 +218,7 @@
         return getProtocolSession().getProtocolMajorVersion();
     }
 
-    private ByteBuffer createEncodedReturnFrame(AMQMessage message, int channelId, int replyCode, AMQShortString replyText) throws AMQException
+    private AMQDataBlock createEncodedReturnFrame(AMQMessage message, int channelId, int replyCode, AMQShortString replyText) throws AMQException
     {
         MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(ProtocolVersion.v8_0);
         BasicReturnBody basicReturnBody =
@@ -228,13 +228,13 @@
                                                      message.getMessagePublishInfo().getRoutingKey());
         AMQFrame returnFrame = basicReturnBody.generateFrame(channelId);
 
-        return returnFrame.toByteBuffer();
+        return returnFrame;
     }
 
     public void writeReturn(AMQMessage message, int channelId, int replyCode, AMQShortString replyText)
             throws AMQException
     {
-        ByteBuffer returnFrame = createEncodedReturnFrame(message, channelId, replyCode, replyText);
+        AMQDataBlock returnFrame = createEncodedReturnFrame(message, channelId, replyCode, replyText);
 
         AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
                                                                       message.getContentHeaderBody());

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/output/amqp0_9/ProtocolOutputConverterImpl.java Mon Feb 18 04:29:07 2008
@@ -16,6 +16,7 @@
 
 public class ProtocolOutputConverterImpl implements ProtocolOutputConverter
 {
+    private static final MethodRegistry METHOD_REGISTRY = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
 
 
     public static Factory getInstanceFactory()
@@ -46,9 +47,10 @@
     public void writeDeliver(AMQMessage message, int channelId, long deliveryTag, AMQShortString consumerTag)
             throws AMQException
     {
-        ByteBuffer deliver = createEncodedDeliverFrame(message, channelId, deliveryTag, consumerTag);
+        AMQDataBlock deliver = createEncodedDeliverFrame(message, channelId, deliveryTag, consumerTag);
+        final ContentHeaderBody contentHeaderBody = message.getContentHeaderBody();
         AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
-                                                                      message.getContentHeaderBody());
+                                                                      contentHeaderBody);
 
         final AMQMessageHandle messageHandle = message.getMessageHandle();
         final StoreContext storeContext = message.getStoreContext();
@@ -101,7 +103,7 @@
         final StoreContext storeContext = message.getStoreContext();
         final long messageId = message.getMessageId();
 
-        ByteBuffer deliver = createEncodedGetOkFrame(message, channelId, deliveryTag, queueSize);
+        AMQFrame deliver = createEncodedGetOkFrame(message, channelId, deliveryTag, queueSize);
 
 
         AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
@@ -145,41 +147,54 @@
     }
 
 
-    private ByteBuffer createEncodedDeliverFrame(AMQMessage message, int channelId, long deliveryTag, AMQShortString consumerTag)
+    private AMQDataBlock createEncodedDeliverFrame(AMQMessage message, final int channelId, final long deliveryTag, final AMQShortString consumerTag)
             throws AMQException
     {
         final MessagePublishInfo pb = message.getMessagePublishInfo();
         final AMQMessageHandle messageHandle = message.getMessageHandle();
 
-        MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
-        BasicDeliverBody deliverBody =
-                methodRegistry.createBasicDeliverBody(consumerTag,
-                                                      deliveryTag,
-                                                      messageHandle.isRedelivered(),
-                                                      pb.getExchange(),
-                                                      pb.getRoutingKey());
-        AMQFrame deliverFrame = deliverBody.generateFrame(channelId);
 
+        final boolean isRedelivered = messageHandle.isRedelivered();
+        final AMQShortString exchangeName = pb.getExchange();
+        final AMQShortString routingKey = pb.getRoutingKey();
+
+        final AMQDataBlock returnBlock = new DeferredDataBlock()
+        {
+
+            protected AMQDataBlock createAMQDataBlock()
+            {
+                BasicDeliverBody deliverBody =
+                        METHOD_REGISTRY.createBasicDeliverBody(consumerTag,
+                                                              deliveryTag,
+                                                              isRedelivered,
+                                                              exchangeName,
+                                                              routingKey);
+                AMQFrame deliverFrame = deliverBody.generateFrame(channelId);
+
+
+                return deliverFrame;
 
-        return deliverFrame.toByteBuffer();
+            }
+        };
+        return returnBlock;
     }
 
-    private ByteBuffer createEncodedGetOkFrame(AMQMessage message, int channelId, long deliveryTag, int queueSize)
+    private AMQFrame createEncodedGetOkFrame(AMQMessage message, int channelId, long deliveryTag, int queueSize)
             throws AMQException
     {
         final MessagePublishInfo pb = message.getMessagePublishInfo();
         final AMQMessageHandle messageHandle = message.getMessageHandle();
 
-        MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
+
         BasicGetOkBody getOkBody =
-                methodRegistry.createBasicGetOkBody(deliveryTag,
+                METHOD_REGISTRY.createBasicGetOkBody(deliveryTag,
                                                     messageHandle.isRedelivered(),
                                                     pb.getExchange(),
                                                     pb.getRoutingKey(),
                                                     queueSize);
         AMQFrame getOkFrame = getOkBody.generateFrame(channelId);
 
-        return getOkFrame.toByteBuffer();
+        return getOkFrame;
     }
 
     public byte getProtocolMinorVersion()
@@ -192,23 +207,23 @@
         return getProtocolSession().getProtocolMajorVersion();
     }
 
-    private ByteBuffer createEncodedReturnFrame(AMQMessage message, int channelId, int replyCode, AMQShortString replyText) throws AMQException
+    private AMQDataBlock createEncodedReturnFrame(AMQMessage message, int channelId, int replyCode, AMQShortString replyText) throws AMQException
     {
-        MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
+
         BasicReturnBody basicReturnBody =
-                methodRegistry.createBasicReturnBody(replyCode,
+                METHOD_REGISTRY.createBasicReturnBody(replyCode,
                                                      replyText,
                                                      message.getMessagePublishInfo().getExchange(),
                                                      message.getMessagePublishInfo().getRoutingKey());
         AMQFrame returnFrame = basicReturnBody.generateFrame(channelId);
 
-        return returnFrame.toByteBuffer();
+        return returnFrame;
     }
 
     public void writeReturn(AMQMessage message, int channelId, int replyCode, AMQShortString replyText)
             throws AMQException
     {
-        ByteBuffer returnFrame = createEncodedReturnFrame(message, channelId, replyCode, replyText);
+        AMQDataBlock returnFrame = createEncodedReturnFrame(message, channelId, replyCode, replyText);
 
         AMQDataBlock contentHeader = ContentHeaderBody.createAMQFrame(channelId,
                                                                       message.getContentHeaderBody());
@@ -252,8 +267,8 @@
 
     public void confirmConsumerAutoClose(int channelId, AMQShortString consumerTag)
     {
-        MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
-        BasicCancelOkBody basicCancelOkBody = methodRegistry.createBasicCancelOkBody(consumerTag);
+
+        BasicCancelOkBody basicCancelOkBody = METHOD_REGISTRY.createBasicCancelOkBody(consumerTag);
         writeFrame(basicCancelOkBody.generateFrame(channelId));
 
     }

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java Mon Feb 18 04:29:07 2008
@@ -38,6 +38,7 @@
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.StoreContext;
 import org.apache.qpid.server.txn.TransactionalContext;
+import org.apache.qpid.server.exchange.Exchange;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -103,6 +104,10 @@
 
     private final int hashcode = System.identityHashCode(this);
 
+    private Exchange _exchange;
+    private static final boolean SYNCED_CLOCKS =
+            ApplicationRegistry.getInstance().getConfiguration().getBoolean("advanced.synced-clocks", false);
+
 
     public String debugIdentity()
     {
@@ -116,7 +121,7 @@
         long timestamp =
                 ((BasicContentHeaderProperties) _transientMessageData.getContentHeaderBody().properties).getTimestamp();
 
-        if (ApplicationRegistry.getInstance().getConfiguration().getBoolean("advanced.synced-clocks", false))
+        if (SYNCED_CLOCKS)
         {
             _expiration = expiration;
         }
@@ -143,6 +148,16 @@
     public boolean isReferenced()
     {
         return _referenceCount.get() > 0;
+    }
+
+    public void setExchange(final Exchange exchange)
+    {
+        _exchange = exchange;
+    }
+
+    public void route() throws AMQException
+    {
+        _exchange.route(this);
     }
 
     /**

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/DestWildExchangeTest.java Mon Feb 18 04:29:07 2008
@@ -565,6 +565,11 @@
             return null;
         }
 
+        public void setExchange(AMQShortString exchange)
+        {
+                        
+        }
+
         public boolean isImmediate()
         {
             return false;

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java Mon Feb 18 04:29:07 2008
@@ -247,6 +247,11 @@
                 return null;
             }
 
+            public void setExchange(AMQShortString exchange)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
             public boolean isImmediate()
             {
                 return immediate;

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java Mon Feb 18 04:29:07 2008
@@ -240,6 +240,11 @@
                 return null;
             }
 
+            public void setExchange(AMQShortString exchange)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
             public boolean isImmediate()
             {
                 return immediate;

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQType.java Mon Feb 18 04:29:07 2008
@@ -23,12 +23,24 @@
 import org.apache.mina.common.ByteBuffer;
 
 import java.math.BigDecimal;
-import java.math.BigInteger;
 
+/**
+ * AMQType is a type that represents the different possible AMQP field table types. It provides operations for each
+ * of the types to perform tasks such as calculating the size of an instance of the type, converting types between AMQP
+ * and Java native types, and reading and writing instances of AMQP types in binary formats to and from byte buffers.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Get the equivalent one byte identifier for a type.
+ * <tr><td> Calculate the size of an instance of an AMQP parameter type. <td> {@link EncodingUtils}
+ * <tr><td> Convert an instance of an AMQP parameter into a compatable Java object tagged with its AMQP type.
+ *     <td> {@link AMQTypedValue}
+ * <tr><td> Write an instance of an AMQP parameter type to a byte buffer. <td> {@link EncodingUtils}
+ * <tr><td> Read an instance of an AMQP parameter from a byte buffer. <td> {@link EncodingUtils}
+ * </table>
+ */
 public enum AMQType
 {
-    //AMQP FieldTable Wire Types
-
     LONG_STRING('S')
     {
         public int getEncodingSize(Object value)
@@ -36,7 +48,6 @@
             return EncodingUtils.encodedLongStringLength((String) value);
         }
 
-
         public String toNativeValue(Object value)
         {
             if (value != null)
@@ -58,12 +69,10 @@
         {
             return EncodingUtils.readLongString(buffer);
         }
-
     },
 
     INTEGER('i')
     {
-
         public int getEncodingSize(Object value)
         {
             return EncodingUtils.unsignedIntegerLength();
@@ -89,12 +98,11 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Long.valueOf((String)value);
+                return Long.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to int.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() + ") to int.");
             }
         }
 
@@ -111,22 +119,21 @@
 
     DECIMAL('D')
     {
-
         public int getEncodingSize(Object value)
         {
-            return EncodingUtils.encodedByteLength()+ EncodingUtils.encodedIntegerLength();
+            return EncodingUtils.encodedByteLength() + EncodingUtils.encodedIntegerLength();
         }
 
         public Object toNativeValue(Object value)
         {
-            if(value instanceof BigDecimal)
+            if (value instanceof BigDecimal)
             {
                 return (BigDecimal) value;
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to BigDecimal.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to BigDecimal.");
             }
         }
 
@@ -150,7 +157,8 @@
             int unscaled = EncodingUtils.readInteger(buffer);
 
             BigDecimal bd = new BigDecimal(unscaled);
-            return bd.setScale(places);            
+
+            return bd.setScale(places);
         }
     },
 
@@ -163,14 +171,14 @@
 
         public Object toNativeValue(Object value)
         {
-            if(value instanceof Long)
+            if (value instanceof Long)
             {
                 return (Long) value;
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to timestamp.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to timestamp.");
             }
         }
 
@@ -179,37 +187,97 @@
             EncodingUtils.writeLong(buffer, (Long) value);
         }
 
-
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
             return EncodingUtils.readLong(buffer);
         }
     },
 
+    /**
+     * Implements the field table type. The native value of a field table type will be an instance of
+     * {@link FieldTable}, which itself may contain name/value pairs encoded as {@link AMQTypedValue}s.
+     */
     FIELD_TABLE('F')
     {
+        /**
+         * Calculates the size of an instance of the type in bytes.
+         *
+         * @param value An instance of the type.
+         *
+         * @return The size of the instance of the type in bytes.
+         */
         public int getEncodingSize(Object value)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            // Ensure that the value is a FieldTable.
+            if (!(value instanceof FieldTable))
+            {
+                throw new IllegalArgumentException("Value is not a FieldTable.");
+            }
+
+            FieldTable ftValue = (FieldTable) value;
+
+            // Loop over all name/value pairs adding up size of each. FieldTable itself keeps track of its encoded
+            // size as entries are added, so no need to loop over all explicitly.
+            // EncodingUtils calculation of the encoded field table lenth, will include 4 bytes for its 'size' field.
+            return EncodingUtils.encodedFieldTableLength(ftValue);
         }
 
+        /**
+         * Converts an instance of the type to an equivalent Java native representation.
+         *
+         * @param value An instance of the type.
+         *
+         * @return An equivalent Java native representation.
+         */
         public Object toNativeValue(Object value)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            // Ensure that the value is a FieldTable.
+            if (!(value instanceof FieldTable))
+            {
+                throw new IllegalArgumentException("Value is not a FieldTable.");
+            }
+
+            return (FieldTable) value;
         }
 
+        /**
+         * Writes an instance of the type to a specified byte buffer.
+         *
+         * @param value  An instance of the type.
+         * @param buffer The byte buffer to write it to.
+         */
         public void writeValueImpl(Object value, ByteBuffer buffer)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            // Ensure that the value is a FieldTable.
+            if (!(value instanceof FieldTable))
+            {
+                throw new IllegalArgumentException("Value is not a FieldTable.");
+            }
+
+            FieldTable ftValue = (FieldTable) value;
+
+            // Loop over all name/values writing out into buffer.
+            ftValue.writeToBuffer(buffer);
         }
 
+        /**
+         * Reads an instance of the type from a specified byte buffer.
+         *
+         * @param buffer The byte buffer to write it to.
+         *
+         * @return An instance of the type.
+         */
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
-            // TODO : fixme
-            throw new UnsupportedOperationException();
+            try
+            {
+                // Read size of field table then all name/value pairs.
+                return EncodingUtils.readFieldTable(buffer);
+            }
+            catch (AMQFrameDecodingException e)
+            {
+                throw new IllegalArgumentException("Unable to read field table from buffer.", e);
+            }
         }
     },
 
@@ -220,7 +288,6 @@
             return 0;
         }
 
-
         public Object toNativeValue(Object value)
         {
             if (value == null)
@@ -229,14 +296,13 @@
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to null String.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to null String.");
             }
         }
 
         public void writeValueImpl(Object value, ByteBuffer buffer)
-        {
-        }
+        { }
 
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
@@ -244,8 +310,6 @@
         }
     },
 
-    // Extended types
-
     BINARY('x')
     {
         public int getEncodingSize(Object value)
@@ -253,21 +317,19 @@
             return EncodingUtils.encodedLongstrLength((byte[]) value);
         }
 
-
         public Object toNativeValue(Object value)
         {
-            if((value instanceof byte[]) || (value == null))
+            if ((value instanceof byte[]) || (value == null))
             {
                 return value;
             }
             else
             {
-                throw new IllegalArgumentException("Value: " + value + " (" + value.getClass().getName() +
-                                                    ") cannot be converted to byte[]");
+                throw new IllegalArgumentException("Value: " + value + " (" + value.getClass().getName()
+                    + ") cannot be converted to byte[]");
             }
         }
 
-
         public void writeValueImpl(Object value, ByteBuffer buffer)
         {
             EncodingUtils.writeLongstr(buffer, (byte[]) value);
@@ -277,7 +339,6 @@
         {
             return EncodingUtils.readLongstr(buffer);
         }
-
     },
 
     ASCII_STRING('c')
@@ -287,7 +348,6 @@
             return EncodingUtils.encodedLongStringLength((String) value);
         }
 
-
         public String toNativeValue(Object value)
         {
             if (value != null)
@@ -309,7 +369,6 @@
         {
             return EncodingUtils.readLongString(buffer);
         }
-
     },
 
     WIDE_STRING('C')
@@ -320,7 +379,6 @@
             return EncodingUtils.encodedLongStringLength((String) value);
         }
 
-
         public String toNativeValue(Object value)
         {
             if (value != null)
@@ -351,7 +409,6 @@
             return EncodingUtils.encodedBooleanLength();
         }
 
-
         public Object toNativeValue(Object value)
         {
             if (value instanceof Boolean)
@@ -360,12 +417,12 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Boolean.valueOf((String)value);
+                return Boolean.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to boolean.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to boolean.");
             }
         }
 
@@ -374,7 +431,6 @@
             EncodingUtils.writeBoolean(buffer, (Boolean) value);
         }
 
-
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
             return EncodingUtils.readBoolean(buffer);
@@ -388,7 +444,6 @@
             return EncodingUtils.encodedCharLength();
         }
 
-
         public Character toNativeValue(Object value)
         {
             if (value instanceof Character)
@@ -401,8 +456,8 @@
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to char.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to char.");
             }
         }
 
@@ -415,7 +470,6 @@
         {
             return EncodingUtils.readChar(buffer);
         }
-
     },
 
     BYTE('b')
@@ -425,7 +479,6 @@
             return EncodingUtils.encodedByteLength();
         }
 
-
         public Byte toNativeValue(Object value)
         {
             if (value instanceof Byte)
@@ -434,12 +487,12 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Byte.valueOf((String)value);
+                return Byte.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to byte.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to byte.");
             }
         }
 
@@ -456,13 +509,11 @@
 
     SHORT('s')
     {
-
         public int getEncodingSize(Object value)
         {
             return EncodingUtils.encodedShortLength();
         }
 
-
         public Short toNativeValue(Object value)
         {
             if (value instanceof Short)
@@ -475,16 +526,13 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Short.valueOf((String)value);
+                return Short.valueOf((String) value);
             }
-
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to short.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to short.");
             }
-
-
         }
 
         public void writeValueImpl(Object value, ByteBuffer buffer)
@@ -521,12 +569,11 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Integer.valueOf((String)value);
+                return Integer.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to int.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName() + ") to int.");
             }
         }
 
@@ -543,7 +590,6 @@
 
     LONG('l')
     {
-
         public int getEncodingSize(Object value)
         {
             return EncodingUtils.encodedLongLength();
@@ -551,7 +597,7 @@
 
         public Object toNativeValue(Object value)
         {
-            if(value instanceof Long)
+            if (value instanceof Long)
             {
                 return (Long) value;
             }
@@ -569,12 +615,12 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Long.valueOf((String)value);
+                return Long.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to long.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to long.");
             }
         }
 
@@ -583,7 +629,6 @@
             EncodingUtils.writeLong(buffer, (Long) value);
         }
 
-
         public Object readValueFromBuffer(ByteBuffer buffer)
         {
             return EncodingUtils.readLong(buffer);
@@ -597,7 +642,6 @@
             return EncodingUtils.encodedFloatLength();
         }
 
-
         public Float toNativeValue(Object value)
         {
             if (value instanceof Float)
@@ -606,12 +650,12 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Float.valueOf((String)value);
+                return Float.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to float.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to float.");
             }
         }
 
@@ -628,13 +672,11 @@
 
     DOUBLE('d')
     {
-
         public int getEncodingSize(Object value)
         {
             return EncodingUtils.encodedDoubleLength();
         }
 
-
         public Double toNativeValue(Object value)
         {
             if (value instanceof Double)
@@ -647,12 +689,12 @@
             }
             else if ((value instanceof String) || (value == null))
             {
-                return Double.valueOf((String)value);
+                return Double.valueOf((String) value);
             }
             else
             {
-                throw new NumberFormatException("Cannot convert: " + value + "(" +
-                                                value.getClass().getName() + ") to double.");
+                throw new NumberFormatException("Cannot convert: " + value + "(" + value.getClass().getName()
+                    + ") to double.");
             }
         }
 
@@ -667,35 +709,87 @@
         }
     };
 
+    /** Holds the defined one byte identifier for the type. */
     private final byte _identifier;
 
+    /**
+     * Creates an instance of an AMQP type from its defined one byte identifier.
+     *
+     * @param identifier The one byte identifier for the type.
+     */
     AMQType(char identifier)
     {
         _identifier = (byte) identifier;
     }
 
+    /**
+     * Extracts the byte identifier for the typ.
+     *
+     * @return The byte identifier for the typ.
+     */
     public final byte identifier()
     {
         return _identifier;
     }
 
-
+    /**
+     * Calculates the size of an instance of the type in bytes.
+     *
+     * @param value An instance of the type.
+     *
+     * @return The size of the instance of the type in bytes.
+     */
     public abstract int getEncodingSize(Object value);
 
+    /**
+     * Converts an instance of the type to an equivalent Java native representation.
+     *
+     * @param value An instance of the type.
+     *
+     * @return An equivalent Java native representation.
+     */
     public abstract Object toNativeValue(Object value);
 
+    /**
+     * Converts an instance of the type to an equivalent Java native representation, packaged as an
+     * {@link AMQTypedValue} tagged with its AMQP type.
+     *
+     * @param value An instance of the type.
+     *
+     * @return An equivalent Java native representation, tagged with its AMQP type.
+     */
     public AMQTypedValue asTypedValue(Object value)
     {
         return new AMQTypedValue(this, toNativeValue(value));
     }
 
+    /**
+     * Writes an instance of the type to a specified byte buffer, preceded by its one byte identifier. As the type and
+     * value are both written, this provides a fully encoded description of a parameters type and value.
+     *
+     * @param value  An instance of the type.
+     * @param buffer The byte buffer to write it to.
+     */
     public void writeToBuffer(Object value, ByteBuffer buffer)
     {
-        buffer.put((byte)identifier());
+        buffer.put(identifier());
         writeValueImpl(value, buffer);
     }
 
+    /**
+     * Writes an instance of the type to a specified byte buffer.
+     *
+     * @param value  An instance of the type.
+     * @param buffer The byte buffer to write it to.
+     */
     abstract void writeValueImpl(Object value, ByteBuffer buffer);
 
+    /**
+     * Reads an instance of the type from a specified byte buffer.
+     *
+     * @param buffer The byte buffer to write it to.
+     *
+     * @return An instance of the type.
+     */
     abstract Object readValueFromBuffer(ByteBuffer buffer);
 }

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQTypedValue.java Mon Feb 18 04:29:07 2008
@@ -18,23 +18,40 @@
  * under the License.
  *
  */
-
 package org.apache.qpid.framing;
 
 import org.apache.mina.common.ByteBuffer;
 
+/**
+ * AMQTypedValue combines together a native Java Object value, and an {@link AMQType}, as a fully typed AMQP parameter
+ * value. It provides the ability to read and write fully typed parameters to and from byte buffers. It also provides
+ * the ability to create such parameters from Java native value and a type tag or to extract the native value and type
+ * from one.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Create a fully typed AMQP value from a native type and a type tag. <td> {@link AMQType}
+ * <tr><td> Create a fully typed AMQP value from a binary representation in a byte buffer. <td> {@link AMQType}
+ * <tr><td> Write a fully typed AMQP value to a binary representation in a byte buffer. <td> {@link AMQType}
+ * <tr><td> Extract the type from a fully typed AMQP value.
+ * <tr><td> Extract the value from a fully typed AMQP value.
+ * </table>
+ */
 public class AMQTypedValue
 {
+    /** The type of the value. */
     private final AMQType _type;
-    private final Object _value;
 
+    /** The Java native representation of the AMQP typed value. */
+    private final Object _value;
 
     public AMQTypedValue(AMQType type, Object value)
     {
-        if(type == null)
+        if (type == null)
         {
             throw new NullPointerException("Cannot create a typed value with null type");
         }
+
         _type = type;
         _value = type.toNativeValue(value);
     }
@@ -42,10 +59,9 @@
     private AMQTypedValue(AMQType type, ByteBuffer buffer)
     {
         _type = type;
-        _value = type.readValueFromBuffer( buffer );
+        _value = type.readValueFromBuffer(buffer);
     }
 
-
     public AMQType getType()
     {
         return _type;
@@ -56,10 +72,9 @@
         return _value;
     }
 
-
     public void writeToBuffer(ByteBuffer buffer)
     {
-        _type.writeToBuffer(_value,buffer);
+        _type.writeToBuffer(_value, buffer);
     }
 
     public int getEncodingSize()
@@ -70,11 +85,12 @@
     public static AMQTypedValue readFromBuffer(ByteBuffer buffer)
     {
         AMQType type = AMQTypeMap.getType(buffer.get());
+
         return new AMQTypedValue(type, buffer);
     }
 
     public String toString()
     {
-        return "["+getType()+": "+getValue()+"]";
+        return "[" + getType() + ": " + getValue() + "]";
     }
 }

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/CompositeAMQDataBlock.java Mon Feb 18 04:29:07 2008
@@ -24,7 +24,7 @@
 
 public class CompositeAMQDataBlock extends AMQDataBlock implements EncodableAMQDataBlock
 {
-    private ByteBuffer _encodedBlock;
+    private AMQDataBlock _firstFrame;
 
     private AMQDataBlock[] _blocks;
 
@@ -39,10 +39,10 @@
      * @param encodedBlock already-encoded data
      * @param blocks some blocks to be encoded.
      */
-    public CompositeAMQDataBlock(ByteBuffer encodedBlock, AMQDataBlock[] blocks)
+    public CompositeAMQDataBlock(AMQDataBlock encodedBlock, AMQDataBlock[] blocks)
     {
         this(blocks);
-        _encodedBlock = encodedBlock;
+        _firstFrame = encodedBlock;
     }
 
     public AMQDataBlock[] getBlocks()
@@ -50,9 +50,9 @@
         return _blocks;
     }
 
-    public ByteBuffer getEncodedBlock()
+    public AMQDataBlock getFirstFrame()
     {
-        return _encodedBlock;
+        return _firstFrame;
     }
 
     public long getSize()
@@ -62,19 +62,18 @@
         {
             frameSize += _blocks[i].getSize();
         }
-        if (_encodedBlock != null)
+        if (_firstFrame != null)
         {
-            _encodedBlock.rewind();
-            frameSize += _encodedBlock.remaining();
+            frameSize += _firstFrame.getSize();
         }
         return frameSize;
     }
 
     public void writePayload(ByteBuffer buffer)
     {
-        if (_encodedBlock != null)
+        if (_firstFrame != null)
         {
-            buffer.put(_encodedBlock);
+            _firstFrame.writePayload(buffer);
         }
         for (int i = 0; i < _blocks.length; i++)
         {
@@ -91,7 +90,7 @@
         else
         {
             StringBuilder buf = new StringBuilder(this.getClass().getName());
-            buf.append("{encodedBlock=").append(_encodedBlock);
+            buf.append("{encodedBlock=").append(_firstFrame);
             for (int i = 0 ; i < _blocks.length; i++)
             {
                 buf.append(" ").append(i).append("=[").append(_blocks[i].toString()).append("]");

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java Mon Feb 18 04:29:07 2008
@@ -18,7 +18,6 @@
  * under the License.
  *
  */
-
 package org.apache.qpid.framing;
 
 import org.apache.mina.common.ByteBuffer;
@@ -360,6 +359,41 @@
         }
     }
 
+    /**
+     * Extracts a value from the field table that is itself a FieldTable associated with the specified parameter name.
+     *
+     * @param string The name of the parameter to get the associated FieldTable value for.
+     *
+     * @return The associated FieldTable value, or <tt>null</tt> if the associated value is not of FieldTable type or
+     *         not present in the field table at all.
+     */
+    public FieldTable getFieldTable(String string)
+    {
+        return getFieldTable(new AMQShortString(string));
+    }
+
+    /**
+     * Extracts a value from the field table that is itself a FieldTable associated with the specified parameter name.
+     *
+     * @param string The name of the parameter to get the associated FieldTable value for.
+     *
+     * @return The associated FieldTable value, or <tt>null</tt> if the associated value is not of FieldTable type or
+     *         not present in the field table at all.
+     */
+    public FieldTable getFieldTable(AMQShortString string)
+    {
+        AMQTypedValue value = getProperty(string);
+
+        if ((value != null) && (value.getType() == AMQType.FIELD_TABLE))
+        {
+            return (FieldTable) value.getValue();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
     public Object getObject(String string)
     {
         return getObject(new AMQShortString(string));
@@ -566,6 +600,32 @@
     public Object setVoid(AMQShortString string)
     {
         return setProperty(string, AMQType.VOID.asTypedValue(null));
+    }
+
+    /**
+     * Associates a nested field table with the specified parameter name.
+     *
+     * @param string  The name of the parameter to store in the table.
+     * @param ftValue The field table value to associate with the parameter name.
+     *
+     * @return The stored value.
+     */
+    public Object setFieldTable(String string, FieldTable ftValue)
+    {
+        return setFieldTable(new AMQShortString(string), ftValue);
+    }
+
+    /**
+     * Associates a nested field table with the specified parameter name.
+     *
+     * @param string  The name of the parameter to store in the table.
+     * @param ftValue The field table value to associate with the parameter name.
+     *
+     * @return The stored value.
+     */
+    public Object setFieldTable(AMQShortString string, FieldTable ftValue)
+    {
+        return setProperty(string, AMQType.FIELD_TABLE.asTypedValue(ftValue));
     }
 
     public Object setObject(AMQShortString string, Object object)

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/SmallCompositeAMQDataBlock.java Mon Feb 18 04:29:07 2008
@@ -25,7 +25,7 @@
 
 public class SmallCompositeAMQDataBlock extends AMQDataBlock implements EncodableAMQDataBlock
 {
-    private ByteBuffer _encodedBlock;
+    private AMQDataBlock _firstFrame;
 
     private AMQDataBlock _block;
 
@@ -40,10 +40,10 @@
      * @param encodedBlock already-encoded data
      * @param block a block to be encoded.
      */
-    public SmallCompositeAMQDataBlock(ByteBuffer encodedBlock, AMQDataBlock block)
+    public SmallCompositeAMQDataBlock(AMQDataBlock encodedBlock, AMQDataBlock block)
     {
         this(block);
-        _encodedBlock = encodedBlock;
+        _firstFrame = encodedBlock;
     }
 
     public AMQDataBlock getBlock()
@@ -51,28 +51,28 @@
         return _block;
     }
 
-    public ByteBuffer getEncodedBlock()
+    public AMQDataBlock getFirstFrame()
     {
-        return _encodedBlock;
+        return _firstFrame;
     }
 
     public long getSize()
     {
         long frameSize = _block.getSize();
 
-        if (_encodedBlock != null)
+        if (_firstFrame != null)
         {
-            _encodedBlock.rewind();
-            frameSize += _encodedBlock.remaining();
+
+            frameSize += _firstFrame.getSize();
         }
         return frameSize;
     }
 
     public void writePayload(ByteBuffer buffer)
     {
-        if (_encodedBlock != null)
+        if (_firstFrame != null)
         {
-            buffer.put(_encodedBlock);
+            _firstFrame.writePayload(buffer);
         }
         _block.writePayload(buffer);
 
@@ -87,7 +87,7 @@
         else
         {
             StringBuilder buf = new StringBuilder(this.getClass().getName());
-            buf.append("{encodedBlock=").append(_encodedBlock);
+            buf.append("{encodedBlock=").append(_firstFrame);
 
             buf.append(" _block=[").append(_block.toString()).append("]");
 

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfo.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfo.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfo.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/abstraction/MessagePublishInfo.java Mon Feb 18 04:29:07 2008
@@ -27,6 +27,8 @@
 
     public AMQShortString getExchange();
 
+    public void setExchange(AMQShortString exchange);
+
     public boolean isImmediate();
 
     public boolean isMandatory();

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_0_9/MethodConverter_0_9.java Mon Feb 18 04:29:07 2008
@@ -67,7 +67,7 @@
         final AMQShortString exchange = publishBody.getExchange();
         final AMQShortString routingKey = publishBody.getRoutingKey();
 
-        return new MethodConverter_0_9.MessagePublishInfoImpl(exchange == null ? null : exchange.intern(),
+        return new MethodConverter_0_9.MessagePublishInfoImpl(exchange,
                                           publishBody.getImmediate(),
                                           publishBody.getMandatory(),
                                           routingKey == null ? null : routingKey.intern());
@@ -87,7 +87,7 @@
 
     private static class MessagePublishInfoImpl implements MessagePublishInfo
     {
-        private final AMQShortString _exchange;
+        private AMQShortString _exchange;
         private final boolean _immediate;
         private final boolean _mandatory;
         private final AMQShortString _routingKey;
@@ -106,6 +106,11 @@
         public AMQShortString getExchange()
         {
             return _exchange;
+        }
+
+        public void setExchange(AMQShortString exchange)
+        {
+            _exchange = exchange;
         }
 
         public boolean isImmediate()

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/main/java/org/apache/qpid/framing/amqp_8_0/MethodConverter_8_0.java Mon Feb 18 04:29:07 2008
@@ -107,7 +107,7 @@
 
     private static class MessagePublishInfoImpl implements MessagePublishInfo
     {
-        private final AMQShortString _exchange;
+        private AMQShortString _exchange;
         private final boolean _immediate;
         private final boolean _mandatory;
         private final AMQShortString _routingKey;
@@ -126,6 +126,11 @@
         public AMQShortString getExchange()
         {
             return _exchange;
+        }
+
+        public void setExchange(AMQShortString exchange)
+        {
+            _exchange = exchange;
         }
 
         public boolean isImmediate()

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java Mon Feb 18 04:29:07 2008
@@ -1,21 +1,21 @@
 /*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.framing;
@@ -437,6 +437,60 @@
         table1.setObject("value", "Hello");
         // Check that it was set correctly
         Assert.assertEquals("Hello", table1.getString("value"));
+    }
+
+    /** Check that a nested field table parameter correctly encodes and decodes to a byte buffer. */
+    public void testNestedFieldTable()
+    {
+        byte[] testBytes = new byte[] { 0, 1, 2, 3, 4, 5 };
+
+        FieldTable outerTable = new FieldTable();
+        FieldTable innerTable = new FieldTable();
+
+        // Put some stuff in the inner table.
+        innerTable.setBoolean("bool", true);
+        innerTable.setByte("byte", Byte.MAX_VALUE);
+        innerTable.setBytes("bytes", testBytes);
+        innerTable.setChar("char", 'c');
+        innerTable.setDouble("double", Double.MAX_VALUE);
+        innerTable.setFloat("float", Float.MAX_VALUE);
+        innerTable.setInteger("int", Integer.MAX_VALUE);
+        innerTable.setLong("long", Long.MAX_VALUE);
+        innerTable.setShort("short", Short.MAX_VALUE);
+        innerTable.setString("string", "hello");
+        innerTable.setString("null-string", null);
+
+        // Put the inner table in the outer one.
+        outerTable.setFieldTable("innerTable", innerTable);
+
+        // Write the outer table into the buffer.
+        final ByteBuffer buffer = ByteBuffer.allocate((int) outerTable.getEncodedSize() + 4);
+        outerTable.writeToBuffer(buffer);
+        buffer.flip();
+
+        // Extract the table back from the buffer again.
+        try
+        {
+            FieldTable extractedOuterTable = EncodingUtils.readFieldTable(buffer);
+
+            FieldTable extractedTable = extractedOuterTable.getFieldTable("innerTable");
+
+            Assert.assertEquals((Boolean) true, extractedTable.getBoolean("bool"));
+            Assert.assertEquals((Byte) Byte.MAX_VALUE, extractedTable.getByte("byte"));
+            assertBytesEqual(testBytes, extractedTable.getBytes("bytes"));
+            Assert.assertEquals((Character) 'c', extractedTable.getCharacter("char"));
+            Assert.assertEquals(Double.MAX_VALUE, extractedTable.getDouble("double"));
+            Assert.assertEquals(Float.MAX_VALUE, extractedTable.getFloat("float"));
+            Assert.assertEquals((Integer) Integer.MAX_VALUE, extractedTable.getInteger("int"));
+            Assert.assertEquals((Long) Long.MAX_VALUE, extractedTable.getLong("long"));
+            Assert.assertEquals((Short) Short.MAX_VALUE, extractedTable.getShort("short"));
+            Assert.assertEquals("hello", extractedTable.getString("string"));
+            Assert.assertEquals(null, extractedTable.getString("null-string"));
+        }
+        catch (AMQFrameDecodingException e)
+        {
+            fail("Failed to decode field table with nested inner table.");
+        }
     }
 
     public void testValues()

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java Mon Feb 18 04:29:07 2008
@@ -117,6 +117,11 @@
                         return null;
                     }
 
+                    public void setExchange(AMQShortString exchange)
+                    {
+                        //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
                     public boolean isImmediate()
                     {
                         return false;

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java Mon Feb 18 04:29:07 2008
@@ -109,6 +109,11 @@
                     return new AMQShortString("someExchange");
                 }
 
+                public void setExchange(AMQShortString exchange)
+                {
+                    //To change body of implemented methods use File | Settings | File Templates.
+                }
+
                 public boolean isImmediate()
                 {
                     return false;

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MessageTestHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MessageTestHelper.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MessageTestHelper.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MessageTestHelper.java Mon Feb 18 04:29:07 2008
@@ -68,6 +68,11 @@
                 return null;
             }
 
+            public void setExchange(AMQShortString exchange)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
             public boolean isImmediate()
             {
                 return immediate;

Modified: incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java?rev=628702&r1=628701&r2=628702&view=diff
==============================================================================
--- incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java (original)
+++ incubator/qpid/branches/thegreatmerge/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java Mon Feb 18 04:29:07 2008
@@ -61,6 +61,11 @@
                 return null;
             }
 
+            public void setExchange(AMQShortString exchange)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
+            }
+
             public boolean isImmediate()
             {
                 return false;
@@ -107,6 +112,11 @@
             public AMQShortString getExchange()
             {
                 return null;
+            }
+
+            public void setExchange(AMQShortString exchange)
+            {
+                //To change body of implemented methods use File | Settings | File Templates.
             }
 
             public boolean isImmediate()



Mime
View raw message