Author: jgomes
Date: Wed Mar 12 23:09:42 2014
New Revision: 1576986
URL: http://svn.apache.org/r1576986
Log:
Add IDisposable interface to IDestination.
Fixes [AMQNET-473]. (See https://issues.apache.org/jira/browse/AMQNET-473)
Modified:
activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IDestination.cs
activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/Commands/Destination.cs
Modified:
activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IDestination.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IDestination.cs?rev=1576986&r1=1576985&r2=1576986&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IDestination.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IDestination.cs
Wed Mar 12 23:09:42 2014
@@ -26,23 +26,18 @@ namespace Apache.NMS
TemporaryQueue,
TemporaryTopic
}
-
-
+
/// <summary>
/// A base interface for destinations such as queues or topics
/// </summary>
- public interface IDestination
+ public interface IDestination : System.IDisposable
{
-
DestinationType DestinationType { get; }
bool IsTopic { get; }
-
bool IsQueue { get; }
-
bool IsTemporary { get; }
}
-
}
Modified:
activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/Commands/Destination.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/Commands/Destination.cs?rev=1576986&r1=1576985&r2=1576986&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/Commands/Destination.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/Commands/Destination.cs
Wed Mar 12 23:09:42 2014
@@ -49,6 +49,8 @@ namespace Apache.NMS.Commands
private String physicalName = "";
private StringDictionary options = null;
+ private bool disposed = false;
+
/// <summary>
/// The Default Constructor
/// </summary>
@@ -65,7 +67,47 @@ namespace Apache.NMS.Commands
setPhysicalName(name);
}
- public bool IsTopic
+ ~Destination()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if(disposed)
+ {
+ return;
+ }
+
+ if(disposing)
+ {
+ try
+ {
+ OnDispose();
+ }
+ catch(Exception ex)
+ {
+ Tracer.ErrorFormat("Exception disposing
Destination {0}: {1}", this.physicalName, ex.Message);
+ }
+ }
+
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Child classes can override this method to perform clean-up
logic.
+ /// </summary>
+ protected virtual void OnDispose()
+ {
+ }
+
+ public bool IsTopic
{
get
{