Author: jstrachan
Date: Tue Feb 20 11:09:19 2007
New Revision: 509712
URL: http://svn.apache.org/viewvc?view=rev&rev=509712
Log:
Added some helper methods to IDestination and Command with a more .Net flavour
Modified:
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseCommand.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseDataStructure.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Command.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Response.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Connection.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransport.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/WireFormatNegotiator.cs
activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/AtomicBoolean.cs
activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs
activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/ActiveMQDestination.cs
Tue Feb 20 11:09:19 2007
@@ -102,6 +102,32 @@
//this.advisory = name != null && name.StartsWith(ADVISORY_PREFIX);
}
+
+ public bool IsTopic
+ {
+ get
+ {
+ return IsTopic;
+ }
+ }
+
+ public bool IsQueue
+ {
+ get
+ {
+ return IsQueue;
+ }
+ }
+
+ public bool IsTemporary
+ {
+ get
+ {
+ return GetDestinationType() == ACTIVEMQ_TEMPORARY_QUEUE
+ || GetDestinationType() == ACTIVEMQ_TEMPORARY_TOPIC;
+ }
+ }
+
/// <summary>
/// Dictionary of name/value pairs representing option values specified
/// in the URI used to create this Destination. A null value is returned
@@ -311,7 +337,7 @@
public static String GetClientId(ActiveMQDestination destination)
{
String answer = null;
- if (destination != null && destination.IsTemporary())
+ if (destination != null && destination.IsTemporary)
{
String name = destination.PhysicalName;
int start = name.IndexOf(TEMP_PREFIX);
@@ -365,16 +391,16 @@
}
if (answer == 0)
{
- if (IsTopic())
+ if (IsTopic)
{
- if (that.IsQueue())
+ if (that.IsQueue)
{
return 1;
}
}
else
{
- if (that.IsTopic())
+ if (that.IsTopic)
{
return -1;
}
@@ -394,46 +420,12 @@
public String PhysicalName
{
get { return this.physicalName; }
- set { this.physicalName = value;
+ set { this.physicalName = value;
this.advisory = value != null && value.StartsWith(ADVISORY_PREFIX);
}
}
/**
- * Returns true if a temporary Destination
- *
- * @return true/false
- */
-
- public bool IsTemporary()
- {
- return GetDestinationType() == ACTIVEMQ_TEMPORARY_TOPIC
- || GetDestinationType() == ACTIVEMQ_TEMPORARY_QUEUE;
- }
-
- /**
- * Returns true if a Topic Destination
- *
- * @return true/false
- */
-
- public bool IsTopic()
- {
- return GetDestinationType() == ACTIVEMQ_TOPIC
- || GetDestinationType() == ACTIVEMQ_TEMPORARY_TOPIC;
- }
-
- /**
- * Returns true if a Queue Destination
- *
- * @return true/false
- */
- public bool IsQueue()
- {
- return !IsTopic();
- }
-
- /**
* Returns true if this destination represents a collection of
* destinations; allowing a set of destinations to be published to or subscribed
* from in one NMS operation.
@@ -443,9 +435,12 @@
*
* @return true if this destination represents a collection of child destinations.
*/
- public bool IsComposite()
+ public bool IsComposite
{
- return physicalName.IndexOf(COMPOSITE_SEPARATOR) > 0;
+ get
+ {
+ return physicalName.IndexOf(COMPOSITE_SEPARATOR) > 0;
+ }
}
/*
@@ -511,7 +506,7 @@
{
answer = physicalName.GetHashCode();
}
- if (IsTopic())
+ if (IsTopic)
{
answer ^= 0xfabfab;
}
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseCommand.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseCommand.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseCommand.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseCommand.cs Tue Feb
20 11:09:19 2007
@@ -41,7 +41,6 @@
set { this.commandId = value; }
}
-
public override int GetHashCode()
{
return (CommandId * 37) + GetDataStructureType();
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseDataStructure.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseDataStructure.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseDataStructure.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/BaseDataStructure.cs
Tue Feb 20 11:09:19 2007
@@ -39,6 +39,10 @@
set { this.responseRequired = value; }
}
+ public virtual bool IsResponse {
+ get { return false; }
+ }
+
public virtual bool IsMarshallAware()
{
return false;
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Command.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Command.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Command.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Command.cs Tue Feb 20
11:09:19 2007
@@ -35,6 +35,11 @@
get;
set;
}
+
+ bool IsResponse {
+ get;
+ }
+
}
}
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Response.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Response.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Response.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Commands/Response.cs Tue Feb 20
11:09:19 2007
@@ -54,8 +54,13 @@
public int CorrelationId
{
get { return correlationId; }
- set { this.correlationId = value; }
+ set { this.correlationId = value; }
}
-
+
+ public override bool IsResponse {
+ get { return true; }
+ }
+
+
}
}
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Connection.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Connection.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Connection.cs Tue Feb 20 11:09:19
2007
@@ -66,7 +66,7 @@
public void Start()
{
CheckConnected();
- if (started.compareAndSet(false, true))
+ if (started.CompareAndSet(false, true))
{
foreach(Session session in sessions)
{
@@ -82,7 +82,7 @@
public void Stop()
{
CheckConnected();
- if (started.compareAndSet(true, false))
+ if (started.CompareAndSet(true, false))
{
foreach(Session session in sessions)
{
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransport.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransport.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Tcp/TcpTransport.cs
Tue Feb 20 11:09:19 2007
@@ -93,7 +93,7 @@
public void Close()
{
- if (closed.compareAndSet(false, true))
+ if (closed.CompareAndSet(false, true))
{
socket.Close();
if (System.Threading.Thread.CurrentThread != readThread)
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/WireFormatNegotiator.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/WireFormatNegotiator.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/WireFormatNegotiator.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/WireFormatNegotiator.cs
Tue Feb 20 11:09:19 2007
@@ -45,7 +45,7 @@
public override void Start() {
base.Start();
- if (firstStart.compareAndSet(true, false))
+ if (firstStart.CompareAndSet(true, false))
{
try
{
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/AtomicBoolean.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/AtomicBoolean.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/AtomicBoolean.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Util/AtomicBoolean.cs Tue Feb
20 11:09:19 2007
@@ -32,6 +32,13 @@
return value;
}
}
+ set
+ {
+ lock (this)
+ {
+ this.value = value;
+ }
+ }
}
public AtomicBoolean(bool b)
@@ -39,7 +46,7 @@
value = b;
}
- public bool compareAndSet(bool expected, bool newValue)
+ public bool CompareAndSet(bool expected, bool newValue)
{
lock(this)
{
@@ -48,7 +55,7 @@
value = newValue;
return true;
}
- return false;
+ return false;
}
}
}
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/IDestination.cs Tue Feb 20 11:09:19
2007
@@ -34,9 +34,13 @@
public interface IDestination
{
- DestinationType DestinationType {
- get;
- }
+ DestinationType DestinationType { get; }
+
+ bool IsTopic { get; }
+
+ bool IsQueue { get; }
+
+ bool IsTemporary { get; }
}
}
Modified: activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs?view=diff&rev=509712&r1=509711&r2=509712
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/NMS/InvalidDestinationException.cs Tue
Feb 20 11:09:19 2007
@@ -23,7 +23,7 @@
/// </summary>
public class InvalidDestinationException : NMSException
{
- public InvalidDestinationException(string message)
+ public InvalidDestinationException(string message)
: base(message)
{
}
|