activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r822765 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/Connection.cs main/csharp/ConnectionMetaData.cs test/csharp/ConnectionMetaDataTest.cs
Date Wed, 07 Oct 2009 14:55:02 GMT
Author: tabish
Date: Wed Oct  7 14:55:01 2009
New Revision: 822765

URL: http://svn.apache.org/viewvc?rev=822765&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQNET-96

Adds an implementation of IConnectionMetaData interface and an accessor for it in IConnection
along with a unit test for it.

Added:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionMetaData.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/ConnectionMetaDataTest.cs
  (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs

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=822765&r1=822764&r2=822765&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 Wed Oct
 7 14:55:01 2009
@@ -38,9 +38,6 @@
 		private WireFormatInfo brokerWireFormatInfo; // from broker
 		private readonly IList sessions = ArrayList.Synchronized(new ArrayList());
         private readonly IDictionary producers = Hashtable.Synchronized(new Hashtable());
-		/// <summary>
-		/// Private object used for synchronization, instead of public "this"
-		/// </summary>
 		private readonly object myLock = new object();
 		private bool asyncSend = false;
         private bool alwaysSyncSend = false;
@@ -54,6 +51,7 @@
 		private int temporaryDestinationCounter = 0;
 		private int localTransactionCounter;
 		private readonly Atomic<bool> started = new Atomic<bool>(false);
+        private ConnectionMetaData metaData = null;
 		private bool disposed = false;
 
 		public Connection(Uri connectionUri, ITransport transport, ConnectionInfo info)
@@ -165,6 +163,19 @@
             set { copyMessageOnSend = value; }
         }
         
+        public IConnectionMetaData MetaData
+        {
+            get 
+            { 
+                if(this.metaData == null)
+                {
+                    this.metaData = new ConnectionMetaData();
+                }
+                
+                return this.metaData; 
+            }
+        }
+        
 		#endregion
 
 		/// <summary>

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionMetaData.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionMetaData.cs?rev=822765&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionMetaData.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionMetaData.cs
Wed Oct  7 14:55:01 2009
@@ -0,0 +1,110 @@
+/*
+ * 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 System.Reflection;
+using Apache.NMS;
+
+namespace Apache.NMS.ActiveMQ
+{
+    /// <summary>
+    /// Implements the Connection Meta-Data feature for Apache.NMS.ActiveMQ
+    /// </summary>
+    public class ConnectionMetaData : IConnectionMetaData
+    {
+        private int nmsMajorVersion;
+        private int nmsMinorVersion;
+
+        private string nmsProviderName;
+        private string nmsVersion;
+
+        private int providerMajorVersion;
+        private int providerMinorVersion;
+        private string providerVersion;        
+
+        private string[] nmsxProperties;
+
+        public ConnectionMetaData()
+        {
+            Assembly self = Assembly.GetExecutingAssembly();
+            AssemblyName asmName = self.GetName();
+
+            this.nmsProviderName = asmName.Name;
+            this.providerMajorVersion = asmName.Version.Major;
+            this.providerMinorVersion = asmName.Version.Minor;
+            this.providerVersion = asmName.Version.ToString();
+
+            this.nmsxProperties = 
+                new String[]{ "NMSXGroupID", "NMSXGroupSeq", "NMSXDeliveryCount", "NMSXProducerTXID"
};
+            
+            foreach( AssemblyName name in self.GetReferencedAssemblies() )
+            {
+                if( name.Name == "Apache.NMS" )
+                {
+                    this.nmsMajorVersion = name.Version.Major;
+                    this.nmsMinorVersion = name.Version.Minor;
+                    this.nmsVersion = name.Version.ToString();
+                    
+                    return;
+                }
+            }
+            
+            throw new NMSException("Could not find a reference to the Apache.NMS Assembly.");
+        }
+        
+        public int NMSMajorVersion
+        { 
+            get{ return this.nmsMajorVersion; }
+        }
+        
+        public int NMSMinorVersion
+        { 
+            get{ return this.nmsMinorVersion; } 
+        }
+        
+        public string NMSProviderName
+        { 
+            get{ return this.nmsProviderName; } 
+        }
+        
+        public string NMSVersion
+        { 
+            get{ return this.nmsVersion; } 
+        }
+        
+        public string[] NMSXPropertyNames
+        { 
+            get{ return this.nmsxProperties; }
+        }
+        
+        public int ProviderMajorVersion
+        { 
+            get{ return this.providerMajorVersion; }
+        }
+
+        public int ProviderMinorVersion
+        { 
+            get{ return this.providerMinorVersion; }
+        }
+
+        public string ProviderVersion
+        {
+            get{ return this.providerVersion; }
+        }
+        
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/ConnectionMetaData.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/ConnectionMetaDataTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/ConnectionMetaDataTest.cs?rev=822765&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/ConnectionMetaDataTest.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/ConnectionMetaDataTest.cs
Wed Oct  7 14:55:01 2009
@@ -0,0 +1,45 @@
+/*
+ * 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 System.Net.Sockets;
+using Apache.NMS.Test;
+using NUnit.Framework;
+using NUnit.Framework.Extensions;
+
+namespace Apache.NMS.ActiveMQ.Test
+{
+	[TestFixture]
+	public class ConnectionMetaDataTest
+	{
+		[Test]
+		public void TestVersionInfo()
+		{
+			ConnectionMetaData data = new ConnectionMetaData();
+			
+			Assert.IsNotNull(data.NMSVersion);
+			Assert.IsTrue(data.NMSMajorVersion > 0);
+			Assert.IsTrue(data.NMSMinorVersion >= 0);
+			
+			Assert.IsTrue(data.ProviderMajorVersion > 0);
+			Assert.IsTrue(data.ProviderMinorVersion >= 0);
+			Assert.IsNotNull(data.ProviderVersion);
+			
+			Assert.IsTrue(data.NMSXPropertyNames.Length > 0);
+		}
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/ConnectionMetaDataTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message