activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r808223 [1/2] - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/ Apache...
Date Wed, 26 Aug 2009 23:42:29 GMT
Author: jgomes
Date: Wed Aug 26 23:42:27 2009
New Revision: 808223

URL: http://svn.apache.org/viewvc?rev=808223&view=rev
Log:
Moved PrimitiveMap, OpenWireBinaryReader, OpenWireBinaryWriter, EndianSupport, MessagePropertyHelper and associated tests from Apache.NMS.ActiveMQ into Apache.NMS.  These are generally useful classes that should be shared among the providers instead of forcing all providers to re-implement these highly useful and complex classes.
Renamed OpenWireBinaryWriter to EndianBinaryWriter.
Renamed OpenWireBinaryReader to EndianBinaryReader.
Implemented MapMessage marshaling in Apache.NMS.MSMQ.

Added:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/EndianBinaryReader.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryReader.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/EndianBinaryWriter.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/EndianSupport.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/EndianSupport.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/MessagePropertyHelper.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/MessagePropertyHelper.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/PrimitiveMap.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/EndianBinaryReaderTest.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/OpenWireBinaryReaderTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/EndianBinaryWriterTest.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/OpenWireBinaryWriterTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/EndianTest.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/EndianTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/PrimitiveMapTest.cs
      - copied, changed from r806651, activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/PrimitiveMapTest.cs
Removed:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/EndianSupport.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/MessagePropertyHelper.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryReader.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/EndianTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/OpenWireBinaryReaderTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/OpenWireBinaryWriterTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/PrimitiveMapTest.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/PrimitiveMap.cs
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMapMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQTextMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/WireFormatInfo.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireFormat.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/DefaultMessageConverter.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MapMessage.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms-test.csproj
    activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms.csproj

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMapMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMapMessage.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMapMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMapMessage.cs Wed Aug 26 23:42:27 2009
@@ -14,52 +14,50 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using Apache.NMS.ActiveMQ.OpenWire;
-using Apache.NMS;
-using System;
 
+using Apache.NMS.Util;
+using Apache.NMS.ActiveMQ.OpenWire;
 
 namespace Apache.NMS.ActiveMQ.Commands
 {
-    public class ActiveMQMapMessage : ActiveMQMessage, IMapMessage
-    {
-        public const byte ID_ACTIVEMQMAPMESSAGE = 25;
-
-        private PrimitiveMap body;
-
-
-        public override byte GetDataStructureType()
-        {
-            return ID_ACTIVEMQMAPMESSAGE;
-        }
-
-        public IPrimitiveMap Body
-        {
-            get {
-                if (body == null)
-                {
-                    body = PrimitiveMap.Unmarshal(Content);
-                }
-                return body;
-            }
-        }
-
-        public override void BeforeMarshall(OpenWireFormat wireFormat)
-        {
-            if (body == null)
-            {
-                Content = null;
-            }
-            else
-            {
-                Content = body.Marshal();
-            }
-
-            Tracer.Debug("BeforeMarshalling, content is: " + Content);
-
-            base.BeforeMarshall(wireFormat);
-        }
-
-    }
+	public class ActiveMQMapMessage : ActiveMQMessage, IMapMessage
+	{
+		public const byte ID_ACTIVEMQMAPMESSAGE = 25;
+
+		private PrimitiveMap body;
+
+
+		public override byte GetDataStructureType()
+		{
+			return ID_ACTIVEMQMAPMESSAGE;
+		}
+
+		public IPrimitiveMap Body
+		{
+			get
+			{
+				if(body == null)
+				{
+					body = PrimitiveMap.Unmarshal(Content);
+				}
+				return body;
+			}
+		}
+
+		public override void BeforeMarshall(OpenWireFormat wireFormat)
+		{
+			if(body == null)
+			{
+				Content = null;
+			}
+			else
+			{
+				Content = body.Marshal();
+			}
+
+			Tracer.Debug("BeforeMarshalling, content is: " + Content);
+
+			base.BeforeMarshall(wireFormat);
+		}
+	}
 }
-

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs Wed Aug 26 23:42:27 2009
@@ -14,275 +14,275 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using System;
 
+using System;
 using Apache.NMS.ActiveMQ.OpenWire;
 using Apache.NMS.ActiveMQ.State;
 using Apache.NMS.Util;
 
 namespace Apache.NMS.ActiveMQ.Commands
 {
-    public delegate void AcknowledgeHandler(ActiveMQMessage message);
+	public delegate void AcknowledgeHandler(ActiveMQMessage message);
 
-    public class ActiveMQMessage : Message, IMessage, MarshallAware
-    {
-        public const byte ID_ACTIVEMQMESSAGE = 23;
-
-        private MessagePropertyHelper propertyHelper;
-        private PrimitiveMap properties;
-
-        public event AcknowledgeHandler Acknowledger;
-
-        public static ActiveMQMessage Transform(IMessage message)
-        {
-            return (ActiveMQMessage) message;
-        }
-
-        // TODO generate Equals method
-        // TODO generate GetHashCode method
-
-        public ActiveMQMessage()
-                : base()
-        {
-            Timestamp = DateUtils.ToJavaTimeUtc(DateTime.UtcNow);
-        }
-
-        public override byte GetDataStructureType()
-        {
-            return ID_ACTIVEMQMESSAGE;
-        }
-
-        public void Acknowledge()
-        {
-            if(null == Acknowledger)
-            {
-                throw new NMSException("No Acknowledger has been associated with this message: " + this);
-            }
-            else
-            {
-                Acknowledger(this);
-            }
-        }
-
-        #region Properties
-
-        public IPrimitiveMap Properties
-        {
-            get
-            {
-                if(null == properties)
-                {
-                    properties = PrimitiveMap.Unmarshal(MarshalledProperties);
-                    propertyHelper = new MessagePropertyHelper(this, properties);
-                }
-
-                return propertyHelper;
-            }
-        }
-
-        public IDestination FromDestination
-        {
-            get { return Destination; }
-            set { this.Destination = ActiveMQDestination.Transform(value); }
-        }
-
-        /// <summary>
-        /// The correlation ID used to correlate messages with conversations or long running business processes
-        /// </summary>
-        public string NMSCorrelationID
-        {
-            get { return CorrelationId; }
-            set { CorrelationId = value; }
-        }
-
-        /// <summary>
-        /// The destination of the message
-        /// </summary>
-        public IDestination NMSDestination
-        {
-            get { return Destination; }
-        }
-
-        private TimeSpan timeToLive = TimeSpan.FromMilliseconds(0);
-        /// <summary>
-        /// The time in milliseconds that this message should expire in
-        /// </summary>
-        public TimeSpan NMSTimeToLive
-        {
-            get { return timeToLive; }
-
-            set
-            {
-                timeToLive = value;
-                if(timeToLive.TotalMilliseconds > 0)
-                {
-                    Expiration = Timestamp + (long) timeToLive.TotalMilliseconds;
-                }
-                else
-                {
-                    Expiration = 0;
-                }
-            }
-        }
-
-        /// <summary>
-        /// The message ID which is set by the provider
-        /// </summary>
-        public string NMSMessageId
-        {
-            get
-            {
-                if(null != MessageId)
-                {
-                    return BaseDataStreamMarshaller.ToString(MessageId);
-                }
-
-                return String.Empty;
-            }
-        }
-
-        /// <summary>
-        /// Whether or not this message is persistent
-        /// </summary>
-        public MsgDeliveryMode NMSDeliveryMode
-        {
-            get { return (Persistent ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent); }
-            set { Persistent = (MsgDeliveryMode.Persistent == value); }
-        }
-
-        /// <summary>
-        /// The Priority on this message
-        /// </summary>
-        public MsgPriority NMSPriority
-        {
-            get { return (MsgPriority) Priority; }
-            set { Priority = (byte) value; }
-        }
-
-        /// <summary>
-        /// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully.
-        /// </summary>
-        public bool NMSRedelivered
-        {
-            get { return (RedeliveryCounter > 0); }
-        }
-
-        /// <summary>
-        /// The destination that the consumer of this message should send replies to
-        /// </summary>
-        public IDestination NMSReplyTo
-        {
-            get { return ReplyTo; }
-            set { ReplyTo = ActiveMQDestination.Transform(value); }
-        }
-
-        /// <summary>
-        /// The timestamp the broker added to the message
-        /// </summary>
-        public DateTime NMSTimestamp
-        {
-            get { return DateUtils.ToDateTime(Timestamp); }
-            set
-            {
-                Timestamp = DateUtils.ToJavaTimeUtc(value);
-                if(timeToLive.TotalMilliseconds > 0)
-                {
-                    Expiration = Timestamp + (long) timeToLive.TotalMilliseconds;
-                }
-            }
-        }
-
-        /// <summary>
-        /// The type name of this message
-        /// </summary>
-        public string NMSType
-        {
-            get { return Type; }
-            set { Type = value; }
-        }
-
-        #endregion
-
-        #region NMS Extension headers
-
-        /// <summary>
-        /// Returns the number of times this message has been redelivered to other consumers without being acknowledged successfully.
-        /// </summary>
-        public int NMSXDeliveryCount
-        {
-            get { return RedeliveryCounter + 1; }
-        }
-
-        /// <summary>
-        /// The Message Group ID used to group messages together to the same consumer for the same group ID value
-        /// </summary>
-        public string NMSXGroupID
-        {
-            get { return GroupID; }
-            set { GroupID = value; }
-        }
-        /// <summary>
-        /// The Message Group Sequence counter to indicate the position in a group
-        /// </summary>
-        public int NMSXGroupSeq
-        {
-            get { return GroupSequence; }
-            set { GroupSequence = value; }
-        }
-
-        /// <summary>
-        /// Returns the ID of the producers transaction
-        /// </summary>
-        public string NMSXProducerTXID
-        {
-            get
-            {
-                TransactionId txnId = OriginalTransactionId;
-                if(null == txnId)
-                {
-                    txnId = TransactionId;
-                }
-
-                if(null != txnId)
-                {
-                    return BaseDataStreamMarshaller.ToString(txnId);
-                }
-
-                return String.Empty;
-            }
-        }
-
-        #endregion
-
-        public object GetObjectProperty(string name)
-        {
-            return Properties[name];
-        }
-
-        public void SetObjectProperty(string name, object value)
-        {
-            Properties[name] = value;
-        }
-
-        // MarshallAware interface
-        public override bool IsMarshallAware()
-        {
-            return true;
-        }
-
-        public override void BeforeMarshall(OpenWireFormat wireFormat)
-        {
-            MarshalledProperties = null;
-            if(properties != null)
-            {
-                MarshalledProperties = properties.Marshal();
-            }
-        }
-
-        public override Response visit(ICommandVisitor visitor)
-        {
-            return visitor.processMessage(this);
-        }
-    }
+	public class ActiveMQMessage : Message, IMessage, MarshallAware
+	{
+		public const byte ID_ACTIVEMQMESSAGE = 23;
+
+		private MessagePropertyHelper propertyHelper;
+		private PrimitiveMap properties;
+
+		public event AcknowledgeHandler Acknowledger;
+
+		public static ActiveMQMessage Transform(IMessage message)
+		{
+			return (ActiveMQMessage) message;
+		}
+
+		// TODO generate Equals method
+		// TODO generate GetHashCode method
+
+		public ActiveMQMessage()
+			: base()
+		{
+			Timestamp = DateUtils.ToJavaTimeUtc(DateTime.UtcNow);
+		}
+
+		public override byte GetDataStructureType()
+		{
+			return ID_ACTIVEMQMESSAGE;
+		}
+
+		public void Acknowledge()
+		{
+			if(null == Acknowledger)
+			{
+				throw new NMSException("No Acknowledger has been associated with this message: " + this);
+			}
+			else
+			{
+				Acknowledger(this);
+			}
+		}
+
+		#region Properties
+
+		public IPrimitiveMap Properties
+		{
+			get
+			{
+				if(null == properties)
+				{
+					properties = PrimitiveMap.Unmarshal(MarshalledProperties);
+					propertyHelper = new MessagePropertyHelper(this, properties);
+				}
+
+				return propertyHelper;
+			}
+		}
+
+		public IDestination FromDestination
+		{
+			get { return Destination; }
+			set { this.Destination = ActiveMQDestination.Transform(value); }
+		}
+
+		/// <summary>
+		/// The correlation ID used to correlate messages with conversations or long running business processes
+		/// </summary>
+		public string NMSCorrelationID
+		{
+			get { return CorrelationId; }
+			set { CorrelationId = value; }
+		}
+
+		/// <summary>
+		/// The destination of the message
+		/// </summary>
+		public IDestination NMSDestination
+		{
+			get { return Destination; }
+		}
+
+		private TimeSpan timeToLive = TimeSpan.FromMilliseconds(0);
+		/// <summary>
+		/// The time in milliseconds that this message should expire in
+		/// </summary>
+		public TimeSpan NMSTimeToLive
+		{
+			get { return timeToLive; }
+
+			set
+			{
+				timeToLive = value;
+				if(timeToLive.TotalMilliseconds > 0)
+				{
+					Expiration = Timestamp + (long) timeToLive.TotalMilliseconds;
+				}
+				else
+				{
+					Expiration = 0;
+				}
+			}
+		}
+
+		/// <summary>
+		/// The message ID which is set by the provider
+		/// </summary>
+		public string NMSMessageId
+		{
+			get
+			{
+				if(null != MessageId)
+				{
+					return BaseDataStreamMarshaller.ToString(MessageId);
+				}
+
+				return String.Empty;
+			}
+		}
+
+		/// <summary>
+		/// Whether or not this message is persistent
+		/// </summary>
+		public MsgDeliveryMode NMSDeliveryMode
+		{
+			get { return (Persistent ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent); }
+			set { Persistent = (MsgDeliveryMode.Persistent == value); }
+		}
+
+		/// <summary>
+		/// The Priority on this message
+		/// </summary>
+		public MsgPriority NMSPriority
+		{
+			get { return (MsgPriority) Priority; }
+			set { Priority = (byte) value; }
+		}
+
+		/// <summary>
+		/// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully.
+		/// </summary>
+		public bool NMSRedelivered
+		{
+			get { return (RedeliveryCounter > 0); }
+		}
+
+		/// <summary>
+		/// The destination that the consumer of this message should send replies to
+		/// </summary>
+		public IDestination NMSReplyTo
+		{
+			get { return ReplyTo; }
+			set { ReplyTo = ActiveMQDestination.Transform(value); }
+		}
+
+		/// <summary>
+		/// The timestamp the broker added to the message
+		/// </summary>
+		public DateTime NMSTimestamp
+		{
+			get { return DateUtils.ToDateTime(Timestamp); }
+			set
+			{
+				Timestamp = DateUtils.ToJavaTimeUtc(value);
+				if(timeToLive.TotalMilliseconds > 0)
+				{
+					Expiration = Timestamp + (long) timeToLive.TotalMilliseconds;
+				}
+			}
+		}
+
+		/// <summary>
+		/// The type name of this message
+		/// </summary>
+		public string NMSType
+		{
+			get { return Type; }
+			set { Type = value; }
+		}
+
+		#endregion
+
+		#region NMS Extension headers
+
+		/// <summary>
+		/// Returns the number of times this message has been redelivered to other consumers without being acknowledged successfully.
+		/// </summary>
+		public int NMSXDeliveryCount
+		{
+			get { return RedeliveryCounter + 1; }
+		}
+
+		/// <summary>
+		/// The Message Group ID used to group messages together to the same consumer for the same group ID value
+		/// </summary>
+		public string NMSXGroupID
+		{
+			get { return GroupID; }
+			set { GroupID = value; }
+		}
+		/// <summary>
+		/// The Message Group Sequence counter to indicate the position in a group
+		/// </summary>
+		public int NMSXGroupSeq
+		{
+			get { return GroupSequence; }
+			set { GroupSequence = value; }
+		}
+
+		/// <summary>
+		/// Returns the ID of the producers transaction
+		/// </summary>
+		public string NMSXProducerTXID
+		{
+			get
+			{
+				TransactionId txnId = OriginalTransactionId;
+				if(null == txnId)
+				{
+					txnId = TransactionId;
+				}
+
+				if(null != txnId)
+				{
+					return BaseDataStreamMarshaller.ToString(txnId);
+				}
+
+				return String.Empty;
+			}
+		}
+
+		#endregion
+
+		public object GetObjectProperty(string name)
+		{
+			return Properties[name];
+		}
+
+		public void SetObjectProperty(string name, object value)
+		{
+			Properties[name] = value;
+		}
+
+		// MarshallAware interface
+		public override bool IsMarshallAware()
+		{
+			return true;
+		}
+
+		public override void BeforeMarshall(OpenWireFormat wireFormat)
+		{
+			MarshalledProperties = null;
+			if(properties != null)
+			{
+				MarshalledProperties = properties.Marshal();
+			}
+		}
+
+		public override Response visit(ICommandVisitor visitor)
+		{
+			return visitor.processMessage(this);
+		}
+	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQTextMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQTextMessage.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQTextMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQTextMessage.cs Wed Aug 26 23:42:27 2009
@@ -14,81 +14,81 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using Apache.NMS;
-using Apache.NMS.ActiveMQ.OpenWire;
+
 using System;
 using System.IO;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.ActiveMQ.Commands
 {
-    public class ActiveMQTextMessage : ActiveMQMessage, ITextMessage
-    {
-        public const byte ID_ACTIVEMQTEXTMESSAGE = 28;
-
-        private String text;
-
-        public ActiveMQTextMessage()
-        {
-        }
-
-        public ActiveMQTextMessage(String text)
-        {
-            this.Text = text;
-        }
-
-        // TODO generate Equals method
-        // TODO generate GetHashCode method
-        // TODO generate ToString method
-
-        public override string ToString()
-        {
-            return base.ToString() + " Text="+Text;
-        }
-
-        public override byte GetDataStructureType()
-        {
-            return ID_ACTIVEMQTEXTMESSAGE;
-        }
-
-        // Properties
-
-        public string Text
-        {
-            get {
-                if (text == null)
-                {
-                    // now lets read the content
-                    byte[] data = this.Content;
-                    if (data != null)
-                    {
-                        MemoryStream stream = new MemoryStream(data);
-                        OpenWireBinaryReader reader = new OpenWireBinaryReader(stream);
-                        text = reader.ReadString32();
-                    }
-                }
-                return text;
-            }
-
-            set {
-                this.text = value;
-                byte[] data = null;
-                if (text != null)
-                {
-                    // TODO lets make the evaluation of the Content lazy!
-
-                    // Set initial size to the size of the string the UTF-8 encode could
-                    // result in more if there are chars that encode to multibye values.
-                    MemoryStream stream = new MemoryStream( text.Length );
-                    OpenWireBinaryWriter writer = new OpenWireBinaryWriter(stream);
-
-                    writer.WriteString32(text);
-
-                    data = stream.GetBuffer();
-                }
-                this.Content = data;
-
-            }
-        }
-    }
+	public class ActiveMQTextMessage : ActiveMQMessage, ITextMessage
+	{
+		public const byte ID_ACTIVEMQTEXTMESSAGE = 28;
+
+		private String text;
+
+		public ActiveMQTextMessage()
+		{
+		}
+
+		public ActiveMQTextMessage(String text)
+		{
+			this.Text = text;
+		}
+
+		// TODO generate Equals method
+		// TODO generate GetHashCode method
+		// TODO generate ToString method
+
+		public override string ToString()
+		{
+			return base.ToString() + " Text=" + Text;
+		}
+
+		public override byte GetDataStructureType()
+		{
+			return ID_ACTIVEMQTEXTMESSAGE;
+		}
+
+		// Properties
+
+		public string Text
+		{
+			get
+			{
+				if(text == null)
+				{
+					// now lets read the content
+					byte[] data = this.Content;
+					if(data != null)
+					{
+						MemoryStream stream = new MemoryStream(data);
+						EndianBinaryReader reader = new EndianBinaryReader(stream);
+						text = reader.ReadString32();
+					}
+				}
+				return text;
+			}
+
+			set
+			{
+				this.text = value;
+				byte[] data = null;
+				if(text != null)
+				{
+					// TODO lets make the evaluation of the Content lazy!
+
+					// Set initial size to the size of the string the UTF-8 encode could
+					// result in more if there are chars that encode to multibye values.
+					MemoryStream stream = new MemoryStream(text.Length);
+					EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+					writer.WriteString32(text);
+					data = stream.GetBuffer();
+				}
+				this.Content = data;
+
+			}
+		}
+	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/WireFormatInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/WireFormatInfo.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/WireFormatInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/WireFormatInfo.cs Wed Aug 26 23:42:27 2009
@@ -15,199 +15,200 @@
 * limitations under the License.
 */
 
-using Apache.NMS.ActiveMQ.OpenWire;
 using Apache.NMS.ActiveMQ.State;
+using Apache.NMS.Util;
+using Apache.NMS.ActiveMQ.OpenWire;
 
 namespace Apache.NMS.ActiveMQ.Commands
 {
-    //
-    //  Marshalling code for Open Wire Format for WireFormatInfo
-    //
-    //
-    public class WireFormatInfo : BaseCommand, Command, MarshallAware
-    {
-        public const byte ID_WIREFORMATINFO = 1;
-        static private byte[] MAGIC = new byte[] {
-                        'A'&0xFF,
-                        'c'&0xFF,
-                        't'&0xFF,
-                        'i'&0xFF,
-                        'v'&0xFF,
-                        'e'&0xFF,
-                        'M'&0xFF,
-                        'Q'&0xFF };
-
-        byte[] magic = MAGIC;
-        int version;
-        byte[] marshalledProperties;
-
-        private PrimitiveMap properties;
-
-        public override string ToString()
-        {
-            return GetType().Name + "["
-                    + " Magic=" + Magic
-                    + " Version=" + Version
-                    + " MarshalledProperties=" + Properties.ToString()
-                    + " ]";
-
-        }
-
-        public override byte GetDataStructureType()
-        {
-            return ID_WIREFORMATINFO;
-        }
-
-
-        // Properties
-        public byte[] Magic
-        {
-            get { return magic; }
-            set { this.magic = value; }
-        }
-
-        public bool Valid
-        {
-            get
-            {
-                if(null == magic)
-                {
-                    return false;
-                }
-
-                if(magic.Length != MAGIC.Length)
-                {
-                    return false;
-                }
-
-                for(int i = 0; i < magic.Length; i++)
-                {
-                    if(magic[i] != MAGIC[i])
-                    {
-                        return false;
-                    }
-                }
-
-                return true;
-            }
-        }
-
-        public int Version
-        {
-            get { return version; }
-            set { this.version = value; }
-        }
-
-        public byte[] MarshalledProperties
-        {
-            get { return marshalledProperties; }
-            set { this.marshalledProperties = value; }
-        }
-
-        public IPrimitiveMap Properties
-        {
-            get
-            {
-                if(null == properties)
-                {
-                    properties = PrimitiveMap.Unmarshal(MarshalledProperties);
-                }
-
-                return properties;
-            }
-        }
-
-        public bool CacheEnabled
-        {
-            get { return true.Equals(Properties["CacheEnabled"]); }
-            set { Properties["CacheEnabled"] = value; }
-        }
-        public bool StackTraceEnabled
-        {
-            get { return true.Equals(Properties["StackTraceEnabled"]); }
-            set { Properties["StackTraceEnabled"] = value; }
-        }
-        public bool TcpNoDelayEnabled
-        {
-            get { return true.Equals(Properties["TcpNoDelayEnabled"]); }
-            set { Properties["TcpNoDelayEnabled"] = value; }
-        }
-        public bool SizePrefixDisabled
-        {
-            get { return true.Equals(Properties["SizePrefixDisabled"]); }
-            set { Properties["SizePrefixDisabled"] = value; }
-        }
-        public bool TightEncodingEnabled
-        {
-            get { return true.Equals(Properties["TightEncodingEnabled"]); }
-            set { Properties["TightEncodingEnabled"] = value; }
-        }
-        public long MaxInactivityDuration
-        {
-            get
-            {
-                object prop = Properties["MaxInactivityDuration"];
-                return (null != prop
-                                        ? (long) prop
-                                        : 0);
-            }
-            set { Properties["MaxInactivityDuration"] = value; }
-        }
-        public long MaxInactivityDurationInitialDelay
-        {
-            get
-            {
-                object prop = Properties["MaxInactivityDurationInitialDelay"];
-                return (null != prop
-                                        ? (long) prop
-                                        : 0);
-            }
-            set { Properties["MaxInactivityDurationInitialDelay"] = value; }
-        }
-        public int CacheSize
-        {
-            get
-            {
-                object prop = Properties["CacheSize"];
-                return (null != prop
-                                        ? (int) prop
-                                        : 0);
-            }
-            set { Properties.SetInt("CacheSize", value); }
-        }
-
-        // MarshallAware interface
-        public override bool IsMarshallAware()
-        {
-            return true;
-        }
-
-        public override void BeforeMarshall(OpenWireFormat wireFormat)
-        {
-            MarshalledProperties = null;
-
-            if(properties != null)
-            {
-                MarshalledProperties = properties.Marshal();
-            }
-        }
-
-        ///
-        /// <summery>
-        ///  Return an answer of true to the IsWireFormatInfo() query.
-        /// </summery>
-        ///
-        public override bool IsWireFormatInfo
-        {
-            get
-            {
-                return true;
-            }
-        }
-
-        public override Response visit(ICommandVisitor visitor)
-        {
-            return visitor.processWireFormat(this);
-        }
-    }
+	//
+	//  Marshalling code for Open Wire Format for WireFormatInfo
+	//
+	//
+	public class WireFormatInfo : BaseCommand, Command, MarshallAware
+	{
+		public const byte ID_WIREFORMATINFO = 1;
+		static private byte[] MAGIC = new byte[] {
+						'A'&0xFF,
+						'c'&0xFF,
+						't'&0xFF,
+						'i'&0xFF,
+						'v'&0xFF,
+						'e'&0xFF,
+						'M'&0xFF,
+						'Q'&0xFF };
+
+		byte[] magic = MAGIC;
+		int version;
+		byte[] marshalledProperties;
+
+		private PrimitiveMap properties;
+
+		public override string ToString()
+		{
+			return GetType().Name + "["
+					+ " Magic=" + Magic
+					+ " Version=" + Version
+					+ " MarshalledProperties=" + Properties.ToString()
+					+ " ]";
+
+		}
+
+		public override byte GetDataStructureType()
+		{
+			return ID_WIREFORMATINFO;
+		}
+
+
+		// Properties
+		public byte[] Magic
+		{
+			get { return magic; }
+			set { this.magic = value; }
+		}
+
+		public bool Valid
+		{
+			get
+			{
+				if(null == magic)
+				{
+					return false;
+				}
+
+				if(magic.Length != MAGIC.Length)
+				{
+					return false;
+				}
+
+				for(int i = 0; i < magic.Length; i++)
+				{
+					if(magic[i] != MAGIC[i])
+					{
+						return false;
+					}
+				}
+
+				return true;
+			}
+		}
+
+		public int Version
+		{
+			get { return version; }
+			set { this.version = value; }
+		}
+
+		public byte[] MarshalledProperties
+		{
+			get { return marshalledProperties; }
+			set { this.marshalledProperties = value; }
+		}
+
+		public IPrimitiveMap Properties
+		{
+			get
+			{
+				if(null == properties)
+				{
+					properties = PrimitiveMap.Unmarshal(MarshalledProperties);
+				}
+
+				return properties;
+			}
+		}
+
+		public bool CacheEnabled
+		{
+			get { return true.Equals(Properties["CacheEnabled"]); }
+			set { Properties["CacheEnabled"] = value; }
+		}
+		public bool StackTraceEnabled
+		{
+			get { return true.Equals(Properties["StackTraceEnabled"]); }
+			set { Properties["StackTraceEnabled"] = value; }
+		}
+		public bool TcpNoDelayEnabled
+		{
+			get { return true.Equals(Properties["TcpNoDelayEnabled"]); }
+			set { Properties["TcpNoDelayEnabled"] = value; }
+		}
+		public bool SizePrefixDisabled
+		{
+			get { return true.Equals(Properties["SizePrefixDisabled"]); }
+			set { Properties["SizePrefixDisabled"] = value; }
+		}
+		public bool TightEncodingEnabled
+		{
+			get { return true.Equals(Properties["TightEncodingEnabled"]); }
+			set { Properties["TightEncodingEnabled"] = value; }
+		}
+		public long MaxInactivityDuration
+		{
+			get
+			{
+				object prop = Properties["MaxInactivityDuration"];
+				return (null != prop
+										? (long) prop
+										: 0);
+			}
+			set { Properties["MaxInactivityDuration"] = value; }
+		}
+		public long MaxInactivityDurationInitialDelay
+		{
+			get
+			{
+				object prop = Properties["MaxInactivityDurationInitialDelay"];
+				return (null != prop
+										? (long) prop
+										: 0);
+			}
+			set { Properties["MaxInactivityDurationInitialDelay"] = value; }
+		}
+		public int CacheSize
+		{
+			get
+			{
+				object prop = Properties["CacheSize"];
+				return (null != prop
+										? (int) prop
+										: 0);
+			}
+			set { Properties.SetInt("CacheSize", value); }
+		}
+
+		// MarshallAware interface
+		public override bool IsMarshallAware()
+		{
+			return true;
+		}
+
+		public override void BeforeMarshall(OpenWireFormat wireFormat)
+		{
+			MarshalledProperties = null;
+
+			if(properties != null)
+			{
+				MarshalledProperties = properties.Marshal();
+			}
+		}
+
+		///
+		/// <summery>
+		///  Return an answer of true to the IsWireFormatInfo() query.
+		/// </summery>
+		///
+		public override bool IsWireFormatInfo
+		{
+			get
+			{
+				return true;
+			}
+		}
+
+		public override Response visit(ICommandVisitor visitor)
+		{
+			return visitor.processWireFormat(this);
+		}
+	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireFormat.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireFormat.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireFormat.cs Wed Aug 26 23:42:27 2009
@@ -14,440 +14,440 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+using System;
+using System.IO;
 using System.Reflection;
 using Apache.NMS.ActiveMQ.Commands;
-using Apache.NMS.ActiveMQ.OpenWire.V1;
 using Apache.NMS.ActiveMQ.Transport;
-using System;
-using System.IO;
-using Apache.NMS;
 using Apache.NMS.ActiveMQ.Transport.Tcp;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.ActiveMQ.OpenWire
 {
-    /// <summary>
-    /// Implements the <a href="http://activemq.apache.org/openwire.html">OpenWire</a> protocol.
-    /// </summary>
-    public class OpenWireFormat : IWireFormat
-    {
-        private readonly object marshalLock = new object();
-        private BaseDataStreamMarshaller[] dataMarshallers;
-        private const byte NULL_TYPE = 0;
-
-        private int version;
-        private bool cacheEnabled = false;
-        private bool stackTraceEnabled = false;
-        private bool tcpNoDelayEnabled = false;
-        private bool sizePrefixDisabled = false;
-        private bool tightEncodingEnabled = false;
-        private long maxInactivityDuration = 0;
-        private long maxInactivityDurationInitialDelay = 0;
-        private int cacheSize = 0;
-        private int minimumVersion = 1;
-
-        private WireFormatInfo preferedWireFormatInfo = new WireFormatInfo();
-        private ITransport transport;
-
-        public OpenWireFormat()
-        {
-            // See the following link for defaults: http://activemq.apache.org/configuring-wire-formats.html
-            // See also the following link for OpenWire format info: http://activemq.apache.org/openwire-version-2-specification.html
-            PreferedWireFormatInfo.CacheEnabled = false;
-            PreferedWireFormatInfo.StackTraceEnabled = false;
-            PreferedWireFormatInfo.TcpNoDelayEnabled = true;
-            PreferedWireFormatInfo.SizePrefixDisabled = false;
-            PreferedWireFormatInfo.TightEncodingEnabled = false;
-            PreferedWireFormatInfo.MaxInactivityDuration = 30000;
-            PreferedWireFormatInfo.MaxInactivityDurationInitialDelay = 10000;
-            PreferedWireFormatInfo.CacheSize = 0;
-            PreferedWireFormatInfo.Version = 2;
-
-            dataMarshallers = new BaseDataStreamMarshaller[256];
-            Version = 1;
-        }
-
-        public ITransport Transport
-        {
-            get { return transport; }
-            set { transport = value; }
-        }
-
-        public int Version
-        {
-            get { return version; }
-            set
-            {
-                Assembly dll = Assembly.GetExecutingAssembly();
-                Type type = dll.GetType("Apache.NMS.ActiveMQ.OpenWire.V" + value + ".MarshallerFactory", false);
-                IMarshallerFactory factory = (IMarshallerFactory) Activator.CreateInstance(type);
-                factory.configure(this);
-                version = value;
-            }
-        }
-
-        public bool CacheEnabled
-        {
-            get { return cacheEnabled; }
-            set { cacheEnabled = value; }
-        }
-
-        public bool StackTraceEnabled
-        {
-            get { return stackTraceEnabled; }
-            set { stackTraceEnabled = value; }
-        }
-
-        public bool TcpNoDelayEnabled
-        {
-            get { return tcpNoDelayEnabled; }
-            set { tcpNoDelayEnabled = value; }
-        }
-
-        public bool SizePrefixDisabled
-        {
-            get { return sizePrefixDisabled; }
-            set { sizePrefixDisabled = value; }
-        }
-
-        public bool TightEncodingEnabled
-        {
-            get { return tightEncodingEnabled; }
-            set { tightEncodingEnabled = value; }
-        }
-
-        public long MaxInactivityDuration
-        {
-            get { return maxInactivityDuration; }
-            set { maxInactivityDuration = value; }
-        }
-
-        public long MaxInactivityDurationInitialDelay
-        {
-            get { return maxInactivityDurationInitialDelay; }
-            set { maxInactivityDurationInitialDelay = value; }
-        }
-
-        public int CacheSize
-        {
-            get { return cacheSize; }
-            set { cacheSize = value; }
-        }
-
-        public WireFormatInfo PreferedWireFormatInfo
-        {
-            get { return preferedWireFormatInfo; }
-            set { preferedWireFormatInfo = value; }
-        }
-
-        public void clearMarshallers()
-        {
-            lock(this.marshalLock)
-            {
-                for(int i = 0; i < dataMarshallers.Length; i++)
-                {
-                    dataMarshallers[i] = null;
-                }
-            }
-        }
-
-        public void addMarshaller(BaseDataStreamMarshaller marshaller)
-        {
-            byte type = marshaller.GetDataStructureType();
-            lock(this.marshalLock)
-            {
-                dataMarshallers[type & 0xFF] = marshaller;
-            }
-        }
-
-        private BaseDataStreamMarshaller GetDataStreamMarshallerForType(byte dataType)
-        {
-            BaseDataStreamMarshaller dsm = this.dataMarshallers[dataType & 0xFF];
-            if(null == dsm)
-            {
-                throw new IOException("Unknown data type: " + dataType);
-            }
-            return dsm;
-        }
-
-        public void Marshal(Object o, BinaryWriter ds)
-        {
-            int size = 1;
-            if(o != null)
-            {
-                DataStructure c = (DataStructure) o;
-                byte type = c.GetDataStructureType();
-                BaseDataStreamMarshaller dsm;
-                bool _tightEncodingEnabled;
-                bool _sizePrefixDisabled;
-
-                lock(this.marshalLock)
-                {
-                    dsm = GetDataStreamMarshallerForType(type);
-                    _tightEncodingEnabled = this.tightEncodingEnabled;
-                    _sizePrefixDisabled = this.sizePrefixDisabled;
-                }
-
-                if(_tightEncodingEnabled)
-                {
-                    BooleanStream bs = new BooleanStream();
-                    size += dsm.TightMarshal1(this, c, bs);
-                    size += bs.MarshalledSize();
-
-                    if(!_sizePrefixDisabled)
-                    {
-                        ds.Write(size);
-                    }
-
-                    ds.Write(type);
-                    bs.Marshal(ds);
-                    dsm.TightMarshal2(this, c, ds, bs);
-                }
-                else
-                {
-                    BinaryWriter looseOut = ds;
-                    MemoryStream ms = null;
-
-                    // If we are prefixing then we need to first write it to memory,
-                    // otherwise we can write direct to the stream.
-                    if(!_sizePrefixDisabled)
-                    {
-                        ms = new MemoryStream();
-                        looseOut = new OpenWireBinaryWriter(ms);
-                        looseOut.Write(size);
-                    }
-
-                    looseOut.Write(type);
-                    dsm.LooseMarshal(this, c, looseOut);
-
-                    if(!_sizePrefixDisabled)
-                    {
-                        ms.Position = 0;
-                        looseOut.Write((int) ms.Length - 4);
-                        ds.Write(ms.GetBuffer(), 0, (int) ms.Length);
-                    }
-                }
-            }
-            else
-            {
-                ds.Write(size);
-                ds.Write(NULL_TYPE);
-            }
-        }
-
-        public Object Unmarshal(BinaryReader dis)
-        {
-            // lets ignore the size of the packet
-            if(!sizePrefixDisabled)
-            {
-                dis.ReadInt32();
-            }
-
-            // first byte is the type of the packet
-            byte dataType = dis.ReadByte();
-
-            if(dataType != NULL_TYPE)
-            {
-                BaseDataStreamMarshaller dsm;
-                bool _tightEncodingEnabled;
-
-                lock(this.marshalLock)
-                {
-                    dsm = GetDataStreamMarshallerForType(dataType);
-                    _tightEncodingEnabled = this.tightEncodingEnabled;
-                }
-
-                Tracer.Debug("Parsing type: " + dataType + " with: " + dsm);
-                Object data = dsm.CreateObject();
-
-                if(_tightEncodingEnabled)
-                {
-                    BooleanStream bs = new BooleanStream();
-                    bs.Unmarshal(dis);
-                    dsm.TightUnmarshal(this, data, dis, bs);
-                    return data;
-                }
-                else
-                {
-                    dsm.LooseUnmarshal(this, data, dis);
-                    return data;
-                }
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
-        {
-            bs.WriteBoolean(o != null);
-            if(null == o)
-            {
-                return 0;
-            }
-
-            if(o.IsMarshallAware())
-            {
-                MarshallAware ma = (MarshallAware) o;
-                byte[] sequence = ma.GetMarshalledForm(this);
-                bs.WriteBoolean(sequence != null);
-                if(sequence != null)
-                {
-                    return 1 + sequence.Length;
-                }
-            }
-
-            byte type = o.GetDataStructureType();
-            if(type == 0)
-            {
-                throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
-            }
-
-            BaseDataStreamMarshaller dsm;
-            lock(this.marshalLock)
-            {
-                dsm = GetDataStreamMarshallerForType(type);
-            }
-
-            Tracer.Debug("Marshalling type: " + type + " with structure: " + o);
-            return 1 + dsm.TightMarshal1(this, o, bs);
-        }
-
-        public void TightMarshalNestedObject2(DataStructure o, BinaryWriter ds, BooleanStream bs)
-        {
-            if(!bs.ReadBoolean())
-            {
-                return;
-            }
-
-            byte type = o.GetDataStructureType();
-            ds.Write(type);
-
-            if(o.IsMarshallAware() && bs.ReadBoolean())
-            {
-                MarshallAware ma = (MarshallAware) o;
-                byte[] sequence = ma.GetMarshalledForm(this);
-                ds.Write(sequence, 0, sequence.Length);
-            }
-            else
-            {
-                BaseDataStreamMarshaller dsm;
-
-                lock(this.marshalLock)
-                {
-                    dsm = GetDataStreamMarshallerForType(type);
-                }
-
-                dsm.TightMarshal2(this, o, ds, bs);
-            }
-        }
-
-        public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
-        {
-            if(bs.ReadBoolean())
-            {
-                DataStructure data;
-                BaseDataStreamMarshaller dsm;
-                byte dataType = dis.ReadByte();
-
-                lock(this.marshalLock)
-                {
-                    dsm = GetDataStreamMarshallerForType(dataType);
-                }
-
-                data = dsm.CreateObject();
-                if(data.IsMarshallAware() && bs.ReadBoolean())
-                {
-                    dis.ReadInt32();
-                    dis.ReadByte();
-
-                    BooleanStream bs2 = new BooleanStream();
-                    bs2.Unmarshal(dis);
-                    dsm.TightUnmarshal(this, data, dis, bs2);
-
-                    // TODO: extract the sequence from the dis and associate it.
-                    //                MarshallAware ma = (MarshallAware)data
-                    //                ma.setCachedMarshalledForm(this, sequence);
-                }
-                else
-                {
-                    dsm.TightUnmarshal(this, data, dis, bs);
-                }
-
-                return data;
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        public void LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
-        {
-            dataOut.Write(o != null);
-            if(o != null)
-            {
-                BaseDataStreamMarshaller dsm;
-                byte type = o.GetDataStructureType();
-                dataOut.Write(type);
-
-                lock(this.marshalLock)
-                {
-                    dsm = GetDataStreamMarshallerForType(type);
-                }
-
-                dsm.LooseMarshal(this, o, dataOut);
-            }
-        }
-
-        public DataStructure LooseUnmarshalNestedObject(BinaryReader dis)
-        {
-            if(dis.ReadBoolean())
-            {
-                BaseDataStreamMarshaller dsm;
-                byte dataType = dis.ReadByte();
-                DataStructure data;
-
-                lock(this.marshalLock)
-                {
-                    dsm = GetDataStreamMarshallerForType(dataType);
-                }
-
-                data = dsm.CreateObject();
-                dsm.LooseUnmarshal(this, data, dis);
-                return data;
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        public void renegotiateWireFormat(WireFormatInfo info)
-        {
-            lock(this.marshalLock)
-            {
-                if(info.Version < minimumVersion)
-                {
-                    throw new IOException("Remote wire format (" + info.Version + ") is lower than the minimum version required (" + minimumVersion + ")");
-                }
-
-                this.Version = Math.Min(PreferedWireFormatInfo.Version, info.Version);
-                this.cacheEnabled = info.CacheEnabled && PreferedWireFormatInfo.CacheEnabled;
-                this.stackTraceEnabled = info.StackTraceEnabled && PreferedWireFormatInfo.StackTraceEnabled;
-                this.tcpNoDelayEnabled = info.TcpNoDelayEnabled && PreferedWireFormatInfo.TcpNoDelayEnabled;
-                this.sizePrefixDisabled = info.SizePrefixDisabled && PreferedWireFormatInfo.SizePrefixDisabled;
-                this.tightEncodingEnabled = info.TightEncodingEnabled && PreferedWireFormatInfo.TightEncodingEnabled;
-                this.maxInactivityDuration = info.MaxInactivityDuration;
-                this.maxInactivityDurationInitialDelay = info.MaxInactivityDurationInitialDelay;
-                this.cacheSize = info.CacheSize;
-
-                TcpTransport tcpTransport = this.transport as TcpTransport;
-                if(null != tcpTransport)
-                {
-                    tcpTransport.TcpNoDelayEnabled = this.tcpNoDelayEnabled;
-                }
-            }
-        }
-    }
+	/// <summary>
+	/// Implements the <a href="http://activemq.apache.org/openwire.html">OpenWire</a> protocol.
+	/// </summary>
+	public class OpenWireFormat : IWireFormat
+	{
+		private readonly object marshalLock = new object();
+		private BaseDataStreamMarshaller[] dataMarshallers;
+		private const byte NULL_TYPE = 0;
+
+		private int version;
+		private bool cacheEnabled = false;
+		private bool stackTraceEnabled = false;
+		private bool tcpNoDelayEnabled = false;
+		private bool sizePrefixDisabled = false;
+		private bool tightEncodingEnabled = false;
+		private long maxInactivityDuration = 0;
+		private long maxInactivityDurationInitialDelay = 0;
+		private int cacheSize = 0;
+		private int minimumVersion = 1;
+
+		private WireFormatInfo preferedWireFormatInfo = new WireFormatInfo();
+		private ITransport transport;
+
+		public OpenWireFormat()
+		{
+			// See the following link for defaults: http://activemq.apache.org/configuring-wire-formats.html
+			// See also the following link for OpenWire format info: http://activemq.apache.org/openwire-version-2-specification.html
+			PreferedWireFormatInfo.CacheEnabled = false;
+			PreferedWireFormatInfo.StackTraceEnabled = false;
+			PreferedWireFormatInfo.TcpNoDelayEnabled = true;
+			PreferedWireFormatInfo.SizePrefixDisabled = false;
+			PreferedWireFormatInfo.TightEncodingEnabled = false;
+			PreferedWireFormatInfo.MaxInactivityDuration = 30000;
+			PreferedWireFormatInfo.MaxInactivityDurationInitialDelay = 10000;
+			PreferedWireFormatInfo.CacheSize = 0;
+			PreferedWireFormatInfo.Version = 2;
+
+			dataMarshallers = new BaseDataStreamMarshaller[256];
+			Version = 1;
+		}
+
+		public ITransport Transport
+		{
+			get { return transport; }
+			set { transport = value; }
+		}
+
+		public int Version
+		{
+			get { return version; }
+			set
+			{
+				Assembly dll = Assembly.GetExecutingAssembly();
+				Type type = dll.GetType("Apache.NMS.ActiveMQ.OpenWire.V" + value + ".MarshallerFactory", false);
+				IMarshallerFactory factory = (IMarshallerFactory) Activator.CreateInstance(type);
+				factory.configure(this);
+				version = value;
+			}
+		}
+
+		public bool CacheEnabled
+		{
+			get { return cacheEnabled; }
+			set { cacheEnabled = value; }
+		}
+
+		public bool StackTraceEnabled
+		{
+			get { return stackTraceEnabled; }
+			set { stackTraceEnabled = value; }
+		}
+
+		public bool TcpNoDelayEnabled
+		{
+			get { return tcpNoDelayEnabled; }
+			set { tcpNoDelayEnabled = value; }
+		}
+
+		public bool SizePrefixDisabled
+		{
+			get { return sizePrefixDisabled; }
+			set { sizePrefixDisabled = value; }
+		}
+
+		public bool TightEncodingEnabled
+		{
+			get { return tightEncodingEnabled; }
+			set { tightEncodingEnabled = value; }
+		}
+
+		public long MaxInactivityDuration
+		{
+			get { return maxInactivityDuration; }
+			set { maxInactivityDuration = value; }
+		}
+
+		public long MaxInactivityDurationInitialDelay
+		{
+			get { return maxInactivityDurationInitialDelay; }
+			set { maxInactivityDurationInitialDelay = value; }
+		}
+
+		public int CacheSize
+		{
+			get { return cacheSize; }
+			set { cacheSize = value; }
+		}
+
+		public WireFormatInfo PreferedWireFormatInfo
+		{
+			get { return preferedWireFormatInfo; }
+			set { preferedWireFormatInfo = value; }
+		}
+
+		public void clearMarshallers()
+		{
+			lock(this.marshalLock)
+			{
+				for(int i = 0; i < dataMarshallers.Length; i++)
+				{
+					dataMarshallers[i] = null;
+				}
+			}
+		}
+
+		public void addMarshaller(BaseDataStreamMarshaller marshaller)
+		{
+			byte type = marshaller.GetDataStructureType();
+			lock(this.marshalLock)
+			{
+				dataMarshallers[type & 0xFF] = marshaller;
+			}
+		}
+
+		private BaseDataStreamMarshaller GetDataStreamMarshallerForType(byte dataType)
+		{
+			BaseDataStreamMarshaller dsm = this.dataMarshallers[dataType & 0xFF];
+			if(null == dsm)
+			{
+				throw new IOException("Unknown data type: " + dataType);
+			}
+			return dsm;
+		}
+
+		public void Marshal(Object o, BinaryWriter ds)
+		{
+			int size = 1;
+			if(o != null)
+			{
+				DataStructure c = (DataStructure) o;
+				byte type = c.GetDataStructureType();
+				BaseDataStreamMarshaller dsm;
+				bool _tightEncodingEnabled;
+				bool _sizePrefixDisabled;
+
+				lock(this.marshalLock)
+				{
+					dsm = GetDataStreamMarshallerForType(type);
+					_tightEncodingEnabled = this.tightEncodingEnabled;
+					_sizePrefixDisabled = this.sizePrefixDisabled;
+				}
+
+				if(_tightEncodingEnabled)
+				{
+					BooleanStream bs = new BooleanStream();
+					size += dsm.TightMarshal1(this, c, bs);
+					size += bs.MarshalledSize();
+
+					if(!_sizePrefixDisabled)
+					{
+						ds.Write(size);
+					}
+
+					ds.Write(type);
+					bs.Marshal(ds);
+					dsm.TightMarshal2(this, c, ds, bs);
+				}
+				else
+				{
+					BinaryWriter looseOut = ds;
+					MemoryStream ms = null;
+
+					// If we are prefixing then we need to first write it to memory,
+					// otherwise we can write direct to the stream.
+					if(!_sizePrefixDisabled)
+					{
+						ms = new MemoryStream();
+						looseOut = new EndianBinaryWriter(ms);
+						looseOut.Write(size);
+					}
+
+					looseOut.Write(type);
+					dsm.LooseMarshal(this, c, looseOut);
+
+					if(!_sizePrefixDisabled)
+					{
+						ms.Position = 0;
+						looseOut.Write((int) ms.Length - 4);
+						ds.Write(ms.GetBuffer(), 0, (int) ms.Length);
+					}
+				}
+			}
+			else
+			{
+				ds.Write(size);
+				ds.Write(NULL_TYPE);
+			}
+		}
+
+		public Object Unmarshal(BinaryReader dis)
+		{
+			// lets ignore the size of the packet
+			if(!sizePrefixDisabled)
+			{
+				dis.ReadInt32();
+			}
+
+			// first byte is the type of the packet
+			byte dataType = dis.ReadByte();
+
+			if(dataType != NULL_TYPE)
+			{
+				BaseDataStreamMarshaller dsm;
+				bool _tightEncodingEnabled;
+
+				lock(this.marshalLock)
+				{
+					dsm = GetDataStreamMarshallerForType(dataType);
+					_tightEncodingEnabled = this.tightEncodingEnabled;
+				}
+
+				Tracer.Debug("Parsing type: " + dataType + " with: " + dsm);
+				Object data = dsm.CreateObject();
+
+				if(_tightEncodingEnabled)
+				{
+					BooleanStream bs = new BooleanStream();
+					bs.Unmarshal(dis);
+					dsm.TightUnmarshal(this, data, dis, bs);
+					return data;
+				}
+				else
+				{
+					dsm.LooseUnmarshal(this, data, dis);
+					return data;
+				}
+			}
+			else
+			{
+				return null;
+			}
+		}
+
+		public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
+		{
+			bs.WriteBoolean(o != null);
+			if(null == o)
+			{
+				return 0;
+			}
+
+			if(o.IsMarshallAware())
+			{
+				MarshallAware ma = (MarshallAware) o;
+				byte[] sequence = ma.GetMarshalledForm(this);
+				bs.WriteBoolean(sequence != null);
+				if(sequence != null)
+				{
+					return 1 + sequence.Length;
+				}
+			}
+
+			byte type = o.GetDataStructureType();
+			if(type == 0)
+			{
+				throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
+			}
+
+			BaseDataStreamMarshaller dsm;
+			lock(this.marshalLock)
+			{
+				dsm = GetDataStreamMarshallerForType(type);
+			}
+
+			Tracer.Debug("Marshalling type: " + type + " with structure: " + o);
+			return 1 + dsm.TightMarshal1(this, o, bs);
+		}
+
+		public void TightMarshalNestedObject2(DataStructure o, BinaryWriter ds, BooleanStream bs)
+		{
+			if(!bs.ReadBoolean())
+			{
+				return;
+			}
+
+			byte type = o.GetDataStructureType();
+			ds.Write(type);
+
+			if(o.IsMarshallAware() && bs.ReadBoolean())
+			{
+				MarshallAware ma = (MarshallAware) o;
+				byte[] sequence = ma.GetMarshalledForm(this);
+				ds.Write(sequence, 0, sequence.Length);
+			}
+			else
+			{
+				BaseDataStreamMarshaller dsm;
+
+				lock(this.marshalLock)
+				{
+					dsm = GetDataStreamMarshallerForType(type);
+				}
+
+				dsm.TightMarshal2(this, o, ds, bs);
+			}
+		}
+
+		public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
+		{
+			if(bs.ReadBoolean())
+			{
+				DataStructure data;
+				BaseDataStreamMarshaller dsm;
+				byte dataType = dis.ReadByte();
+
+				lock(this.marshalLock)
+				{
+					dsm = GetDataStreamMarshallerForType(dataType);
+				}
+
+				data = dsm.CreateObject();
+				if(data.IsMarshallAware() && bs.ReadBoolean())
+				{
+					dis.ReadInt32();
+					dis.ReadByte();
+
+					BooleanStream bs2 = new BooleanStream();
+					bs2.Unmarshal(dis);
+					dsm.TightUnmarshal(this, data, dis, bs2);
+
+					// TODO: extract the sequence from the dis and associate it.
+					//                MarshallAware ma = (MarshallAware)data
+					//                ma.setCachedMarshalledForm(this, sequence);
+				}
+				else
+				{
+					dsm.TightUnmarshal(this, data, dis, bs);
+				}
+
+				return data;
+			}
+			else
+			{
+				return null;
+			}
+		}
+
+		public void LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
+		{
+			dataOut.Write(o != null);
+			if(o != null)
+			{
+				BaseDataStreamMarshaller dsm;
+				byte type = o.GetDataStructureType();
+				dataOut.Write(type);
+
+				lock(this.marshalLock)
+				{
+					dsm = GetDataStreamMarshallerForType(type);
+				}
+
+				dsm.LooseMarshal(this, o, dataOut);
+			}
+		}
+
+		public DataStructure LooseUnmarshalNestedObject(BinaryReader dis)
+		{
+			if(dis.ReadBoolean())
+			{
+				BaseDataStreamMarshaller dsm;
+				byte dataType = dis.ReadByte();
+				DataStructure data;
+
+				lock(this.marshalLock)
+				{
+					dsm = GetDataStreamMarshallerForType(dataType);
+				}
+
+				data = dsm.CreateObject();
+				dsm.LooseUnmarshal(this, data, dis);
+				return data;
+			}
+			else
+			{
+				return null;
+			}
+		}
+
+		public void renegotiateWireFormat(WireFormatInfo info)
+		{
+			lock(this.marshalLock)
+			{
+				if(info.Version < minimumVersion)
+				{
+					throw new IOException("Remote wire format (" + info.Version + ") is lower than the minimum version required (" + minimumVersion + ")");
+				}
+
+				this.Version = Math.Min(PreferedWireFormatInfo.Version, info.Version);
+				this.cacheEnabled = info.CacheEnabled && PreferedWireFormatInfo.CacheEnabled;
+				this.stackTraceEnabled = info.StackTraceEnabled && PreferedWireFormatInfo.StackTraceEnabled;
+				this.tcpNoDelayEnabled = info.TcpNoDelayEnabled && PreferedWireFormatInfo.TcpNoDelayEnabled;
+				this.sizePrefixDisabled = info.SizePrefixDisabled && PreferedWireFormatInfo.SizePrefixDisabled;
+				this.tightEncodingEnabled = info.TightEncodingEnabled && PreferedWireFormatInfo.TightEncodingEnabled;
+				this.maxInactivityDuration = info.MaxInactivityDuration;
+				this.maxInactivityDurationInitialDelay = info.MaxInactivityDurationInitialDelay;
+				this.cacheSize = info.CacheSize;
+
+				TcpTransport tcpTransport = this.transport as TcpTransport;
+				if(null != tcpTransport)
+				{
+					tcpTransport.TcpNoDelayEnabled = this.tcpNoDelayEnabled;
+				}
+			}
+		}
+	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs Wed Aug 26 23:42:27 2009
@@ -20,7 +20,6 @@
 using System.Net.Sockets;
 using System.Threading;
 using Apache.NMS.ActiveMQ.Commands;
-using Apache.NMS.ActiveMQ.OpenWire;
 using Apache.NMS.Util;
 
 namespace Apache.NMS.ActiveMQ.Transport.Tcp
@@ -41,7 +40,7 @@
 		private AtomicBoolean closed = new AtomicBoolean(false);
 		private volatile bool seenShutdown;
 		private TimeSpan maxWait = TimeSpan.FromMilliseconds(Timeout.Infinite);
-        private Uri connectedUri;
+		private Uri connectedUri;
 
 		private CommandHandler commandHandler;
 		private ExceptionHandler exceptionHandler;
@@ -51,7 +50,7 @@
 
 		public TcpTransport(Uri uri, Socket socket, IWireFormat wireformat)
 		{
-            this.connectedUri = uri;
+			this.connectedUri = uri;
 			this.socket = socket;
 			this.wireformat = wireformat;
 		}
@@ -86,8 +85,8 @@
 
 					// As reported in AMQ-988 it appears that NetworkStream is not thread safe
 					// so lets use an instance for each of the 2 streams
-					socketWriter = new OpenWireBinaryWriter(new NetworkStream(socket));
-					socketReader = new OpenWireBinaryReader(new NetworkStream(socket));
+					socketWriter = new EndianBinaryWriter(new NetworkStream(socket));
+					socketReader = new EndianBinaryReader(new NetworkStream(socket));
 
 					// now lets create the background read thread
 					readThread = new Thread(new ThreadStart(ReadLoop));
@@ -367,7 +366,7 @@
 			get { return interruptedHandler; }
 			set { this.interruptedHandler = value; }
 		}
-		
+
 		public ResumedHandler Resumed
 		{
 			get { return resumedHandler; }
@@ -380,31 +379,31 @@
 			set { wireformat = value; }
 		}
 
-        public bool IsFaultTolerant
-        {
-            get{ return false; }
-        }
-
-        public bool IsConnected
-        {
-            get{ return socket.Connected; }
-        }
-
-        public Uri RemoteAddress
-        {
-            get{ return connectedUri; }
-        }
-
-        public Object Narrow(Type type)
-        {
-            if( this.GetType().Equals(type) )
-            {
-                return this;
-            }
-
-            return null;
-        }
-        
+		public bool IsFaultTolerant
+		{
+			get { return false; }
+		}
+
+		public bool IsConnected
+		{
+			get { return socket.Connected; }
+		}
+
+		public Uri RemoteAddress
+		{
+			get { return connectedUri; }
+		}
+
+		public Object Narrow(Type type)
+		{
+			if(this.GetType().Equals(type))
+			{
+				return this;
+			}
+
+			return null;
+		}
+
 	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/BooleanStreamTest.cs Wed Aug 26 23:42:27 2009
@@ -18,6 +18,7 @@
 using System;
 using System.IO;
 using Apache.NMS.ActiveMQ.OpenWire;
+using Apache.NMS.Util;
 using NUnit.Framework;
 
 namespace Apache.NMS.ActiveMQ.Test.OpenWire
@@ -88,14 +89,14 @@
 				bs.WriteBoolean(valueDelegate(i, count));
 			}
 			MemoryStream buffer = new MemoryStream();
-			BinaryWriter ds = new OpenWireBinaryWriter(buffer);
+			BinaryWriter ds = new EndianBinaryWriter(buffer);
 			bs.Marshal(ds);
 			ds.Write(endOfStreamMarker);
 
 			// now lets read from the stream
 
 			MemoryStream ins = new MemoryStream(buffer.ToArray());
-			BinaryReader dis = new OpenWireBinaryReader(ins);
+			BinaryReader dis = new EndianBinaryReader(ins);
 			bs = new BooleanStream();
 			bs.Unmarshal(dis);
 
@@ -110,13 +111,11 @@
 				}
 				catch(Exception e)
 				{
-					Assert.Fail(
-							"Failed to parse bool: " + i + " out of: " + count + " due to: " + e);
+					Assert.Fail("Failed to parse bool: " + i + " out of: " + count + " due to: " + e);
 				}
 			}
 			int marker = dis.ReadInt32();
-			Assert.AreEqual(
-					endOfStreamMarker, marker, "did not match: " + endOfStreamMarker + " and " + marker);
+			Assert.AreEqual(endOfStreamMarker, marker, "did not match: " + endOfStreamMarker + " and " + marker);
 
 			// lets try read and we should get an exception
 			try

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq-test.csproj Wed Aug 26 23:42:27 2009
@@ -2,7 +2,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{EB943C69-2C9B-45E7-B95B-FB916E7057ED}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -71,16 +71,8 @@
     <Compile Include="src\test\csharp\OpenWire\BooleanStreamTest.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="src\test\csharp\OpenWire\EndianTest.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="src\test\csharp\OpenWire\MaxInactivityDurationTest.cs" />
-    <Compile Include="src\test\csharp\OpenWire\OpenWireBinaryReaderTest.cs" />
-    <Compile Include="src\test\csharp\OpenWire\OpenWireBinaryWriterTest.cs" />
     <Compile Include="src\test\csharp\OpenWire\PrefetchSizeZeroTest.cs" />
-    <Compile Include="src\test\csharp\OpenWire\PrimitiveMapTest.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="src\test\csharp\StompHelperTest.cs" />
     <Compile Include="src\test\csharp\Transport\failover\FailoverTransportTest.cs" />
     <Compile Include="src\test\csharp\Transport\Mock\MockTransportFactoryTest.cs" />

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj Wed Aug 26 23:42:27 2009
@@ -2,7 +2,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{08321F42-4B3D-4815-B592-95962BAC3B9F}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -319,24 +319,9 @@
       <SubType>Code</SubType>
     </Compile>
     <Compile Include="src\main\csharp\OpenWire\IMarshallerFactory.cs" />
-    <Compile Include="src\main\csharp\OpenWire\EndianSupport.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="src\main\csharp\OpenWire\MessagePropertyHelper.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="src\main\csharp\OpenWire\OpenWireBinaryReader.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="src\main\csharp\OpenWire\OpenWireBinaryWriter.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="src\main\csharp\OpenWire\OpenWireFormat.cs">
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="src\main\csharp\OpenWire\PrimitiveMap.cs">
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="src\main\csharp\OpenWire\V1\ActiveMQBlobMessageMarshaller.cs" />
     <Compile Include="src\main\csharp\OpenWire\V1\ActiveMQBytesMessageMarshaller.cs">
       <SubType>Code</SubType>

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/BaseMessage.cs Wed Aug 26 23:42:27 2009
@@ -14,7 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.MSMQ
 {
@@ -43,11 +45,7 @@
 
 		public void Acknowledge()
 		{
-			if(Acknowledger == null)
-			{
-				throw new NMSException("No Acknowledger has been associated with this message: " + this);
-			}
-			else
+			if(null != Acknowledger)
 			{
 				Acknowledger(this);
 			}
@@ -144,6 +142,7 @@
 		public DateTime NMSTimestamp
 		{
 			get { return timestamp; }
+			set { timestamp = value; }
 		}
 
 		/// <summary>

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/Connection.cs Wed Aug 26 23:42:27 2009
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 using System;
 
 namespace Apache.NMS.MSMQ
@@ -25,7 +26,6 @@
 	///
 	public class Connection : IConnection
 	{
-
 		private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;
 		private IMessageConverter messageConverter = new DefaultMessageConverter();
 
@@ -47,10 +47,7 @@
 		/// </summary>
 		public bool IsStarted
 		{
-			get
-			{
-				return true;
-			}
+			get { return true; }
 		}
 
 		/// <summary>
@@ -148,8 +145,6 @@
 			{
 				Tracer.Error(e);
 			}
-
 		}
-
 	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/DefaultMessageConverter.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/DefaultMessageConverter.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/DefaultMessageConverter.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/DefaultMessageConverter.cs Wed Aug 26 23:42:27 2009
@@ -18,47 +18,79 @@
 using System.IO;
 using System.Messaging;
 using System.Text;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.MSMQ
 {
 	public enum NMSMessageType
 	{
-		BytesMessage,
+		BaseMessage,
 		TextMessage,
-		MapMessage
+		BytesMessage,
+		ObjectMessage,
+		MapMessage,
+		StreamMessage
 	}
 
 	public class DefaultMessageConverter : IMessageConverter
 	{
 		public virtual Message ToMsmqMessage(IMessage message)
 		{
-			Message answer = new Message();
-			ConvertMessageBodyToMSMQ(message, answer);
-			MessageQueue responseQueue = null;
-			if(message.NMSReplyTo != null)
-			{
-				IDestination destination = message.NMSReplyTo;
-				responseQueue = ToMsmqDestination(destination);
-			}
+			Message msmqMessage = new Message();
+			PrimitiveMap metaData = new PrimitiveMap();
+
+			ConvertMessageBodyToMSMQ(message, msmqMessage);
 
 			if(message.NMSTimeToLive != TimeSpan.Zero)
 			{
-				answer.TimeToBeReceived = message.NMSTimeToLive;
+				msmqMessage.TimeToBeReceived = message.NMSTimeToLive;
 			}
 
 			if(message.NMSCorrelationID != null)
 			{
-				answer.CorrelationId = message.NMSCorrelationID;
+				metaData.SetString("NMSCorrelationID", message.NMSCorrelationID);
 			}
 
-			answer.Recoverable = (message.NMSDeliveryMode == MsgDeliveryMode.Persistent);
-			answer.Priority = ToMessagePriority(message.NMSPriority);
-			answer.ResponseQueue = responseQueue;
+			msmqMessage.Recoverable = (message.NMSDeliveryMode == MsgDeliveryMode.Persistent);
+			msmqMessage.Priority = ToMessagePriority(message.NMSPriority);
+			msmqMessage.ResponseQueue = ToMsmqDestination(message.NMSReplyTo);
 			if(message.NMSType != null)
 			{
-				answer.Label = message.NMSType;
+				msmqMessage.Label = message.NMSType;
+			}
+
+			// Store the NMS meta data in the extension area
+			msmqMessage.Extension = metaData.Marshal();
+			return msmqMessage;
+		}
+
+		public virtual IMessage ToNmsMessage(Message message)
+		{
+			BaseMessage answer = CreateNmsMessage(message);
+			// Get the NMS meta data from the extension area
+			PrimitiveMap metaData = PrimitiveMap.Unmarshal(message.Extension);
+
+			try
+			{
+				answer.NMSMessageId = message.Id;
+				answer.NMSCorrelationID = metaData.GetString("NMSCorrelationID");
+				answer.NMSDeliveryMode = (message.Recoverable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent);
+				answer.NMSDestination = ToNmsDestination(message.DestinationQueue);
+			}
+			catch(InvalidOperationException)
+			{
 			}
-			
+
+			try
+			{
+				answer.NMSType = message.Label;
+				answer.NMSReplyTo = ToNmsDestination(message.ResponseQueue);
+				answer.NMSTimeToLive = message.TimeToBeReceived;
+			}
+			catch(InvalidOperationException)
+			{
+			}
+
 			return answer;
 		}
 
@@ -95,28 +127,45 @@
 			}
 		}
 
-		protected virtual void ConvertMessageBodyToMSMQ(IMessage message,
-														Message answer)
+		protected virtual void ConvertMessageBodyToMSMQ(IMessage message, Message answer)
 		{
-			if(message is IBytesMessage)
+			if(message is TextMessage)
+			{
+				TextMessage textMessage = message as TextMessage;
+				byte[] buf = Encoding.UTF32.GetBytes(textMessage.Text);
+				answer.BodyStream.Write(buf, 0, buf.Length);
+				answer.AppSpecific = (int) NMSMessageType.TextMessage;
+			}
+			else if(message is BytesMessage)
 			{
-				IBytesMessage bytesMessage = message as IBytesMessage;
+				BytesMessage bytesMessage = message as BytesMessage;
 				answer.BodyStream.Write(bytesMessage.Content, 0, bytesMessage.Content.Length);
 				answer.AppSpecific = (int) NMSMessageType.BytesMessage;
 			}
-			else if(message is ITextMessage)
+			else if(message is ObjectMessage)
 			{
-				ITextMessage textMessage = message as ITextMessage;
-				byte[] buf = Encoding.UTF8.GetBytes(textMessage.Text);
-				answer.BodyStream.Write(buf, 0, buf.Length);
-				answer.AppSpecific = (int) NMSMessageType.TextMessage;
+				ObjectMessage objectMessage = message as ObjectMessage;
+				answer.Body = objectMessage.Body;
+				answer.AppSpecific = (int) NMSMessageType.ObjectMessage;
 			}
-			else if(message is IMapMessage)
+			else if(message is MapMessage)
 			{
-				IMapMessage mapMessage = message as IMapMessage;
-				answer.Body = mapMessage.Body;
+				MapMessage mapMessage = message as MapMessage;
+				PrimitiveMap mapBody = mapMessage.Body as PrimitiveMap;
+				byte[] buf = mapBody.Marshal();
+				answer.BodyStream.Write(buf, 0, buf.Length);
 				answer.AppSpecific = (int) NMSMessageType.MapMessage;
 			}
+			else if(message is StreamMessage)
+			{
+				StreamMessage streamMessage = message as StreamMessage;
+				answer.AppSpecific = (int) NMSMessageType.StreamMessage;
+				// TODO: Implement
+			}
+			else if(message is BaseMessage)
+			{
+				answer.AppSpecific = (int) NMSMessageType.BaseMessage;
+			}
 			else
 			{
 				throw new Exception("unhandled message type");
@@ -127,7 +176,23 @@
 		{
 			BaseMessage result = null;
 
-			if((int) NMSMessageType.BytesMessage == message.AppSpecific)
+			if((int) NMSMessageType.TextMessage == message.AppSpecific)
+			{
+				TextMessage textMessage = new TextMessage();
+				string content = String.Empty;
+
+				if(message.BodyStream != null && message.BodyStream.Length > 0)
+				{
+					byte[] buf = null;
+					buf = new byte[message.BodyStream.Length];
+					message.BodyStream.Read(buf, 0, buf.Length);
+					content = Encoding.UTF32.GetString(buf);
+				}
+
+				textMessage.Text = content;
+				result = textMessage;
+			}
+			else if((int) NMSMessageType.BytesMessage == message.AppSpecific)
 			{
 				byte[] buf = null;
 
@@ -141,82 +206,61 @@
 				bytesMessage.Content = buf;
 				result = bytesMessage;
 			}
-			else if((int) NMSMessageType.TextMessage == message.AppSpecific)
+			else if((int) NMSMessageType.ObjectMessage == message.AppSpecific)
 			{
-				TextMessage textMessage = new TextMessage();
-				string content = String.Empty;
+				ObjectMessage objectMessage = new ObjectMessage();
+
+				objectMessage.Body = message.Body;
+				result = objectMessage;
+			}
+			else if((int) NMSMessageType.MapMessage == message.AppSpecific)
+			{
+				byte[] buf = null;
 
 				if(message.BodyStream != null && message.BodyStream.Length > 0)
 				{
-					byte[] buf = null;
 					buf = new byte[message.BodyStream.Length];
 					message.BodyStream.Read(buf, 0, buf.Length);
-					content = Encoding.UTF8.GetString(buf);
 				}
 
-				textMessage.Text = content;
-				result = textMessage;
+				MapMessage mapMessage = new MapMessage();
+				mapMessage.Body = PrimitiveMap.Unmarshal(buf);
+				result = mapMessage;
 			}
-			else if((int) NMSMessageType.MapMessage == message.AppSpecific)
+			else if((int) NMSMessageType.StreamMessage == message.AppSpecific)
 			{
-				MapMessage mapMessage = new MapMessage();
+				StreamMessage streamMessage = new StreamMessage();
 
-				mapMessage.Body = message.Body as IPrimitiveMap;
-				result = mapMessage;
+				// TODO: Implement
+				result = streamMessage;
 			}
 			else
 			{
-				result = new BaseMessage();
+				BaseMessage baseMessage = new BaseMessage();
+
+				result = baseMessage;
 			}
 
 			return result;
 		}
 
-		public virtual IMessage ToNmsMessage(Message message)
+		public MessageQueue ToMsmqDestination(IDestination destination)
 		{
-			BaseMessage answer = CreateNmsMessage(message);
-			answer.NMSMessageId = message.Id;
-			try
-			{
-				answer.NMSCorrelationID = message.CorrelationId;
-				answer.NMSDeliveryMode = (message.Recoverable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent);
-			}
-			catch(InvalidOperationException)
-			{
-			}
-
-			try
-			{
-				answer.NMSDestination = ToNmsDestination(message.DestinationQueue);
-			}
-			catch(InvalidOperationException)
-			{
-			}
-
-			answer.NMSType = message.Label;
-			answer.NMSReplyTo = ToNmsDestination(message.ResponseQueue);
-			try
-			{
-				answer.NMSTimeToLive = message.TimeToBeReceived;
-			}
-			catch(InvalidOperationException)
+			if(null == destination)
 			{
+				return null;
 			}
-			return answer;
-		}
-
 
-		public MessageQueue ToMsmqDestination(IDestination destination)
-		{
 			return new MessageQueue((destination as Destination).Path);
 		}
 
 		protected virtual IDestination ToNmsDestination(MessageQueue destinationQueue)
 		{
-			if(destinationQueue == null)
+			if(null == destinationQueue)
 			{
 				return null;
 			}
+
 			return new Queue(destinationQueue.Path);
 		}
 	}

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MapMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MapMessage.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MapMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MapMessage.cs Wed Aug 26 23:42:27 2009
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+using Apache.NMS.Util;
 
 namespace Apache.NMS.MSMQ
 {

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/src/main/csharp/MessageProducer.cs Wed Aug 26 23:42:27 2009
@@ -36,13 +36,11 @@
 		private bool disableMessageTimestamp;
 
 		private MessageQueue messageQueue;
-		private IMessageConverter messageConverter;
 
 		public MessageProducer(Session session, Destination destination)
 		{
 			this.session = session;
 			this.destination = destination;
-			MessageConverter = session.MessageConverter;
 			if(destination != null)
 			{
 				messageQueue = openMessageQueue(destination);
@@ -76,6 +74,7 @@
 				{
 					rc.Dispose();
 				}
+
 				throw new NMSException(e.Message + ": " + dest, e);
 			}
 			return rc;
@@ -100,8 +99,7 @@
 		{
 			BaseMessage message = (BaseMessage) imessage;
 			MessageQueue mq = null;
-			MessageQueue responseQueue = null;
-			MessageQueueTransaction transaction = null;
+
 			try
 			{
 				// Locate the MSMQ Queue we will be sending to
@@ -121,15 +119,22 @@
 					mq = openMessageQueue((Destination) destination);
 				}
 
-				// Convert the Mesasge into a MSMQ message
 				message.NMSDeliveryMode = deliveryMode;
 				message.NMSTimeToLive = timeToLive;
 				message.NMSPriority = priority;
+				if(!DisableMessageTimestamp)
+				{
+					message.NMSTimestamp = DateTime.UtcNow;
+				}
+
+				if(!DisableMessageID)
+				{
+					// TODO: message.NMSMessageId =
+				}
+
+				// Convert the Mesasge into a MSMQ message
+				Message msg = session.MessageConverter.ToMsmqMessage(message);
 
-				// message.NMSTimestamp = new DateTime().Date.;
-				Message msg = messageConverter.ToMsmqMessage(message);
-				// TODO: message.NMSMessageId =
-				// Now Send the message
 				if(mq.Transactional)
 				{
 					if(session.Transacted)
@@ -140,10 +145,12 @@
 					else
 					{
 						// Start our own mini transaction here to send the message.
-						transaction = new MessageQueueTransaction();
-						transaction.Begin();
-						mq.Send(msg, transaction);
-						transaction.Commit();
+						using(MessageQueueTransaction transaction = new MessageQueueTransaction())
+						{
+							transaction.Begin();
+							mq.Send(msg, transaction);
+							transaction.Commit();
+						}
 					}
 				}
 				else
@@ -160,17 +167,6 @@
 			}
 			finally
 			{
-				// Cleanup
-				if(transaction != null)
-				{
-					transaction.Dispose();
-				}
-
-				if(responseQueue != null)
-				{
-					responseQueue.Dispose();
-				}
-
 				if(mq != null && mq != messageQueue)
 				{
 					mq.Dispose();
@@ -271,11 +267,5 @@
 			get { return disableMessageTimestamp; }
 			set { disableMessageTimestamp = value; }
 		}
-
-		public IMessageConverter MessageConverter
-		{
-			get { return messageConverter; }
-			set { messageConverter = value; }
-		}
 	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj?rev=808223&r1=808222&r2=808223&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.MSMQ/trunk/vs2008-msmq.csproj Wed Aug 26 23:42:27 2009
@@ -77,7 +77,6 @@
     <Compile Include="src\main\csharp\MessageConsumer.cs" />
     <Compile Include="src\main\csharp\MessageProducer.cs" />
     <Compile Include="src\main\csharp\ObjectMessage.cs" />
-    <Compile Include="src\main\csharp\PrimitiveMap.cs" />
     <Compile Include="src\main\csharp\Queue.cs" />
     <Compile Include="src\main\csharp\Session.cs" />
     <Compile Include="src\main\csharp\StreamMessage.cs" />



Mime
View raw message