qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1620344 [4/4] - in /qpid/branches/0.30/qpid/java: ./ bdbstore/src/main/java/resources/js/qpid/management/virtualhost/bdb_ha/ bdbstore/src/main/java/resources/js/qpid/management/virtualhost/store/ bdbstore/src/main/java/resources/virtualhos...
Date Mon, 25 Aug 2014 15:25:03 GMT
Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js Mon Aug 25 15:25:00 2014
@@ -34,6 +34,7 @@ define(["dojo/_base/xhr",
         "dijit/form/FilteringSelect",
         "qpid/common/properties",
         "qpid/common/util",
+        "qpid/common/metadata",
         "dojo/text!addVirtualHostNodeAndVirtualHost.html",
         "dijit/form/Form",
         "dijit/form/CheckBox",
@@ -41,7 +42,7 @@ define(["dojo/_base/xhr",
         "dojox/validate/us",
         "dojox/validate/web",
         "dojo/domReady!"],
-  function (xhr, event, lang, array, dom, domConstruct, json, parser, Memory, fobject, registry, Dialog, Button, FilteringSelect, properties, util, template)
+  function (xhr, event, lang, array, dom, domConstruct, json, parser, Memory, fobject, registry, Dialog, Button, FilteringSelect, properties, util, metadata, template)
   {
 
     var addVirtualHostNodeAndVirtualHost =
@@ -71,38 +72,26 @@ define(["dojo/_base/xhr",
         this.virtualHostType = registry.byId("addVirtualHost.type");
         this.virtualHostType.set("disabled", true);
 
-        xhr.get({sync: properties.useSyncGet, handleAs: "json", url: "api/latest/broker?depth=0", load: function(data){that._onBrokerData(data[0]) }});
-      },
-      _makeTypeStore: function (types) {
-          var typeData = [];
-          for (var i = 0; i < types.length; i++) {
-              var type = types[i];
-              typeData.push({id: type, name: type});
-          }
-          return new Memory({ data: typeData });
-      },
-      _onBrokerData: function(brokerData)
-      {
-          var that=this;
-          this.supportedVirtualHostNodeTypes = brokerData.supportedVirtualHostNodeTypes;
-          this.supportedVirtualHostNodeTypes.sort();
-          this.supportedVirtualHostTypes = brokerData.supportedVirtualHostTypes;
-          this.supportedVirtualHostTypes.sort();
-
-          //VH Type BDB_HA_REPLICA is not user creatable. This is only needed until we have model meta data available.
-          this.supportedVirtualHostTypes = array.filter(this.supportedVirtualHostTypes, function(item){
-              return item != "BDB_HA_REPLICA" && item != "BDB_HA";
-          });
+        this.supportedVirtualHostNodeTypes = metadata.getTypesForCategory("VirtualHostNode");
+        this.supportedVirtualHostNodeTypes.sort();
+        this.supportedVirtualHostTypes = metadata.getTypesForCategory("VirtualHost");
+        this.supportedVirtualHostTypes.sort();
+
+        //VH Type BDB_HA_REPLICA is not user creatable. This is only needed until we have model meta data available.
+        this.supportedVirtualHostTypes = array.filter(this.supportedVirtualHostTypes, function(item){
+            return item != "BDB_HA_REPLICA" && item != "BDB_HA";
+        });
+
+        var virtualHostNodeTypeStore = util.makeTypeStore(this.supportedVirtualHostNodeTypes);
+        this.virtualHostNodeType.set("store", virtualHostNodeTypeStore);
+        this.virtualHostNodeType.set("disabled", false);
+        this.virtualHostNodeType.on("change", function(type){that._vhnTypeChanged(type, that.virtualHostNodeTypeFieldsContainer, "qpid/management/virtualhostnode/");});
+
+        this.virtualHostTypeStore = util.makeTypeStore(this.supportedVirtualHostTypes);
+        this.virtualHostType.set("store", this.virtualHostTypeStore);
+        this.virtualHostType.set("disabled", false);
+        this.virtualHostType.on("change", function(type){that._vhTypeChanged(type, that.virtualHostTypeFieldsContainer, "qpid/management/virtualhost/");});
 
-          var virtualHostNodeTypeStore = this._makeTypeStore(this.supportedVirtualHostNodeTypes);
-          this.virtualHostNodeType.set("store", virtualHostNodeTypeStore);
-          this.virtualHostNodeType.set("disabled", false);
-          this.virtualHostNodeType.on("change", function(type){that._vhnTypeChanged(type, that.virtualHostNodeTypeFieldsContainer, "qpid/management/virtualhostnode/");});
-
-          this.virtualHostTypeStore = this._makeTypeStore(this.supportedVirtualHostTypes);
-          this.virtualHostType.set("store", this.virtualHostTypeStore);
-          this.virtualHostType.set("disabled", false);
-          this.virtualHostType.on("change", function(type){that._vhTypeChanged(type, that.virtualHostTypeFieldsContainer, "qpid/management/virtualhost/");});
       },
       show: function()
       {
@@ -132,13 +121,14 @@ define(["dojo/_base/xhr",
       {
         this._processDropDownsForBdbHa(type);
         this._processDropDownsForJson(type);
-        this._typeChanged(type, typeFieldsContainer, urlStem);
+
+        this._typeChanged(type, typeFieldsContainer, urlStem, "VirtualHostNode");
       },
       _vhTypeChanged: function (type, typeFieldsContainer, urlStem)
       {
-        this._typeChanged(type, typeFieldsContainer, urlStem);
+        this._typeChanged(type, typeFieldsContainer, urlStem, "VirtualHost");
       },
-      _typeChanged: function (type, typeFieldsContainer, urlStem)
+      _typeChanged: function (type, typeFieldsContainer, urlStem, category)
       {
           var widgets = registry.findWidgets(typeFieldsContainer);
           array.forEach(widgets, function(item) { item.destroyRecursive();});
@@ -148,11 +138,13 @@ define(["dojo/_base/xhr",
           {
             var that = this;
             require([urlStem + type.toLowerCase() + "/add"],
-              function(TypeUI)
+              function(typeUI)
               {
                   try
                   {
-                      TypeUI.show({containerNode:typeFieldsContainer, parent: that});
+                      typeUI.show({containerNode:typeFieldsContainer, parent: that});
+
+                      util.applyMetadataToWidgets(typeFieldsContainer,category, type);
                   }
                   catch(e)
                   {

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js Mon Aug 25 15:25:00 2014
@@ -56,6 +56,7 @@ define(["dojo/_base/xhr",
         var that=this;
         this.containerNode = domConstruct.create("div", {innerHTML: template});
         parser.parse(this.containerNode);
+        this.allFieldsContainer = dom.byId("editVirtualHost.allFields");
         this.typeFieldsContainer = dom.byId("editVirtualHost.typeFields");
         this.dialog = registry.byId("editVirtualHostDialog");
         this.saveButton = registry.byId("editVirtualHost.saveButton");
@@ -176,6 +177,8 @@ define(["dojo/_base/xhr",
                 {
                     TypeUI.show({containerNode:that.typeFieldsContainer, parent: that, data: virtualHostData});
                     that.form.connectChildren();
+
+                    util.applyMetadataToWidgets(that.allFieldsContainer, "VirtualHost", virtualHostData.type);
                 }
                 catch(e)
                 {

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js Mon Aug 25 15:25:00 2014
@@ -147,6 +147,8 @@ define(["dojo/_base/xhr",
                 {
                     TypeUI.show({containerNode:that.typeFieldsContainer, parent: that, data: nodeData});
                     that.form.connectChildren();
+
+                    util.applyMetadataToWidgets(that.allFieldsContainer, "VirtualHostNode", nodeData.type);
                 }
                 catch(e)
                 {

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementhttp.js Mon Aug 25 15:25:00 2014
@@ -139,7 +139,9 @@ define(["dojo/_base/xhr",
               widgetFactories,
               data,
               "api/latest/plugin/" + encodeURIComponent(data.name),
-              "Edit plugin - " + data.name);
+              "Edit plugin - " + data.name,
+              "Plugin",
+              "MANAGEMENT-HTTP");
         };
 
         function ManagementHttpUpdater(node, pluginObject, controller)

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/plugin/managementjmx.js Mon Aug 25 15:25:00 2014
@@ -86,7 +86,9 @@ define(["dojo/_base/xhr",
               widgetFactories,
               data,
               "api/latest/plugin/" + encodeURIComponent(data.name),
-              "Edit plugin - " + data.name);
+              "Edit plugin - " + data.name,
+              "Plugin",
+              "MANAGEMENT-JMX");
         };
 
         function ManagementJmxUpdater(node, pluginObject, controller)

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/add.html
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/add.html?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/add.html (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/add.html Mon Aug 25 15:25:00 2014
@@ -28,7 +28,8 @@
                               name: 'storeOverfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages'" />
+                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages',
+                              promptMessage: 'Ceiling (in bytes) at which store will begin to throttle sessions producing messages'" />
         </div>
     </div>
     <div class="clear">
@@ -40,7 +41,8 @@
                               name: 'storeUnderfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages'" />
+                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages',
+                              promptMessage: 'Floor (in bytes) at which store will cease to throttle sessions producing messages'" />
         </div>
     </div>
    </div>

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/edit.html
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/edit.html?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/edit.html (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/providedstore/edit.html Mon Aug 25 15:25:00 2014
@@ -28,7 +28,8 @@
                               name: 'storeOverfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages'"
+                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages',
+                              promptMessage: 'Ceiling (in bytes) at which store will begin to throttle sessions producing messages'"
                    />
         </div>
     </div>
@@ -41,7 +42,8 @@
                               name: 'storeUnderfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages'"
+                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages',
+                              promptMessage: 'Floor (in bytes) at which store will cease to throttle sessions producing messages'"
                    />
         </div>
     </div>

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/add.html
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/add.html?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/add.html (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/add.html Mon Aug 25 15:25:00 2014
@@ -26,7 +26,8 @@
                    data-dojo-props="
                               name: 'storePath',
                               placeHolder: 'path/to/store',
-                              title: 'Enter message store path'" />
+                              title: 'Enter message store path',
+                              promptMessage: 'File system location for the message store'" />
         </div>
     </div>
     <div class="clear">
@@ -38,7 +39,8 @@
                               name: 'storeOverfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages'" />
+                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages',
+                              promptMessage: 'Ceiling (in bytes) at which store will begin to throttle sessions producing messages'" />
         </div>
     </div>
     <div class="clear">
@@ -50,7 +52,8 @@
                               name: 'storeUnderfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages'" />
+                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages',
+                              promptMessage: 'Floor (in bytes) at which store will cease to throttle sessions producing messages'" />
         </div>
     </div>
     <div class="clear"></div>

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/edit.html
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/edit.html?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/edit.html (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/sizemonitoring/edit.html Mon Aug 25 15:25:00 2014
@@ -26,7 +26,6 @@
                    data-dojo-type="dijit/form/ValidationTextBox"
                    data-dojo-props="
                               name: 'storePath',
-                              placeHolder: 'path/to/store',
                               disabled: true,
                               title: 'Enter message store path'" />
         </div>
@@ -41,7 +40,8 @@
                               name: 'storeOverfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages'"
+                              title: 'Enter ceiling (in bytes) at which store will begin to throttle sessions producing messages',
+                              promptMessage: 'Ceiling (in bytes) at which store will begin to throttle sessions producing messages'"
                    />
         </div>
     </div>
@@ -54,7 +54,8 @@
                               name: 'storeUnderfullSize',
                               placeHolder: 'size in bytes',
                               required: false,
-                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages'"
+                              title: 'Enter floor (in bytes) at which store will cease to throttle sessions producing messages',
+                              promptMessage: 'Floor (in bytes) at which store will cease to throttle sessions producing messages'"
                    />
         </div>
     </div>

Modified: qpid/branches/0.30/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java (original)
+++ qpid/branches/0.30/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementPluginImpl.java Mon Aug 25 15:25:00 2014
@@ -32,6 +32,7 @@ import java.util.Set;
 import javax.management.JMException;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.jmx.mbeans.LoggingManagementMBean;
 import org.apache.qpid.server.jmx.mbeans.ServerInformationMBean;

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java Mon Aug 25 15:25:00 2014
@@ -20,6 +20,39 @@
  */
 package org.apache.qpid.client;
 
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.ConnectException;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.nio.channels.UnresolvedAddressException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionMetaData;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.ServerSessionPool;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicSession;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,38 +82,6 @@ import org.apache.qpid.jms.FailoverPolic
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.url.URLSyntaxException;
 
-import javax.jms.ConnectionConsumer;
-import javax.jms.ConnectionMetaData;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueSession;
-import javax.jms.ServerSessionPool;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.ConnectException;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-import java.nio.channels.UnresolvedAddressException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
 public class AMQConnection extends Closeable implements Connection, QueueConnection, TopicConnection, Referenceable
 {
     private static final Logger _logger = LoggerFactory.getLogger(AMQConnection.class);
@@ -191,6 +192,9 @@ public class AMQConnection extends Close
     //Address resolution purposes
     private volatile long _lastFailoverTime = 0;
 
+    private boolean _compressMessages;
+    private int _messageCompressionThresholdSize;
+
     /**
      * @param broker      brokerdetails
      * @param username    username
@@ -325,6 +329,31 @@ public class AMQConnection extends Close
                 Boolean.parseBoolean(System.getProperty(ClientProperties.VERIFY_QUEUE_ON_SEND, "false"));
         }
 
+        if(connectionURL.getOption(ConnectionURL.OPTIONS_COMPRESS_MESSAGES) != null)
+        {
+            _compressMessages = Boolean.parseBoolean(connectionURL.getOption(ConnectionURL.OPTIONS_COMPRESS_MESSAGES));
+        }
+        else
+        {
+            _compressMessages =
+                    Boolean.parseBoolean(System.getProperty(ClientProperties.CONNECTION_OPTION_COMPRESS_MESSAGES,
+                                         String.valueOf(ClientProperties.DEFAULT_CONNECTION_OPTION_COMPRESS_MESSAGES)));
+        }
+
+
+        if(connectionURL.getOption(ConnectionURL.OPTIONS_MESSAGES_COMPRESSION_THRESHOLD_SIZE) != null)
+        {
+            _messageCompressionThresholdSize = Integer.valueOf(connectionURL.getOption(ConnectionURL.OPTIONS_MESSAGES_COMPRESSION_THRESHOLD_SIZE));
+        }
+        else
+        {
+            _messageCompressionThresholdSize = Integer.getInteger(ClientProperties.CONNECTION_OPTION_MESSAGE_COMPRESSION_THRESHOLD_SIZE,
+                                                                ClientProperties.DEFAULT_MESSAGE_COMPRESSION_THRESHOLD_SIZE);
+        }
+        if(_messageCompressionThresholdSize <= 0)
+        {
+            _messageCompressionThresholdSize = Integer.MAX_VALUE;
+        }
 
         String amqpVersion = System.getProperty((ClientProperties.AMQP_VERSION), "0-10");
         if (_logger.isDebugEnabled())
@@ -449,16 +478,13 @@ public class AMQConnection extends Close
                 }
             }
 
-            if ((message == null) || message.equals(""))
+            if (message == null)
             {
-                if (message == null)
-                {
-                    message = "Unable to Connect";
-                }
-                else // can only be "" if getMessage() returned it therfore lastException != null
-                {
-                    message = "Unable to Connect:" + connectionException.getClass();
-                }
+                message = "Unable to Connect";
+            }
+            else if("".equals(message))
+            {
+                message = "Unable to Connect:" + connectionException.getClass();
             }
 
             for (Throwable th = connectionException; th != null; th = th.getCause())
@@ -1543,6 +1569,11 @@ public class AMQConnection extends Close
         return _syncPublish;
     }
 
+    public boolean isMessageCompressionDesired()
+    {
+        return _compressMessages;
+    }
+
     public int getNextChannelID()
     {
         return _sessions.getNextChannelId();
@@ -1615,4 +1646,9 @@ public class AMQConnection extends Close
     {
         return super.setClosed();
     }
+
+    public int getMessageCompressionThresholdSize()
+    {
+        return _messageCompressionThresholdSize;
+    }
 }

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate.java Mon Aug 25 15:25:00 2014
@@ -20,6 +20,11 @@
  */
 package org.apache.qpid.client;
 
+import java.io.IOException;
+
+import javax.jms.JMSException;
+import javax.jms.XASession;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
@@ -27,10 +32,6 @@ import org.apache.qpid.framing.ProtocolV
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.Session;
 
-import javax.jms.JMSException;
-import javax.jms.XASession;
-import java.io.IOException;
-
 public interface AMQConnectionDelegate
 {
     ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException;
@@ -82,4 +83,6 @@ public interface AMQConnectionDelegate
     void setHeartbeatListener(HeartbeatListener listener);
 
     boolean supportsIsBound();
+
+    boolean isMessageCompressionSupported();
 }

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java Mon Aug 25 15:25:00 2014
@@ -21,6 +21,17 @@
 
 package org.apache.qpid.client;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.XASession;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,7 +40,6 @@ import org.apache.qpid.client.failover.F
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
 import org.apache.qpid.client.transport.ClientConnectionDelegate;
 import org.apache.qpid.common.ServerPropertyNames;
-
 import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ChannelLimitReachedException;
@@ -48,16 +58,6 @@ import org.apache.qpid.transport.Session
 import org.apache.qpid.transport.SessionException;
 import org.apache.qpid.transport.TransportException;
 
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.XASession;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-
 public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, ConnectionListener
 {
     /**
@@ -441,7 +441,11 @@ public class AMQConnectionDelegate_0_10 
         try
         {
             clientProps.put(ConnectionStartProperties.CLIENT_ID_0_10, _conn.getClientID());
-	        conSettings.setClientProperties(clientProps);
+            if(_conn.isMessageCompressionDesired())
+            {
+                clientProps.put(ConnectionStartProperties.QPID_MESSAGE_COMPRESSION_SUPPORTED, Boolean.TRUE.toString());
+            }
+            conSettings.setClientProperties(clientProps);
         }
         catch (JMSException e)
         {
@@ -504,4 +508,10 @@ public class AMQConnectionDelegate_0_10 
         //0-10 supports the isBound method
         return true;
     }
+
+    @Override
+    public boolean isMessageCompressionSupported()
+    {
+        return _qpidConnection.isMessageCompressionSupported();
+    }
 }

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java Mon Aug 25 15:25:00 2014
@@ -20,8 +20,21 @@
  */
 package org.apache.qpid.client;
 
+import java.io.IOException;
+import java.net.ConnectException;
+import java.nio.channels.UnresolvedAddressException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jms.JMSException;
+import javax.jms.XASession;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.failover.FailoverException;
 import org.apache.qpid.client.failover.FailoverProtectedOperation;
@@ -49,22 +62,11 @@ import org.apache.qpid.transport.network
 import org.apache.qpid.transport.network.security.SecurityLayer;
 import org.apache.qpid.transport.network.security.SecurityLayerFactory;
 
-import javax.jms.JMSException;
-import javax.jms.XASession;
-
-import java.io.IOException;
-import java.net.ConnectException;
-import java.nio.channels.UnresolvedAddressException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Set;
-
 public class AMQConnectionDelegate_8_0 implements AMQConnectionDelegate
 {
     private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionDelegate_8_0.class);
     private final AMQConnection _conn;
+    private boolean _messageCompressionSupported;
 
     public void closeConnection(long timeout) throws JMSException, AMQException
     {
@@ -139,6 +141,7 @@ public class AMQConnectionDelegate_8_0 i
             _conn.getFailoverPolicy().attainedConnection();
             _conn.setConnected(true);
             _conn.logConnected(network.getLocalAddress(), network.getRemoteAddress());
+            _messageCompressionSupported = checkMessageCompressionSupported();
             return null;
         }
         else
@@ -413,4 +416,17 @@ public class AMQConnectionDelegate_8_0 i
 
         return connectedToQpid;
     }
+
+    private boolean checkMessageCompressionSupported()
+    {
+        FieldTable serverProperties = _conn.getProtocolHandler().getProtocolSession().getConnectionStartServerProperties();
+        return serverProperties != null
+           && Boolean.parseBoolean(serverProperties.getString(ConnectionStartProperties.QPID_MESSAGE_COMPRESSION_SUPPORTED));
+
+    }
+
+    public boolean isMessageCompressionSupported()
+    {
+        return _messageCompressionSupported;
+    }
 }

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java Mon Aug 25 15:25:00 2014
@@ -17,6 +17,19 @@
  */
 package org.apache.qpid.client;
 
+import static org.apache.qpid.transport.Option.NONE;
+import static org.apache.qpid.transport.Option.SYNC;
+import static org.apache.qpid.transport.Option.UNRELIABLE;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,25 +49,15 @@ import org.apache.qpid.transport.Message
 import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.Option;
 import org.apache.qpid.transport.TransportException;
+import org.apache.qpid.util.GZIPUtils;
 import org.apache.qpid.util.Strings;
 
-import static org.apache.qpid.transport.Option.NONE;
-import static org.apache.qpid.transport.Option.SYNC;
-import static org.apache.qpid.transport.Option.UNRELIABLE;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
 /**
  * This is a 0_10 message producer.
  */
 public class BasicMessageProducer_0_10 extends BasicMessageProducer
 {
+
     private static final Logger _logger = LoggerFactory.getLogger(BasicMessageProducer_0_10.class);
     private byte[] userIDBytes;
 
@@ -204,6 +207,22 @@ public class BasicMessageProducer_0_10 e
         }
 
         ByteBuffer data = message.getData();
+
+        if(data != null
+           && data.remaining() > getConnection().getMessageCompressionThresholdSize()
+           && getConnection().getDelegate().isMessageCompressionSupported()
+           && getConnection().isMessageCompressionDesired()
+           && messageProps.getContentEncoding() == null)
+        {
+            byte[] compressed = GZIPUtils.compressBufferToArray(data);
+            if(compressed != null)
+            {
+                messageProps.setContentEncoding(GZIPUtils.GZIP_CONTENT_ENCODING);
+                data = ByteBuffer.wrap(compressed);
+            }
+        }
+
+
         messageProps.setContentLength(data == null ? 0 : data.remaining());
 
         // send the message

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java Mon Aug 25 15:25:00 2014
@@ -44,6 +44,7 @@ import org.apache.qpid.framing.ContentBo
 import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.ExchangeDeclareBody;
 import org.apache.qpid.framing.MethodRegistry;
+import org.apache.qpid.util.GZIPUtils;
 
 public class BasicMessageProducer_0_8 extends BasicMessageProducer
 {
@@ -147,7 +148,20 @@ public class BasicMessageProducer_0_8 ex
         contentHeaderProperties.setDeliveryMode((byte) deliveryMode);
         contentHeaderProperties.setPriority((byte) priority);
 
-        final int size = (payload != null) ? payload.limit() : 0;
+        int size = (payload != null) ? payload.remaining() : 0;
+
+        byte[] compressed;
+        if(size > getConnection().getMessageCompressionThresholdSize()
+               && getConnection().getDelegate().isMessageCompressionSupported()
+               && getConnection().isMessageCompressionDesired()
+               && contentHeaderProperties.getEncoding() == null
+               && (compressed = GZIPUtils.compressBufferToArray(payload)) != null)
+        {
+            contentHeaderProperties.setEncoding("gzip");
+            payload = ByteBuffer.wrap(compressed);
+            size = compressed.length;
+
+        }
         final int contentBodyFrameCount = calculateContentBodyFrameCount(payload);
         final AMQFrame[] frames = new AMQFrame[2 + contentBodyFrameCount];
 

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelper.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelper.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/CloseWhenNoRouteSettingsHelper.java Mon Aug 25 15:25:00 2014
@@ -18,11 +18,12 @@
  */
 package org.apache.qpid.client.handler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.properties.ConnectionStartProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Used during connection establishment to optionally set the "close when no route" client property

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java Mon Aug 25 15:25:00 2014
@@ -20,6 +20,13 @@
  */
 package org.apache.qpid.client.handler;
 
+import java.io.UnsupportedEncodingException;
+import java.util.StringTokenizer;
+
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+import javax.security.sasl.SaslException;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,12 +47,6 @@ import org.apache.qpid.framing.ProtocolV
 import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.properties.ConnectionStartProperties;
 
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-import java.io.UnsupportedEncodingException;
-import java.util.StringTokenizer;
-
 public class ConnectionStartMethodHandler implements StateAwareMethodListener<ConnectionStartBody>
 {
     private static final Logger _log = LoggerFactory.getLogger(ConnectionStartMethodHandler.class);
@@ -173,6 +174,9 @@ public class ConnectionStartMethodHandle
                 ConnectionURL url = getConnectionURL(session);
                 _closeWhenNoRouteHelper.setClientProperties(clientProperties, url, serverProperties);
 
+                clientProperties.setString(ConnectionStartProperties.QPID_MESSAGE_COMPRESSION_SUPPORTED,
+                                           String.valueOf(session.getAMQConnection().isMessageCompressionDesired()));
+
                 ConnectionStartOkBody connectionStartOkBody = session.getMethodRegistry().createConnectionStartOkBody(clientProperties,new AMQShortString(mechanism),saslResponse,new AMQShortString(locales));
                 // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
                 // TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
@@ -188,7 +192,7 @@ public class ConnectionStartMethodHandle
         else
         {
             _log.error("Broker requested Protocol [" + body.getVersionMajor() + "-" + body.getVersionMinor()
-                + "] which is not supported by this version of the client library");
+                       + "] which is not supported by this version of the client library");
 
             session.closeProtocolSession();
         }

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java Mon Aug 25 15:25:00 2014
@@ -20,6 +20,17 @@
  */
 package org.apache.qpid.client.message;
 
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+
+import javax.jms.JMSException;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,16 +39,11 @@ import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQSession_0_8;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
 import org.apache.qpid.framing.ContentBody;
 import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.MessageProperties;
-
-import javax.jms.JMSException;
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.List;
+import org.apache.qpid.util.GZIPUtils;
 
 public abstract class AbstractJMSMessageFactory implements MessageFactory
 {
@@ -52,46 +58,57 @@ public abstract class AbstractJMSMessage
         ByteBuffer data;
         final boolean debug = _logger.isDebugEnabled();
 
-        // we optimise the non-fragmented case to avoid copying
-        if ((bodies != null) && (bodies.size() == 1))
-        {
-            if (debug)
-            {
-                _logger.debug("Non-fragmented message body (bodySize=" + contentHeader.getBodySize() + ")");
-            }
+        byte[] uncompressed;
 
-            data = ByteBuffer.wrap(((ContentBody) bodies.get(0)).getPayload());
+        if(GZIPUtils.GZIP_CONTENT_ENCODING.equals(contentHeader.getProperties().getEncodingAsString())
+                && (uncompressed = GZIPUtils.uncompressStreamToArray(new BodyInputStream(bodies))) != null )
+        {
+            contentHeader.getProperties().setEncoding((String)null);
+            data = ByteBuffer.wrap(uncompressed);
         }
-        else if (bodies != null)
+        else
         {
-            if (debug)
+            // we optimise the non-fragmented case to avoid copying
+            if ((bodies != null) && (bodies.size() == 1))
             {
-                _logger.debug("Fragmented message body (" + bodies
-                        .size() + " frames, bodySize=" + contentHeader.getBodySize() + ")");
-            }
+                if (debug)
+                {
+                    _logger.debug("Non-fragmented message body (bodySize=" + contentHeader.getBodySize() + ")");
+                }
 
-            data = ByteBuffer.allocate((int) contentHeader.getBodySize()); // XXX: Is cast a problem?
-            final Iterator it = bodies.iterator();
-            while (it.hasNext())
+                data = ByteBuffer.wrap(((ContentBody) bodies.get(0)).getPayload());
+            }
+            else if (bodies != null)
             {
-                ContentBody cb = (ContentBody) it.next();
-                final ByteBuffer payload = ByteBuffer.wrap(cb.getPayload());
-                if(payload.isDirect() || payload.isReadOnly())
+                if (debug)
                 {
-                    data.put(payload);
+                    _logger.debug("Fragmented message body (" + bodies
+                            .size() + " frames, bodySize=" + contentHeader.getBodySize() + ")");
                 }
-                else
+
+                data = ByteBuffer.allocate((int) contentHeader.getBodySize()); // XXX: Is cast a problem?
+                final Iterator it = bodies.iterator();
+                while (it.hasNext())
                 {
-                    data.put(payload.array(), payload.arrayOffset(), payload.limit());
+                    ContentBody cb = (ContentBody) it.next();
+                    final ByteBuffer payload = ByteBuffer.wrap(cb.getPayload());
+                    if (payload.isDirect() || payload.isReadOnly())
+                    {
+                        data.put(payload);
+                    }
+                    else
+                    {
+                        data.put(payload.array(), payload.arrayOffset(), payload.limit());
+                    }
+
                 }
 
+                data.flip();
+            }
+            else // bodies == null
+            {
+                data = ByteBuffer.allocate(0);
             }
-
-            data.flip();
-        }
-        else // bodies == null
-        {
-            data = ByteBuffer.allocate(0);
         }
 
         if (debug)
@@ -132,22 +149,42 @@ public abstract class AbstractJMSMessage
             _logger.debug("Creating message from buffer with position=" + data.position() + " and remaining=" + data
                     .remaining());
         }
+        if(GZIPUtils.GZIP_CONTENT_ENCODING.equals(msgProps.getContentEncoding()))
+        {
+            byte[] uncompressed = GZIPUtils.uncompressBufferToArray(data);
+            if(uncompressed != null)
+            {
+                msgProps.setContentEncoding(null);
+                data = ByteBuffer.wrap(uncompressed);
+            }
+        }
         AMQMessageDelegate delegate = new AMQMessageDelegate_0_10(msgProps, deliveryProps, messageNbr);
 
         AbstractJMSMessage message = createMessage(delegate, data);
         return message;
     }
 
-    private static final String asString(byte[] bytes)
+    private ByteBuffer uncompressBody(final InputStream bodyInputStream) throws AMQException
     {
-        if (bytes == null)
+        final ByteBuffer data;
+        try(GZIPInputStream gzipInputStream = new GZIPInputStream(bodyInputStream))
         {
-            return null;
+            ByteArrayOutputStream uncompressedBuffer = new ByteArrayOutputStream();
+            int read;
+            byte[] buf = new byte[4096];
+            while((read = gzipInputStream.read(buf))!=-1)
+            {
+                uncompressedBuffer.write(buf,0,read);
+            }
+            byte[] uncompressedBytes = uncompressedBuffer.toByteArray();
+            data = ByteBuffer.wrap(uncompressedBytes);
         }
-        else
+        catch (IOException e)
         {
-            return new String(bytes);
+            // TODO - shouldn't happen
+            throw new AMQException("Error uncompressing gzipped message data", e);
         }
+        return data;
     }
 
 
@@ -174,4 +211,57 @@ public abstract class AbstractJMSMessage
         return msg;
     }
 
+    private class BodyInputStream extends InputStream
+    {
+        private final Iterator<ContentBody> _bodiesIter;
+        private byte[] _currentBuffer;
+        private int _currentPos;
+        public BodyInputStream(final List<ContentBody> bodies)
+        {
+            _bodiesIter = bodies.iterator();
+            _currentBuffer = _bodiesIter.next().getPayload();
+            _currentPos = 0;
+        }
+
+        @Override
+        public int read() throws IOException
+        {
+            byte[] buf = new byte[1];
+            int size = read(buf);
+            if(size == -1)
+            {
+                throw new EOFException();
+            }
+            else
+            {
+                return ((int)buf[0])&0xff;
+            }
+        }
+
+        @Override
+        public int read(final byte[] dst, final int off, final int len)
+        {
+            while(_currentPos == _currentBuffer.length)
+            {
+                if(!_bodiesIter.hasNext())
+                {
+                    return -1;
+                }
+                else
+                {
+                    _currentBuffer = _bodiesIter.next().getPayload();
+                    _currentPos = 0;
+                }
+            }
+            int size = Math.min(len, _currentBuffer.length - _currentPos);
+            System.arraycopy(_currentBuffer,_currentPos, dst,off,size);
+            _currentPos+=size;
+            return size;
+        }
+
+        @Override
+        public void close()
+        {
+        }
+    }
 }

Modified: qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java (original)
+++ qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java Mon Aug 25 15:25:00 2014
@@ -70,6 +70,11 @@ public interface ConnectionURL
      */
     public static final String OPTIONS_CLOSE_WHEN_NO_ROUTE = "closeWhenNoRoute";
 
+
+    public static final String OPTIONS_COMPRESS_MESSAGES = "compressMessages";
+    public static final String OPTIONS_MESSAGES_COMPRESSION_THRESHOLD_SIZE = "messageCompressionThresholdSize";
+
+
     public static final String OPTIONS_DEFAULT_TOPIC_EXCHANGE = "defaultTopicExchange";
     public static final String OPTIONS_DEFAULT_QUEUE_EXCHANGE = "defaultQueueExchange";
     public static final String OPTIONS_TEMPORARY_TOPIC_EXCHANGE = "temporaryTopicExchange";

Modified: qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java (original)
+++ qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java Mon Aug 25 15:25:00 2014
@@ -254,6 +254,19 @@ public class ClientProperties
     public static final String CONNECTION_OPTION_SSL_VERIFY_HOST_NAME = "qpid.connection_ssl_verify_hostname";
     public static final boolean DEFAULT_CONNECTION_OPTION_SSL_VERIFY_HOST_NAME = true;
 
+    /**
+     * System property to set a default value for a connection option 'compress_messages'
+     */
+    public static final String CONNECTION_OPTION_COMPRESS_MESSAGES = "qpid.connection_compress_messages";
+    public static final boolean DEFAULT_CONNECTION_OPTION_COMPRESS_MESSAGES = false;
+
+
+    /**
+     * System property to set a default value for a connection option 'message_compression_threshold_size'
+     */
+    public static final String CONNECTION_OPTION_MESSAGE_COMPRESSION_THRESHOLD_SIZE = "qpid.message_compression_threshold_size";
+    public static final int DEFAULT_MESSAGE_COMPRESSION_THRESHOLD_SIZE = 102400;
+
     private ClientProperties()
     {
         //No instances

Modified: qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java (original)
+++ qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java Mon Aug 25 15:25:00 2014
@@ -20,13 +20,13 @@
  */
 package org.apache.qpid.framing;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class BasicContentHeaderProperties
 {
     //persistent & non-persistent constants, values as per JMS DeliveryMode
@@ -83,8 +83,48 @@ public class BasicContentHeaderPropertie
     private byte[] _encodedForm;
 
 
+    public BasicContentHeaderProperties(BasicContentHeaderProperties other)
+    {
+        if(other._headers != null)
+        {
+            byte[] encodedHeaders = other._headers.getDataAsBytes();
+
+            _headers = new FieldTable(encodedHeaders,0,encodedHeaders.length);
+
+        }
+
+        _contentType = other._contentType;
+
+        _encoding = other._encoding;
+
+        _deliveryMode = other._deliveryMode;
+
+        _priority = other._priority;
+
+        _correlationId = other._correlationId;
+
+        _replyTo = other._replyTo;
+
+        _expiration = other._expiration;
+
+        _messageId = other._messageId;
+
+        _timestamp = other._timestamp;
+
+        _type = other._type;
+
+        _userId = other._userId;
+
+        _appId = other._appId;
+
+        _clusterId = other._clusterId;
+        
+        _propertyFlags = other._propertyFlags;
+    }
+
     public BasicContentHeaderProperties()
-    { }
+    { 
+    }
 
     public int getPropertyListSize()
     {

Modified: qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java (original)
+++ qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java Mon Aug 25 15:25:00 2014
@@ -84,7 +84,7 @@ public class FieldTable
         _encodedSize = length;
     }
 
-    public FieldTable(byte[] encodedForm, int offset, int length) throws IOException
+    public FieldTable(byte[] encodedForm, int offset, int length)
     {
         this();
         _encodedForm = encodedForm;
@@ -858,7 +858,17 @@ public class FieldTable
             }
 
         }
-        return _encodedForm.clone();
+        else if(_encodedFormOffset == 0 && _encodedSize == _encodedForm.length)
+        {
+            return _encodedForm.clone();
+        }
+        else
+        {
+            byte[] encodedCopy = new byte[(int) _encodedSize];
+            System.arraycopy(_encodedForm,_encodedFormOffset,encodedCopy,0,(int)_encodedSize);
+            return encodedCopy;
+        }
+
     }
 
     public long getEncodedSize()

Modified: qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java (original)
+++ qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java Mon Aug 25 15:25:00 2014
@@ -41,6 +41,9 @@ public class ConnectionStartProperties
      */
     public static final String QPID_CLOSE_WHEN_NO_ROUTE = "qpid.close_when_no_route";
 
+    public static final String QPID_MESSAGE_COMPRESSION_SUPPORTED = "qpid.message_compression_supported";
+
+
     public static final String CLIENT_ID_0_10 = "clientName";
     public static final String CLIENT_ID_0_8 = "instance";
 

Modified: qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java (original)
+++ qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java Mon Aug 25 15:25:00 2014
@@ -41,6 +41,7 @@ import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslServer;
 
 import org.apache.qpid.framing.ProtocolVersion;
+import org.apache.qpid.properties.ConnectionStartProperties;
 import org.apache.qpid.transport.network.Assembler;
 import org.apache.qpid.transport.network.Disassembler;
 import org.apache.qpid.transport.network.InputHandler;
@@ -78,6 +79,7 @@ public class Connection extends Connecti
     private long _lastReadTime;
     private NetworkConnection _networkConnection;
     private FrameSizeObserver _frameSizeObserver;
+    private boolean _messageCompressionSupported;
 
     public enum State { NEW, CLOSED, OPENING, OPEN, CLOSING, CLOSE_RCVD, RESUMING }
 
@@ -699,6 +701,7 @@ public class Connection extends Connecti
     public void setServerProperties(final Map<String, Object> serverProperties)
     {
         _serverProperties = serverProperties == null ? Collections.<String, Object>emptyMap() : serverProperties;
+        _messageCompressionSupported = Boolean.parseBoolean(String.valueOf(_serverProperties.get(ConnectionStartProperties.QPID_MESSAGE_COMPRESSION_SUPPORTED)));
     }
 
     public Map<String, Object> getServerProperties()
@@ -848,4 +851,9 @@ public class Connection extends Connecti
                                     };
         }
     }
+
+    public boolean isMessageCompressionSupported()
+    {
+        return _messageCompressionSupported;
+    }
 }

Modified: qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/util/ByteBufferInputStream.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/util/ByteBufferInputStream.java?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/util/ByteBufferInputStream.java (original)
+++ qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/util/ByteBufferInputStream.java Mon Aug 25 15:25:00 2014
@@ -92,4 +92,9 @@ public class ByteBufferInputStream exten
     {
         return _buffer.remaining();
     }
+
+    @Override
+    public void close()
+    {
+    }
 }

Modified: qpid/branches/0.30/qpid/java/pom.xml
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/pom.xml?rev=1620344&r1=1620343&r2=1620344&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/pom.xml (original)
+++ qpid/branches/0.30/qpid/java/pom.xml Mon Aug 25 15:25:00 2014
@@ -54,6 +54,7 @@
     <qpid.home.qbtc.output>${qpid.home}${file.separator}target${file.separator}qbtc-output</qpid.home.qbtc.output> <!-- override for broker tests -->
     <qpid.work>${project.build.directory}${file.separator}QPID_WORK</qpid.work>
 
+    <argLine />
     <profile>java-mms.0-10</profile>
     <profile.broker.language>java</profile.broker.language>
     <profile.broker.type>internal</profile.broker.type>



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


Mime
View raw message