activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r693666 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/ Apache.NMS.ActiveMQ/trunk/...
Date Wed, 10 Sep 2008 00:20:50 GMT
Author: jgomes
Date: Tue Sep  9 17:20:49 2008
New Revision: 693666

URL: http://svn.apache.org/viewvc?rev=693666&view=rev
Log:
Added support for wireFormat.MaxInactivityDuration and wireFormat.MaxInactivityDurationInitialDelay.
Enhanced PrimitiveMap to support synchronized access from multiple threads.
Fixes [AMQNET-114]. (See https://issues.apache.org/activemq/browse/AMQNET-114)

Added:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/MaxInactivityDurationTest.cs
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nant.build
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nmsprovider-test.config
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/WireFormatInfo.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireFormat.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.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/trunk/src/test/csharp/NMSTestSupport.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nant.build
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nant.build?rev=693666&r1=693665&r2=693666&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nant.build (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nant.build Tue Sep  9 17:20:49 2008
@@ -35,6 +35,7 @@
 
   <!-- Repository organized as: organization/module/version/plaform/artifact, platform might be something like 'all' or 'net-2.0/release' -->
   <property name="nunit.dll" value="${basedir}/vendor/Apache.NMS/lib/${current.build.framework}/nunit.framework.dll" dynamic="true"/>
+  <property name="nunit.extensions.dll" value="${basedir}/vendor/Apache.NMS/lib/${current.build.framework}/nunit.framework.extensions.dll" dynamic="true"/>
   <property name="Apache.NMS.dll" value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.dll" dynamic="true"/>
   <property name="Apache.NMS.pdb" value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.pdb" dynamic="true"/>
   <property name="Apache.NMS.xml" value="${basedir}/vendor/Apache.NMS/build/${current.build.framework}/${current.build.config}/Apache.NMS.xml" dynamic="true"/>
@@ -75,6 +76,7 @@
       <include name="${Apache.NMS.Test.dll}"/>
       <include name="${build.bin.dir}/${project.name}.dll"/>
       <include name="${nunit.dll}"/>
+      <include name="${nunit.extensions.dll}"/>
     </assemblyfileset>
 
     <fileset id="content.filenames">
@@ -88,6 +90,7 @@
       <include name="${Apache.NMS.Test.pdb}"/>
       <include name="${Apache.NMS.Test.xml}"/>
       <include name="${nunit.dll}"/>
+      <include name="${nunit.extensions.dll}"/>
     </fileset>
 
     <fileset id="install.filenames">

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nmsprovider-test.config
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nmsprovider-test.config?rev=693666&r1=693665&r2=693666&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nmsprovider-test.config (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/nmsprovider-test.config Tue Sep  9 17:20:49 2008
@@ -16,21 +16,15 @@
 * limitations under the License.
 -->
 <configuration>
-	<defaultURI value="activemq:tcp://devgvapp1:61616">
-		<factoryParams/>
-		<userName value="guest"/>
-		<passWord value="guest"/>
-	</defaultURI>
+	<defaultURI value="activemq:tcp://activemqhost:61616"/>
 
-	<openWireURI value="activemq:tcp://jgomesv1:61616">
+	<maxInactivityDurationURI value="activemq:tcp://activemqhost:61616?wireFormat.MaxInactivityDuration=30000"/>
+
+	<openWireURI value="activemq:tcp://activemqhost:61616">
 		<factoryParams>
 			<param type="string" value="OpenWireTestClient"/>
 		</factoryParams>
+		<userName value="guest"/>
+		<passWord value="guest"/>
 	</openWireURI>
-
-	<stompURI value="activemq:stomp://jgomesv1:61613">
-		<factoryParams>
-			<param type="string" value="STOMPTestClient"/>
-		</factoryParams>
-	</stompURI>
 </configuration>

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=693666&r1=693665&r2=693666&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 Tue Sep  9 17:20:49 2008
@@ -21,131 +21,174 @@
 
 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 ( magic == null )
-                    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 (properties == null)
-                {
-                    properties = PrimitiveMap.Unmarshal(MarshalledProperties);
-                }
-                return properties;
-            }
-        }
-
-        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 bool CacheEnabled
-        {
-            get { return true.Equals(Properties["CacheEnabled"]); }
-            set { Properties["CacheEnabled"] = value; }
-        }
-        
-        // MarshallAware interface
-        public override bool IsMarshallAware()
-        {
-            return true;
-        }
-        
-        public override void BeforeMarshall(OpenWireFormat wireFormat)
-        {
-            MarshalledProperties = null;
-            if (properties != null)
-            {
-                MarshalledProperties = properties.Marshal();
-            }
-        }
-        
-
-    }
+	//
+	//  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();
+			}
+		}
+	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs?rev=693666&r1=693665&r2=693666&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs Tue Sep  9 17:20:49 2008
@@ -460,6 +460,10 @@
 			{
 				DispatchMessage((MessageDispatch) command);
 			}
+			else if(command is KeepAliveInfo)
+			{
+				OnKeepAliveCommand(commandTransport, (KeepAliveInfo) command);
+			}
 			else if(command is WireFormatInfo)
 			{
 				this.brokerWireFormatInfo = (WireFormatInfo) command;
@@ -507,6 +511,23 @@
 			}
 		}
 
+		protected void OnKeepAliveCommand(ITransport commandTransport, KeepAliveInfo info)
+		{
+			Tracer.Info("Keep alive message received.");
+			if(info.ResponseRequired)
+			{
+				try
+				{
+					info.ResponseRequired = false;
+					OneWay(info);
+				}
+				catch(Exception ex)
+				{
+					OnException(commandTransport, ex);
+				}
+			}
+		}
+
 		protected void OnException(ITransport sender, Exception exception)
 		{
 			Tracer.ErrorFormat("Transport Exception: {0}", exception.ToString());

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=693666&r1=693665&r2=693666&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 Tue Sep  9 17:20:49 2008
@@ -25,57 +25,69 @@
 
 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 BaseDataStreamMarshaller[] dataMarshallers;
-        private const byte NULL_TYPE = 0;
-		
+	/// <summary>
+	/// Implements the <a href="http://activemq.apache.org/openwire.html">OpenWire</a> protocol.
+	/// </summary>
+	public class OpenWireFormat : IWireFormat
+	{
+
+		private BaseDataStreamMarshaller[] dataMarshallers;
+		private const byte NULL_TYPE = 0;
+
 		private int version;
+		private bool cacheEnabled = false;
 		private bool stackTraceEnabled = false;
-		private bool tightEncodingEnabled = false;
-		private bool sizePrefixDisabled = false;
 		private bool tcpNoDelayEnabled = false;
-        private int minimumVersion=1;
+		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 WireFormatInfo preferedWireFormatInfo = new WireFormatInfo();
 		private ITransport transport;
-        
-        public OpenWireFormat()
-        {
-            PreferedWireFormatInfo.StackTraceEnabled = false;
-            PreferedWireFormatInfo.TightEncodingEnabled = false;
-            PreferedWireFormatInfo.TcpNoDelayEnabled = true;
-            PreferedWireFormatInfo.CacheEnabled = false;
-            PreferedWireFormatInfo.SizePrefixDisabled = false;
-            PreferedWireFormatInfo.Version = 2;
-            
-            dataMarshallers = new BaseDataStreamMarshaller[256];
-            Version = 1;
-        }
 
-        public ITransport Transport
+		public OpenWireFormat()
+		{
+			PreferedWireFormatInfo.CacheEnabled = false;
+			PreferedWireFormatInfo.StackTraceEnabled = false;
+			PreferedWireFormatInfo.TcpNoDelayEnabled = true;
+			PreferedWireFormatInfo.SizePrefixDisabled = false;
+			PreferedWireFormatInfo.TightEncodingEnabled = false;
+			PreferedWireFormatInfo.MaxInactivityDuration = 0;
+			PreferedWireFormatInfo.MaxInactivityDurationInitialDelay = 0;
+			PreferedWireFormatInfo.CacheSize = 0;
+			PreferedWireFormatInfo.Version = 2;
+
+			dataMarshallers = new BaseDataStreamMarshaller[256];
+			Version = 1;
+		}
+
+		public ITransport Transport
 		{
 			get { return transport; }
 			set { transport = value; }
 		}
-				
-        public int Version
+
+		public int Version
 		{
-            get { return 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; 			
+				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
 		{
@@ -83,116 +95,142 @@
 			set { stackTraceEnabled = value; }
 		}
 
+		public bool TcpNoDelayEnabled
+		{
+			get { return tcpNoDelayEnabled; }
+			set { tcpNoDelayEnabled = value; }
+		}
+
 		public bool SizePrefixDisabled
 		{
-            get { return sizePrefixDisabled; }
+			get { return sizePrefixDisabled; }
 			set { sizePrefixDisabled = value; }
-        }
+		}
 
-        public bool TightEncodingEnabled 
+		public bool TightEncodingEnabled
 		{
-            get { return tightEncodingEnabled; }
+			get { return tightEncodingEnabled; }
 			set { tightEncodingEnabled = value; }
-        }
+		}
 
-		public bool TcpNoDelayEnabled
+		public long MaxInactivityDuration
 		{
-			get { return tcpNoDelayEnabled; }
-			set { tcpNoDelayEnabled = value; }
+			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()
-        {
-            for (int i=0; i < dataMarshallers.Length; i++ )
-            {
-                dataMarshallers[i] = null;
-            }
-        }
-        
-        public void addMarshaller(BaseDataStreamMarshaller marshaller)
-        {
-            byte type = marshaller.GetDataStructureType();
-            dataMarshallers[type & 0xFF] = marshaller;
-        }
-        
-        public void Marshal(Object o, BinaryWriter ds)
-        {
-            int size = 1;
-            if (o != null)
-            {
-                DataStructure c = (DataStructure) o;
-                byte type = c.GetDataStructureType();
-                BaseDataStreamMarshaller dsm = dataMarshallers[type & 0xFF];
-                if (dsm == null)
-                    throw new IOException("Unknown data type: " + type);
+		public WireFormatInfo PreferedWireFormatInfo
+		{
+			get { return preferedWireFormatInfo; }
+			set { preferedWireFormatInfo = value; }
+		}
 
-                if(tightEncodingEnabled) {
-					
+		public void clearMarshallers()
+		{
+			for (int i=0; i < dataMarshallers.Length; i++ )
+			{
+				dataMarshallers[i] = null;
+			}
+		}
+
+		public void addMarshaller(BaseDataStreamMarshaller marshaller)
+		{
+			byte type = marshaller.GetDataStructureType();
+			dataMarshallers[type & 0xFF] = marshaller;
+		}
+
+		public void Marshal(Object o, BinaryWriter ds)
+		{
+			int size = 1;
+			if(o != null)
+			{
+				DataStructure c = (DataStructure) o;
+				byte type = c.GetDataStructureType();
+				BaseDataStreamMarshaller dsm = dataMarshallers[type & 0xFF];
+				if(dsm == null)
+				{
+					throw new IOException("Unknown data type: " + type);
+				}
+
+				if(tightEncodingEnabled)
+				{
 					BooleanStream bs = new BooleanStream();
 					size += dsm.TightMarshal1(this, c, bs);
 					size += bs.MarshalledSize();
-					
-                    if( !sizePrefixDisabled ) {
+
+					if(!sizePrefixDisabled)
+					{
 						ds.Write(size);
 					}
-					
+
 					ds.Write(type);
 					bs.Marshal(ds);
 					dsm.TightMarshal2(this, c, ds, bs);
-					
-				} else {
-					
+				}
+				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();
+					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);
+
+					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
+			}
+			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 = dataMarshallers[dataType & 0xFF];
-                if (dsm == null)
-                    throw new IOException("Unknown data type: " + dataType);
-                Tracer.Debug("Parsing type: " + dataType + " with: " + dsm);
-                Object data = dsm.CreateObject();
-				
+
+			// first byte is the type of the packet
+			byte dataType = dis.ReadByte();
+			if(dataType != NULL_TYPE)
+			{
+				BaseDataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF];
+				if(dsm == null)
+				{
+					throw new IOException("Unknown data type: " + dataType);
+				}
+
+				Tracer.Debug("Parsing type: " + dataType + " with: " + dsm);
+				Object data = dsm.CreateObject();
+
 				if(tightEncodingEnabled)
 				{
 					BooleanStream bs = new BooleanStream();
@@ -205,172 +243,173 @@
 					dsm.LooseUnmarshal(this, data, dis);
 					return data;
 				}
-            }
-            else
-            {
-                return null;
-            }
-        }
-        
-        public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
-        {
-            bs.WriteBoolean(o != null);
+			}
+			else
+			{
+				return null;
+			}
+		}
+
+		public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
+		{
+			bs.WriteBoolean(o != null);
 			if(o == null)
 			{
 				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)
+
+			if(o.IsMarshallAware())
 			{
-                throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
-            }
+				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 = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
+			BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
 			if(dsm == null)
 			{
 				throw new IOException("Unknown data type: " + 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)
-        {
+			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 = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
+
+			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 = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
 				if(dsm == null)
 				{
 					throw new IOException("Unknown data type: " + type);
 				}
-                dsm.TightMarshal2(this, o, ds, bs);
-            }
-        }
-        
-        public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
-        {
-            if(bs.ReadBoolean())
-            {
-                byte dataType = dis.ReadByte();
-                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[dataType & 0xFF];
+				dsm.TightMarshal2(this, o, ds, bs);
+			}
+		}
+
+		public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
+		{
+			if(bs.ReadBoolean())
+			{
+				byte dataType = dis.ReadByte();
+				BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[dataType & 0xFF];
 				if(dsm == null)
 				{
 					throw new IOException("Unknown data type: " + dataType);
 				}
-                DataStructure 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)
-        {
+				DataStructure 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)
 			{
 				byte type = o.GetDataStructureType();
 				dataOut.Write(type);
-                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
+				BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
 				if(dsm == null)
 				{
 					throw new IOException("Unknown data type: " + type);
 				}
 				dsm.LooseMarshal(this, o, dataOut);
 			}
-        }
-        
-        public DataStructure LooseUnmarshalNestedObject(BinaryReader dis)
-        {
-            if(dis.ReadBoolean())
-            {
-                byte dataType = dis.ReadByte();
-                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[dataType & 0xFF];
+		}
+
+		public DataStructure LooseUnmarshalNestedObject(BinaryReader dis)
+		{
+			if(dis.ReadBoolean())
+			{
+				byte dataType = dis.ReadByte();
+				BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[dataType & 0xFF];
 				if(dsm == null)
 				{
 					throw new IOException("Unknown data type: " + dataType);
 				}
-                DataStructure data = dsm.CreateObject();
+				DataStructure data = dsm.CreateObject();
 				dsm.LooseUnmarshal(this, data, dis);
-                return data;
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        public void renegotiateWireFormat(WireFormatInfo info)
-        {
-            if(info.Version < minimumVersion)
-            {
-                throw new IOException("Remote wire format (" + info.Version +") is lower than the minimum version required (" + minimumVersion + ")");
-            }
+				return data;
+			}
+			else
+			{
+				return null;
+			}
+		}
+
+		public void renegotiateWireFormat(WireFormatInfo info)
+		{
+			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.stackTraceEnabled = info.StackTraceEnabled && PreferedWireFormatInfo.StackTraceEnabled;
+			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.sizePrefixDisabled = info.SizePrefixDisabled && PreferedWireFormatInfo.SizePrefixDisabled;
+			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;
 			}
-
-			// The following options is not used client-side.
-			// this.cacheEnabled = info.CacheEnabled && PreferedWireFormatInfo.CacheEnabled;
 		}
-    }
+	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.cs?rev=693666&r1=693665&r2=693666&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/PrimitiveMap.cs Tue Sep  9 17:20:49 2008
@@ -21,527 +21,520 @@
 
 namespace Apache.NMS.ActiveMQ.OpenWire
 {
-    /// <summary>
-    /// A default implementation of IPrimitiveMap
-    /// </summary>
-    public class PrimitiveMap : IPrimitiveMap
-    {
-        public const byte NULL                    = 0;
-        public const byte BOOLEAN_TYPE            = 1;
-        public const byte BYTE_TYPE               = 2;
-        public const byte CHAR_TYPE               = 3;
-        public const byte SHORT_TYPE              = 4;
-        public const byte INTEGER_TYPE            = 5;
-        public const byte LONG_TYPE               = 6;
-        public const byte DOUBLE_TYPE             = 7;
-        public const byte FLOAT_TYPE              = 8;
-        public const byte STRING_TYPE             = 9;
-        public const byte BYTE_ARRAY_TYPE         = 10;
-        public const byte MAP_TYPE                = 11;
-        public const byte LIST_TYPE               = 12;
-        public const byte BIG_STRING_TYPE         = 13;
-
-        private IDictionary dictionary = new Hashtable();
-        
-        public void Clear()
-        {
-            dictionary.Clear();
-        }
-        
-        public bool Contains(Object key)
-        {
-            return dictionary.Contains(key);
-        }
-        
-        public void Remove(Object key)
-        {
-            dictionary.Remove(key);
-        }
-        
-        
-        public int Count
-        {
-            get {
-                return dictionary.Count;
-            }
-        }
-        
-        public ICollection Keys
-        {
-            get {
-                return dictionary.Keys;
-            }
-        }
-        
-        public ICollection Values
-        {
-            get {
-                return dictionary.Values;
-            }
-        }
-        
-        public object this[string key]
-        {
-            get {
-                return GetValue(key);
-            }
-            set {
-                CheckValidType(value);
-                SetValue(key, value);
-            }
-        }
-        
-        public string GetString(string key)
-        {
-            Object value = GetValue(key);
+	/// <summary>
+	/// A default implementation of IPrimitiveMap
+	/// </summary>
+	public class PrimitiveMap : IPrimitiveMap
+	{
+		public const byte NULL                    = 0;
+		public const byte BOOLEAN_TYPE            = 1;
+		public const byte BYTE_TYPE               = 2;
+		public const byte CHAR_TYPE               = 3;
+		public const byte SHORT_TYPE              = 4;
+		public const byte INTEGER_TYPE            = 5;
+		public const byte LONG_TYPE               = 6;
+		public const byte DOUBLE_TYPE             = 7;
+		public const byte FLOAT_TYPE              = 8;
+		public const byte STRING_TYPE             = 9;
+		public const byte BYTE_ARRAY_TYPE         = 10;
+		public const byte MAP_TYPE                = 11;
+		public const byte LIST_TYPE               = 12;
+		public const byte BIG_STRING_TYPE         = 13;
+
+		private IDictionary dictionary = Hashtable.Synchronized(new Hashtable());
+
+		public void Clear()
+		{
+			dictionary.Clear();
+		}
+
+		public bool Contains(Object key)
+		{
+			return dictionary.Contains(key);
+		}
+
+		public void Remove(Object key)
+		{
+			dictionary.Remove(key);
+		}
+
+		public int Count
+		{
+			get { return dictionary.Count; }
+		}
+
+		public ICollection Keys
+		{
+			get { lock(dictionary.SyncRoot) return new ArrayList(dictionary.Keys); }
+		}
+
+		public ICollection Values
+		{
+			get { lock(dictionary.SyncRoot) return new ArrayList(dictionary.Values); }
+		}
+
+		public object this[string key]
+		{
+			get { return GetValue(key); }
+			set
+			{
+				CheckValidType(value);
+				SetValue(key, value);
+			}
+		}
+
+		public string GetString(string key)
+		{
+			Object value = GetValue(key);
 			if( value == null )
 			{
 				return null;
 			}
-            CheckValueType(value, typeof(string));
-            return (string) value;
-        }
-        
-        public void SetString(string key, string value)
-        {
-            SetValue(key, value);
-        }
-        
-        public bool GetBool(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(bool));
-            return (bool) value;
-        }
-        
-        public void SetBool(String key, bool value)
-        {
-            SetValue(key, value);
-        }
-        
-        public byte GetByte(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(byte));
-            return (byte) value;
-        }
-        
-        public void SetByte(String key, byte value)
-        {
-            SetValue(key, value);
-        }
-        
-        public char GetChar(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(char));
-            return (char) value;
-        }
-        
-        public void SetChar(String key, char value)
-        {
-            SetValue(key, value);
-        }
-        
-        public short GetShort(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(short));
-            return (short) value;
-        }
-        
-        public void SetShort(String key, short value)
-        {
-            SetValue(key, value);
-        }
-        
-        public int GetInt(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(int));
-            return (int) value;
-        }
-        
-        public void SetInt(String key, int value)
-        {
-            SetValue(key, value);
-        }
-        
-        public long GetLong(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(long));
-            return (long) value;
-        }
-        
-        public void SetLong(String key, long value)
-        {
-            SetValue(key, value);
-        }
-        
-        public float GetFloat(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(float));
-            return (float) value;
-        }
-        
-        public void SetFloat(String key, float value)
-        {
-            SetValue(key, value);
-        }
-        
-        public double GetDouble(String key)
-        {
-            Object value = GetValue(key);
-            CheckValueType(value, typeof(double));
-            return (double) value;
-        }
-        
-        public void SetDouble(String key, double value)
-        {
-            SetValue(key, value);
-        }
-
-        public IList GetList(String key)
-        {
-            Object value = GetValue(key);
-            if (value != null && !(value is IList))
-            {
-                throw new NMSException("Property: " + key + " is not an IList but is: " + value);
-            }
-            return (IList) value;
-        }
-
-        public void SetList(String key, IList value)
-        {
-            SetValue(key, value);
-        }
-
-        public IDictionary GetDictionary(String key)
-        {
-            Object value = GetValue(key);
-            if (value != null && !(value is IDictionary))
-            {
-                throw new NMSException("Property: " + key + " is not an IDictionary but is: " + value);
-            }
-            return (IDictionary) value;
-        }
-
-        public void SetDictionary(String key, IDictionary value)
-        {
-            SetValue(key, value);
-        }
-
-        
-        protected virtual void SetValue(String key, Object value)
-        {
-            dictionary[key] = value;
-        }
-        
-        
-        protected virtual Object GetValue(String key)
-        {
-            return dictionary[key];
-        }
-        
-        protected virtual void CheckValueType(Object value, Type type)
-        {
-            if (! type.IsInstanceOfType(value))
-            {
-                throw new NMSException("Expected type: " + type.Name + " but was: " + value);
-            }
-        }
-        
-        protected virtual void CheckValidType(Object value)
-        {
-            if (value != null && !(value is IList) && !(value is IDictionary))
-            {
-                Type type = value.GetType();
-                if (! type.IsPrimitive && !type.IsValueType && !type.IsAssignableFrom(typeof(string)))
-                {
-                    throw new NMSException("Invalid type: " + type.Name + " for value: " + value);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Method ToString
-        /// </summary>
-        /// <returns>A string</returns>
-        public override String ToString()
-        {
-            String s="{";
-            bool first=true;
-            foreach (DictionaryEntry entry in dictionary)
-            {
-                if( !first ) {
-                    s+=", ";
-                }
-                first=false;
-                String name = (String) entry.Key;
-                Object value = entry.Value;
-                s+=name+"="+value;
-            }
-            s += "}";
-            return s;
-        }
-
-
-
-
-        /// <summary>
-        /// Unmarshalls the map from the given data or if the data is null just
-        /// return an empty map
-        /// </summary>
-        public static PrimitiveMap Unmarshal(byte[] data)
-        {
-            PrimitiveMap answer = new PrimitiveMap();
-            answer.dictionary = UnmarshalPrimitiveMap(data);
-            return answer;
-        }
-        
-        public byte[] Marshal()
-        {
-            return MarshalPrimitiveMap(dictionary);
-        }
-
-
-        /// <summary>
-        /// Marshals the primitive type map to a byte array
-        /// </summary>
-        public static byte[] MarshalPrimitiveMap(IDictionary map)
-        {
-            if (map == null)
-            {
-                return null;
-            }
-            else
-            {
-                MemoryStream memoryStream = new MemoryStream();
-                MarshalPrimitiveMap(map, new OpenWireBinaryWriter(memoryStream));
-                return memoryStream.GetBuffer();
-            }
-        }
-        
-        public static void MarshalPrimitiveMap(IDictionary map, BinaryWriter dataOut)
-        {
-            if (map == null)
-            {
-                dataOut.Write((int)-1);
-            }
-            else
-            {
-                dataOut.Write(map.Count);
-                foreach (DictionaryEntry entry in map)
-                {
-                    String name = (String) entry.Key;
-                    dataOut.Write(name);
-                    Object value = entry.Value;
-                    MarshalPrimitive(dataOut, value);
-                }
-            }}
-        
-        
-        
-        /// <summary>
-        /// Unmarshals the primitive type map from the given byte array
-        /// </summary>
-        public static  IDictionary UnmarshalPrimitiveMap(byte[] data)
-        {
-            if (data == null)
-            {
-                return new Hashtable();
-            }
-            else
-            {
-                return UnmarshalPrimitiveMap(new OpenWireBinaryReader(new MemoryStream(data)));
-            }
-        }
-        
-        public static  IDictionary UnmarshalPrimitiveMap(BinaryReader dataIn)
-        {
-            int size = dataIn.ReadInt32();
-            if (size < 0)
-            {
-                return null;
-            }
-            else
-            {
-                IDictionary answer = new Hashtable(size);
-                for (int i=0; i < size; i++)
-                {
-                    String name = dataIn.ReadString();
-                    answer[name] = UnmarshalPrimitive(dataIn);
-                }
-                return answer;
-            }
-            
-        }
-
-        public static void MarshalPrimitiveList(IList list, BinaryWriter dataOut)
-        {
-            dataOut.Write((int) list.Count);
-            foreach (Object element in list)
-            {
-                MarshalPrimitive(dataOut, element);
-            }
-        }
-
-        public static IList UnmarshalPrimitiveList(BinaryReader dataIn)
-        {
-            int size = dataIn.ReadInt32();
-            IList answer = new ArrayList(size);
-            while (size-- > 0) {
-                answer.Add(UnmarshalPrimitive(dataIn));
-            }
-            return answer;
-        }
-
-
-        public static void MarshalPrimitive(BinaryWriter dataOut, Object value)
-        {
-            if (value == null)
-            {
-                dataOut.Write(NULL);
-            }
-            else if (value is bool)
-            {
-                dataOut.Write(BOOLEAN_TYPE);
-                dataOut.Write((bool) value);
-            }
-            else if (value is byte)
-            {
-                dataOut.Write(BYTE_TYPE);
-                dataOut.Write(((byte)value));
-            }
-            else if (value is char)
-            {
-                dataOut.Write(CHAR_TYPE);
-                dataOut.Write((char) value);
-            }
-            else if (value is short)
-            {
-                dataOut.Write(SHORT_TYPE);
-                dataOut.Write((short) value);
-            }
-            else if (value is int)
-            {
-                dataOut.Write(INTEGER_TYPE);
-                dataOut.Write((int) value);
-            }
-            else if (value is long)
-            {
-                dataOut.Write(LONG_TYPE);
-                dataOut.Write((long) value);
-            }
-            else if (value is float)
-            {
-                dataOut.Write(FLOAT_TYPE);
-                dataOut.Write((float) value);
-            }
-            else if (value is double)
-            {
-                dataOut.Write(DOUBLE_TYPE);
-                dataOut.Write((double) value);
-            }
-            else if (value is byte[])
-            {
-                byte[] data = (byte[]) value;
-                dataOut.Write(BYTE_ARRAY_TYPE);
-                dataOut.Write(data.Length);
-                dataOut.Write(data);
-            }
-            else if (value is string)
-            {
-                string s = (string) value;
-                // is the string big??
-                if (s.Length > 8191)
-                {
-                    dataOut.Write(BIG_STRING_TYPE);
-                    dataOut.Write(s);
-                }
-                else
-                {
-                    dataOut.Write(STRING_TYPE);
-                    dataOut.Write(s);
-                }
-            }
-            else if (value is IDictionary)
-            {
-                dataOut.Write(MAP_TYPE);
-                MarshalPrimitiveMap((IDictionary) value, dataOut);
-            }
-            else if (value is IList)
-            {
-                dataOut.Write(LIST_TYPE);
-                MarshalPrimitiveList((IList) value, dataOut);
-            }
-            else
-            {
-                throw new IOException("Object is not a primitive: " + value);
-            }
-        }
-        
-        public static Object UnmarshalPrimitive(BinaryReader dataIn)
-        {
-            Object value=null;
-            byte type = dataIn.ReadByte();
-            switch (type)
-            {
-                case NULL:
-                    value = null;
-                    break;
-                case BYTE_TYPE:
-                    value = dataIn.ReadByte();
-                    break;
-                case BOOLEAN_TYPE:
-                    value = dataIn.ReadBoolean();
-                    break;
-                case CHAR_TYPE:
-                    value = dataIn.ReadChar();
-                    break;
-                case SHORT_TYPE:
-                    value = dataIn.ReadInt16();
-                    break;
-                case INTEGER_TYPE:
-                    value = dataIn.ReadInt32();
-                    break;
-                case LONG_TYPE:
-                    value = dataIn.ReadInt64();
-                    break;
-                case FLOAT_TYPE:
-                    value = dataIn.ReadSingle();
-                    break;
-                case DOUBLE_TYPE:
-                    value = dataIn.ReadDouble();
-                    break;
-                case BYTE_ARRAY_TYPE:
-                    int size = dataIn.ReadInt32();
-                    byte[] data = new byte[size];
-                    dataIn.Read(data, 0, size);
-                    value = data;
-                    break;
-                case STRING_TYPE:
-                    value = dataIn.ReadString();
-                    break;
-                case BIG_STRING_TYPE:
-                    value = dataIn.ReadString();
-                    break;
-                case MAP_TYPE:
-                    value = UnmarshalPrimitiveMap(dataIn);
-                    break;
-
-                case LIST_TYPE:
-                    value = UnmarshalPrimitiveList(dataIn);
-                    break;
-
-                default:
-                    throw new Exception("Unsupported data type: " + type);
-            }
-            return value;
-        }
+			CheckValueType(value, typeof(string));
+			return (string) value;
+		}
+
+		public void SetString(string key, string value)
+		{
+			SetValue(key, value);
+		}
+
+		public bool GetBool(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(bool));
+			return (bool) value;
+		}
+
+		public void SetBool(String key, bool value)
+		{
+			SetValue(key, value);
+		}
+
+		public byte GetByte(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(byte));
+			return (byte) value;
+		}
+
+		public void SetByte(String key, byte value)
+		{
+			SetValue(key, value);
+		}
+
+		public char GetChar(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(char));
+			return (char) value;
+		}
+
+		public void SetChar(String key, char value)
+		{
+			SetValue(key, value);
+		}
+
+		public short GetShort(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(short));
+			return (short) value;
+		}
+
+		public void SetShort(String key, short value)
+		{
+			SetValue(key, value);
+		}
+
+		public int GetInt(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(int));
+			return (int) value;
+		}
+
+		public void SetInt(String key, int value)
+		{
+			SetValue(key, value);
+		}
+
+		public long GetLong(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(long));
+			return (long) value;
+		}
+
+		public void SetLong(String key, long value)
+		{
+			SetValue(key, value);
+		}
+
+		public float GetFloat(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(float));
+			return (float) value;
+		}
+
+		public void SetFloat(String key, float value)
+		{
+			SetValue(key, value);
+		}
+
+		public double GetDouble(String key)
+		{
+			Object value = GetValue(key);
+			CheckValueType(value, typeof(double));
+			return (double) value;
+		}
+
+		public void SetDouble(String key, double value)
+		{
+			SetValue(key, value);
+		}
+
+		public IList GetList(String key)
+		{
+			Object value = GetValue(key);
+			if (value != null && !(value is IList))
+			{
+				throw new NMSException("Property: " + key + " is not an IList but is: " + value);
+			}
+			return (IList) value;
+		}
+
+		public void SetList(String key, IList value)
+		{
+			SetValue(key, value);
+		}
+
+		public IDictionary GetDictionary(String key)
+		{
+			Object value = GetValue(key);
+			if (value != null && !(value is IDictionary))
+			{
+				throw new NMSException("Property: " + key + " is not an IDictionary but is: " + value);
+			}
+			return (IDictionary) value;
+		}
+
+		public void SetDictionary(String key, IDictionary value)
+		{
+			SetValue(key, value);
+		}
+
+		protected virtual void SetValue(String key, Object value)
+		{
+			dictionary[key] = value;
+		}
+
+		protected virtual Object GetValue(String key)
+		{
+			return dictionary[key];
+		}
+
+		protected virtual void CheckValueType(Object value, Type type)
+		{
+			if (! type.IsInstanceOfType(value))
+			{
+				throw new NMSException("Expected type: " + type.Name + " but was: " + value);
+			}
+		}
+
+		protected virtual void CheckValidType(Object value)
+		{
+			if (value != null && !(value is IList) && !(value is IDictionary))
+			{
+				Type type = value.GetType();
+				if (! type.IsPrimitive && !type.IsValueType && !type.IsAssignableFrom(typeof(string)))
+				{
+					throw new NMSException("Invalid type: " + type.Name + " for value: " + value);
+				}
+			}
+		}
+
+		/// <summary>
+		/// Method ToString
+		/// </summary>
+		/// <returns>A string</returns>
+		public override String ToString()
+		{
+			String s="{";
+			bool first=true;
+			lock(dictionary.SyncRoot)
+			{
+				foreach(DictionaryEntry entry in dictionary)
+				{
+					if(!first)
+					{
+						s+=", ";
+					}
+					first=false;
+					String name = (String) entry.Key;
+					Object value = entry.Value;
+					s += name + "=" + value;
+				}
+			}
+			s += "}";
+			return s;
+		}
+
+		/// <summary>
+		/// Unmarshalls the map from the given data or if the data is null just
+		/// return an empty map
+		/// </summary>
+		public static PrimitiveMap Unmarshal(byte[] data)
+		{
+			PrimitiveMap answer = new PrimitiveMap();
+			answer.dictionary = UnmarshalPrimitiveMap(data);
+			return answer;
+		}
+
+		public byte[] Marshal()
+		{
+			lock(dictionary.SyncRoot)
+			{
+				return MarshalPrimitiveMap(dictionary);
+			}
+		}
+
+		/// <summary>
+		/// Marshals the primitive type map to a byte array
+		/// </summary>
+		public static byte[] MarshalPrimitiveMap(IDictionary map)
+		{
+			if(map == null)
+			{
+				return null;
+			}
+
+			MemoryStream memoryStream = new MemoryStream();
+			lock(map.SyncRoot)
+			{
+				MarshalPrimitiveMap(map, new OpenWireBinaryWriter(memoryStream));
+			}
+
+			return memoryStream.GetBuffer();
+		}
+
+		public static void MarshalPrimitiveMap(IDictionary map, BinaryWriter dataOut)
+		{
+			if(map == null)
+			{
+				dataOut.Write((int)-1);
+			}
+			else
+			{
+				lock(map.SyncRoot)
+				{
+					dataOut.Write(map.Count);
+					foreach(DictionaryEntry entry in map)
+					{
+						String name = (String) entry.Key;
+						dataOut.Write(name);
+						Object value = entry.Value;
+						MarshalPrimitive(dataOut, value);
+					}
+				}
+			}
+		}
+
+		/// <summary>
+		/// Unmarshals the primitive type map from the given byte array
+		/// </summary>
+		public static  IDictionary UnmarshalPrimitiveMap(byte[] data)
+		{
+			if(data == null)
+			{
+				return new Hashtable();
+			}
+			else
+			{
+				return UnmarshalPrimitiveMap(new OpenWireBinaryReader(new MemoryStream(data)));
+			}
+		}
+
+		public static  IDictionary UnmarshalPrimitiveMap(BinaryReader dataIn)
+		{
+			int size = dataIn.ReadInt32();
+			if (size < 0)
+			{
+				return null;
+			}
+
+			IDictionary answer = new Hashtable(size);
+			for(int i = 0; i < size; i++)
+			{
+				String name = dataIn.ReadString();
+				answer[name] = UnmarshalPrimitive(dataIn);
+			}
+
+			return answer;
+		}
+
+		public static void MarshalPrimitiveList(IList list, BinaryWriter dataOut)
+		{
+			dataOut.Write((int) list.Count);
+			foreach (Object element in list)
+			{
+				MarshalPrimitive(dataOut, element);
+			}
+		}
+
+		public static IList UnmarshalPrimitiveList(BinaryReader dataIn)
+		{
+			int size = dataIn.ReadInt32();
+			IList answer = new ArrayList(size);
+			while (size-- > 0)
+			{
+				answer.Add(UnmarshalPrimitive(dataIn));
+			}
+
+			return answer;
+		}
+
+		public static void MarshalPrimitive(BinaryWriter dataOut, Object value)
+		{
+			if (value == null)
+			{
+				dataOut.Write(NULL);
+			}
+			else if (value is bool)
+			{
+				dataOut.Write(BOOLEAN_TYPE);
+				dataOut.Write((bool) value);
+			}
+			else if (value is byte)
+			{
+				dataOut.Write(BYTE_TYPE);
+				dataOut.Write(((byte)value));
+			}
+			else if (value is char)
+			{
+				dataOut.Write(CHAR_TYPE);
+				dataOut.Write((char) value);
+			}
+			else if (value is short)
+			{
+				dataOut.Write(SHORT_TYPE);
+				dataOut.Write((short) value);
+			}
+			else if (value is int)
+			{
+				dataOut.Write(INTEGER_TYPE);
+				dataOut.Write((int) value);
+			}
+			else if (value is long)
+			{
+				dataOut.Write(LONG_TYPE);
+				dataOut.Write((long) value);
+			}
+			else if (value is float)
+			{
+				dataOut.Write(FLOAT_TYPE);
+				dataOut.Write((float) value);
+			}
+			else if (value is double)
+			{
+				dataOut.Write(DOUBLE_TYPE);
+				dataOut.Write((double) value);
+			}
+			else if (value is byte[])
+			{
+				byte[] data = (byte[]) value;
+				dataOut.Write(BYTE_ARRAY_TYPE);
+				dataOut.Write(data.Length);
+				dataOut.Write(data);
+			}
+			else if (value is string)
+			{
+				string s = (string) value;
+				// is the string big??
+				if (s.Length > 8191)
+				{
+					dataOut.Write(BIG_STRING_TYPE);
+					dataOut.Write(s);
+				}
+				else
+				{
+					dataOut.Write(STRING_TYPE);
+					dataOut.Write(s);
+				}
+			}
+			else if (value is IDictionary)
+			{
+				dataOut.Write(MAP_TYPE);
+				MarshalPrimitiveMap((IDictionary) value, dataOut);
+			}
+			else if (value is IList)
+			{
+				dataOut.Write(LIST_TYPE);
+				MarshalPrimitiveList((IList) value, dataOut);
+			}
+			else
+			{
+				throw new IOException("Object is not a primitive: " + value);
+			}
+		}
 
-        
-    }
+		public static Object UnmarshalPrimitive(BinaryReader dataIn)
+		{
+			Object value=null;
+			byte type = dataIn.ReadByte();
+			switch (type)
+			{
+				case NULL:
+					value = null;
+					break;
+				case BYTE_TYPE:
+					value = dataIn.ReadByte();
+					break;
+				case BOOLEAN_TYPE:
+					value = dataIn.ReadBoolean();
+					break;
+				case CHAR_TYPE:
+					value = dataIn.ReadChar();
+					break;
+				case SHORT_TYPE:
+					value = dataIn.ReadInt16();
+					break;
+				case INTEGER_TYPE:
+					value = dataIn.ReadInt32();
+					break;
+				case LONG_TYPE:
+					value = dataIn.ReadInt64();
+					break;
+				case FLOAT_TYPE:
+					value = dataIn.ReadSingle();
+					break;
+				case DOUBLE_TYPE:
+					value = dataIn.ReadDouble();
+					break;
+				case BYTE_ARRAY_TYPE:
+					int size = dataIn.ReadInt32();
+					byte[] data = new byte[size];
+					dataIn.Read(data, 0, size);
+					value = data;
+					break;
+				case STRING_TYPE:
+					value = dataIn.ReadString();
+					break;
+				case BIG_STRING_TYPE:
+					value = dataIn.ReadString();
+					break;
+				case MAP_TYPE:
+					value = UnmarshalPrimitiveMap(dataIn);
+					break;
+				case LIST_TYPE:
+					value = UnmarshalPrimitiveList(dataIn);
+					break;
+
+				default:
+					throw new Exception("Unsupported data type: " + type);
+			}
+			return value;
+		}
+	}
 }

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/MaxInactivityDurationTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/MaxInactivityDurationTest.cs?rev=693666&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/MaxInactivityDurationTest.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/OpenWire/MaxInactivityDurationTest.cs Tue Sep  9 17:20:49 2008
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Apache.NMS.Util;
+using NUnit.Framework;
+using NUnit.Framework.Extensions;
+using System.Threading;
+
+namespace Apache.NMS.Test
+{
+	[TestFixture]
+	public class MaxInactivityDurationTest : NMSTestSupport
+	{
+		protected static string DESTINATION_NAME = "TestMaxInactivityDuration";
+		protected static string CORRELATION_ID = "MaxInactivityCorrelationID";
+
+		/// <summary>
+		/// The name of the connection configuration that CreateNMSFactory() will load.
+		/// </summary>
+		/// <returns></returns>
+		protected override string GetNameTestURI() { return "maxInactivityDurationURI"; }
+
+		[Test, Explicit]
+		public void TestMaxInactivityDuration()
+		{
+			using(IConnection connection = CreateConnection())
+			{
+				connection.Start();
+				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+				{
+					IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+					using(IMessageConsumer consumer = session.CreateConsumer(destination))
+					using(IMessageProducer producer = session.CreateProducer(destination))
+					{
+						SendMessage(producer);
+
+						IMessage receivedMsg = consumer.Receive(TimeSpan.FromSeconds(5));
+						Assert.AreEqual(CORRELATION_ID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+
+						// Go inactive...
+						Thread.Sleep(TimeSpan.FromSeconds(60));
+
+						// Send another message.
+						SendMessage(producer);
+						receivedMsg = consumer.Receive(TimeSpan.FromSeconds(5));
+						Assert.AreEqual(CORRELATION_ID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+					}
+				}
+			}
+		}
+
+		protected void SendMessage(IMessageProducer producer)
+		{
+			IMessage request = producer.CreateMessage();
+			request.NMSCorrelationID = CORRELATION_ID;
+			request.NMSType = "Test";
+			producer.Send(request);
+		}
+	}
+}

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=693666&r1=693665&r2=693666&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 Tue Sep  9 17:20:49 2008
@@ -17,7 +17,8 @@
     <UpgradeBackupLocation>
     </UpgradeBackupLocation>
     <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>activemq-dotnet.snk</AssemblyOriginatorKeyFile>
+    <AssemblyOriginatorKeyFile>
+    </AssemblyOriginatorKeyFile>
     <SccProjectName>Svn</SccProjectName>
     <SccLocalPath>Svn</SccLocalPath>
     <SccAuxPath>Svn</SccAuxPath>
@@ -41,6 +42,7 @@
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+    <Reference Include="nunit.framework.extensions, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
@@ -58,6 +60,7 @@
     <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\PrimitiveMapTest.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -78,7 +81,6 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <None Include="activemq-dotnet.snk" />
     <Content Include="nmsprovider-test.config">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>

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=693666&r1=693665&r2=693666&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/vs2008-activemq.csproj Tue Sep  9 17:20:49 2008
@@ -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>
@@ -10,7 +10,8 @@
     <AssemblyName>Apache.NMS.ActiveMQ</AssemblyName>
     <WarningLevel>4</WarningLevel>
     <SignAssembly>true</SignAssembly>
-    <AssemblyOriginatorKeyFile>activemq-dotnet.snk</AssemblyOriginatorKeyFile>
+    <AssemblyOriginatorKeyFile>
+    </AssemblyOriginatorKeyFile>
     <FileUpgradeFlags>
     </FileUpgradeFlags>
     <OldToolsVersion>2.0</OldToolsVersion>
@@ -59,7 +60,6 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="activemq-dotnet.snk" />
     <Content Include="nmsprovider-activemq.config">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=693666&r1=693665&r2=693666&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Tue Sep  9 17:20:49 2008
@@ -195,6 +195,16 @@
 		/// </summary>
 		/// <param name="newClientId">Client ID of the new connection.</param>
 		/// <returns></returns>
+		public virtual IConnection CreateConnection()
+		{
+			return CreateConnection(null);
+		}
+
+		/// <summary>
+		/// Create a new connection to the broker.
+		/// </summary>
+		/// <param name="newClientId">Client ID of the new connection.</param>
+		/// <returns></returns>
 		public virtual IConnection CreateConnection(string newClientId)
 		{
 			IConnection newConnection = Factory.CreateConnection(userName, passWord);



Mime
View raw message