Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 51188 invoked from network); 17 Feb 2009 19:27:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Feb 2009 19:27:52 -0000 Received: (qmail 77875 invoked by uid 500); 17 Feb 2009 19:27:51 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 77860 invoked by uid 500); 17 Feb 2009 19:27:51 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 77851 invoked by uid 99); 17 Feb 2009 19:27:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2009 11:27:51 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2009 19:27:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8020E2388A3D; Tue, 17 Feb 2009 19:27:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r745205 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/CommonAssemblyInfo.cs main/csharp/OpenWire/OpenWireBinaryWriter.cs main/csharp/State/ConnectionState.cs test/csharp/CommonAssemblyInfo.cs Date: Tue, 17 Feb 2009 19:27:23 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090217192723.8020E2388A3D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgomes Date: Tue Feb 17 19:27:22 2009 New Revision: 745205 URL: http://svn.apache.org/viewvc?rev=745205&view=rev Log: Applied patch submitted by Jan Willem. Thanks, Jan! Fixes [AMQNET-128]. (See https://issues.apache.org/activemq/browse/AMQNET-128) Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs?rev=745205&r1=745204&r2=745205&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs Tue Feb 17 19:27:22 2009 @@ -5,7 +5,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.3082 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs?rev=745205&r1=745204&r2=745205&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs Tue Feb 17 19:27:22 2009 @@ -14,26 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -using Apache.NMS.ActiveMQ.Commands; using System; using System.Collections; using System.IO; -using System.Text; namespace Apache.NMS.ActiveMQ.OpenWire { - /// + /// /// A BinaryWriter that switches the endian orientation of the write opperations so that they /// are compatible with marshalling used by OpenWire. - /// + /// [CLSCompliant(false)] - public class OpenWireBinaryWriter : BinaryWriter - { - - public OpenWireBinaryWriter(Stream output) : base(output) + public class OpenWireBinaryWriter : BinaryWriter + { + public const int MAXSTRINGLEN = short.MaxValue; + + public OpenWireBinaryWriter(Stream output) + : base(output) { } - + /// /// Method Write /// @@ -42,7 +42,7 @@ { base.Write(EndianSupport.SwitchEndian(value)); } - + /// /// Method Write /// @@ -51,7 +51,7 @@ { base.Write(EndianSupport.SwitchEndian(value)); } - + /// /// Method Write /// @@ -61,7 +61,7 @@ int x = EndianSupport.SwitchEndian(value); base.Write(x); } - + /// /// Method Write /// @@ -71,12 +71,13 @@ public override void Write(char[] chars, int index, int count) { char[] t = new char[count]; - for( int i=0; i < count; i++ ) { - t[index+i] = EndianSupport.SwitchEndian(t[index+i]); + for(int i = 0; i < count; i++) + { + t[index + i] = EndianSupport.SwitchEndian(t[index + i]); } base.Write(t); } - + /// /// Method Write /// @@ -85,7 +86,7 @@ { Write(chars, 0, chars.Length); } - + /// /// Method Write /// @@ -94,18 +95,18 @@ { base.Write(EndianSupport.SwitchEndian(value)); } - - + + /// /// Method Write /// /// A char public override void Write(char ch) { - base.Write( (byte)( ( ch>>8 ) & 0xFF ) ); - base.Write( (byte)( ch & 0xFF ) ); + base.Write((byte) ((ch >> 8) & 0xFF)); + base.Write((byte) (ch & 0xFF)); } - + /// /// Method Write /// @@ -114,7 +115,7 @@ { base.Write(EndianSupport.SwitchEndian(value)); } - + /// /// Method Write /// @@ -123,91 +124,211 @@ { base.Write(EndianSupport.SwitchEndian(value)); } - - + + public override void Write(String text) + { + foreach(string textPackage in new StringPackageSplitter(text)) + { + WriteString(textPackage); + } + } + /// /// Method Write /// /// A string - public override void Write(String text) + private void WriteString(String text) + { + if(text != null) + { + if(text.Length > OpenWireBinaryWriter.MAXSTRINGLEN) + { + throw new IOException(String.Format("Cannot marshall string longer than: {0} characters, supplied string was: {1} characters", OpenWireBinaryWriter.MAXSTRINGLEN, text.Length)); + } + + int strlen = text.Length; + short utflen = 0; + int c = 0; + int count = 0; + + char[] charr = text.ToCharArray(); + + for(int i = 0; i < strlen; i++) + { + c = charr[i]; + if((c >= 0x0001) && (c <= 0x007F)) + { + utflen++; + } + else if(c > 0x07FF) + { + utflen += 3; + } + else + { + utflen += 2; + } + } + + Write((short) utflen); + + byte[] bytearr = new byte[utflen]; + for(int i = 0; i < strlen; i++) + { + c = charr[i]; + if((c >= 0x0001) && (c <= 0x007F)) + { + bytearr[count++] = (byte) c; + } + else if(c > 0x07FF) + { + bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F)); + bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F)); + bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); + } + else + { + bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F)); + bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); + } + } + + Write(bytearr); + + } + else + { + Write((short) -1); + } + } + + /// + /// Method Write + /// + /// A double + public override void Write(float value) { - if (text != null) - { - if( text.Length > short.MaxValue ) { - throw new IOException("Cannot marshall string longer than: "+short.MaxValue+" characters, supplied steing was: "+text.Length+" characters"); - } - short strlen = (short)text.Length; - short utflen = 0; - int c, count = 0; - - char[] charr = text.ToCharArray(); - - for (int i = 0; i < strlen; i++) - { - c = charr[i]; - if ((c >= 0x0001) && (c <= 0x007F)) - { - utflen++; - } - else if (c > 0x07FF) - { - utflen += 3; - } - else - { - utflen += 2; - } - } - - Write(utflen); - byte[] bytearr = new byte[utflen]; - for (int i = 0; i < strlen; i++) - { - c = charr[i]; - if ((c >= 0x0001) && (c <= 0x007F)) - { - bytearr[count++] = (byte) c; - } - else if (c > 0x07FF) - { - bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F)); - bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F)); - bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); - } - else - { - bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F)); - bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); - } - } - - Write(bytearr); - - } - else - { - Write((short)-1); - } - } - - /// - /// Method Write - /// - /// A double - public override void Write(float value) - { - base.Write(EndianSupport.SwitchEndian(value)); - } - - /// - /// Method Write - /// - /// A double - public override void Write(double value) - { - base.Write(EndianSupport.SwitchEndian(value)); - } - - } + base.Write(EndianSupport.SwitchEndian(value)); + } + + /// + /// Method Write + /// + /// A double + public override void Write(double value) + { + base.Write(EndianSupport.SwitchEndian(value)); + } + } + + #region StringPackageSplitter + + /// + /// StringPackageSplitter + /// + class StringPackageSplitter : IEnumerable + { + public StringPackageSplitter(string value) + { + this.value = value; + } + + /// + /// Emumerator class for StringPackageSplitter + /// + class StringPackageSplitterEnumerator : IEnumerator + { + /// + /// + /// + public StringPackageSplitterEnumerator(StringPackageSplitter parent) + { + this.parent = parent; + } + + private int Position = -1; + private StringPackageSplitter parent; + + #region IEnumerator Members + + public string Current + { + get + { + int delta = parent.value.Length - Position; + + if(delta >= OpenWireBinaryWriter.MAXSTRINGLEN) + { + return parent.value.Substring(Position, OpenWireBinaryWriter.MAXSTRINGLEN); + } + else + { + return parent.value.Substring(Position, delta); + } + } + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + } + + #endregion + + #region IEnumerator Members + + object IEnumerator.Current + { + get { return parent.value.Substring(Position, OpenWireBinaryWriter.MAXSTRINGLEN); } + } + + public bool MoveNext() + { + if(parent.value == null) + { + return false; + } + + if(Position == -1) + { + Position = 0; + return true; + } + + if((Position + OpenWireBinaryWriter.MAXSTRINGLEN) < parent.value.Length) + { + Position += OpenWireBinaryWriter.MAXSTRINGLEN; + return true; + } + else + { + return false; + } + } + + public void Reset() + { + Position = -1; + } + + #endregion + } + + private String value; + + #region IEnumerable Members + + IEnumerator IEnumerable.GetEnumerator() + { + return new StringPackageSplitterEnumerator(this); + } + + #endregion + } + + #endregion // END StringPackageSplitter } Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs?rev=745205&r1=745204&r2=745205&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs Tue Feb 17 19:27:22 2009 @@ -127,7 +127,7 @@ } System.Diagnostics.Debug.Assert(false, string.Format("Session '{0}' did not exist in the sessions collection.\n\nSessions:-\n{1}", id, sessionList)); - throw; + throw ex; } #endif } Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs?rev=745205&r1=745204&r2=745205&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs Tue Feb 17 19:27:22 2009 @@ -5,7 +5,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.3082 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated.