activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r961036 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/
Date Tue, 06 Jul 2010 22:27:15 GMT
Author: tabish
Date: Tue Jul  6 22:27:14 2010
New Revision: 961036

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

Adds a basic FailoverTransport and Inactivity monitor.  Also provides a simple ConnectionStateTracker
that can track the Connection and restore all its Consumer subscriptions once a successful
failover is completed.

Added:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/CommandVisitorAdapter.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionState.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionStateTracker.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConsumerState.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ICommandVisitor.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/SynchronizedObjects.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ThreadSimulator.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/Tracked.cs   (with
props)

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/CommandVisitorAdapter.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/CommandVisitorAdapter.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/CommandVisitorAdapter.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/CommandVisitorAdapter.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,85 @@
+/*
+ * 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 Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp.State
+{
+    public class CommandVisitorAdapter : ICommandVisitor
+    {
+        public virtual Response processAddConnection(ConnectionInfo info)
+        {
+            return null;
+        }
+
+        public virtual Response processAddConsumer(ConsumerInfo info)
+        {
+            return null;
+        }
+
+        public virtual Response processKeepAliveInfo(KeepAliveInfo info)
+        {
+            return null;
+        }
+
+        public virtual Response processMessage(Message send)
+        {
+            return null;
+        }
+
+        public virtual Response processMessageAck(MessageAck ack)
+        {
+            return null;
+        }
+
+        public virtual Response processRemoveConnection(ConnectionId id)
+        {
+            return null;
+        }
+
+        public virtual Response processRemoveConsumer(ConsumerId id)
+        {
+            return null;
+        }
+
+        public virtual Response processRemoveSubscriptionInfo(RemoveSubscriptionInfo info)
+        {
+            return null;
+        }
+
+        public virtual Response processShutdownInfo(ShutdownInfo info)
+        {
+            return null;
+        }
+
+        public virtual Response processMessageDispatch(MessageDispatch dispatch)
+        {
+            return null;
+        }
+
+        public virtual Response processResponse(Response response)
+        {
+            return null;
+        }
+
+        public virtual Response processConnectionError(ConnectionError error)
+        {
+            return null;
+        }
+
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/CommandVisitorAdapter.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionState.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionState.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionState.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionState.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,128 @@
+/*
+ * 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.Stomp.Commands;
+using Apache.NMS.Util;
+
+namespace Apache.NMS.Stomp.State
+{
+	public class ConnectionState
+	{
+
+		ConnectionInfo info;
+		private AtomicDictionary<ConsumerId, ConsumerState> consumers =
+            new AtomicDictionary<ConsumerId, ConsumerState>();
+		private Atomic<bool> _shutdown = new Atomic<bool>(false);
+
+		public ConnectionState(ConnectionInfo info)
+		{
+			this.info = info;
+		}
+
+		public override String ToString()
+		{
+			return info.ToString();
+		}
+
+		public void reset(ConnectionInfo info)
+		{
+			this.info = info;
+			_shutdown.Value = false;
+		}
+
+		public ConsumerState this[ConsumerId id]
+		{
+			get
+			{
+				#if DEBUG
+				try
+				{
+				#endif
+					return consumers[id];
+				#if DEBUG
+				}
+				catch(System.Collections.Generic.KeyNotFoundException ex)
+				{
+					// Useful for dignosing missing consumer ids
+					string consumerList = string.Empty;
+					foreach(ConsumerId consumerId in consumers.Keys)
+					{
+						consumerList += consumerId.ToString() + "\n";
+					}
+					System.Diagnostics.Debug.Assert(false,
+						string.Format("Consumer '{0}' did not exist in the consumers collection.\n\nConsumers:-\n{1}",
id, consumerList));
+					throw ex;
+				}
+				#endif
+			}
+		}
+
+		public void addConsumer(ConsumerInfo info)
+		{
+			checkShutdown();
+			consumers.Add(info.ConsumerId, new ConsumerState(info));
+		}
+
+		public ConsumerState removeConsumer(ConsumerId id)
+		{
+			ConsumerState ret = consumers[id];
+			consumers.Remove(id);
+			return ret;
+		}
+
+		public ConnectionInfo Info
+		{
+			get
+			{
+				return info;
+			}
+		}
+
+		public AtomicCollection<ConsumerId> ConsumerIds
+		{
+			get
+			{
+				return consumers.Keys;
+			}
+		}
+
+		public AtomicCollection<ConsumerState> ConsumerStates
+		{
+			get
+			{
+				return consumers.Values;
+			}
+		}
+
+		private void checkShutdown()
+		{
+			if(_shutdown.Value)
+			{
+				throw new ApplicationException("Disposed");
+			}
+		}
+
+		public void shutdown()
+		{
+			if(_shutdown.CompareAndSet(false, true))
+			{
+                this.consumers.Clear();
+			}
+		}
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionState.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionStateTracker.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionStateTracker.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionStateTracker.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionStateTracker.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,163 @@
+/*
+ * 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.Collections.Generic;
+
+using Apache.NMS.Stomp.Commands;
+using Apache.NMS.Stomp.Transport;
+
+namespace Apache.NMS.Stomp.State
+{
+	/// <summary>
+	/// Tracks the state of a connection so a newly established transport can be
+	/// re-initialized to the state that was tracked.
+	/// </summary>
+	public class ConnectionStateTracker : CommandVisitorAdapter
+	{
+
+		private static Tracked TRACKED_RESPONSE_MARKER = new Tracked(null);
+
+		protected Dictionary<ConnectionId, ConnectionState> connectionStates =
+            new Dictionary<ConnectionId, ConnectionState>();
+
+		private bool _restoreConsumers = true;
+
+		/// <summary>
+		/// </summary>
+		/// <param name="command"></param>
+		/// <returns>null if the command is not state tracked.</returns>
+		public Tracked track(Command command)
+		{
+			try
+			{
+				return (Tracked) command.visit(this);
+			}
+			catch(IOException e)
+			{
+				throw e;
+			}
+			catch(Exception e)
+			{
+				throw new IOException(e.Message);
+			}
+		}
+
+		public void trackBack(Command command)
+		{
+		}
+
+		public void DoRestore(ITransport transport)
+		{
+			// Restore the connections.
+			foreach(ConnectionState connectionState in connectionStates.Values)
+			{
+				transport.Oneway(connectionState.Info);
+
+                if(RestoreConsumers)
+                {
+                    DoRestoreConsumers(transport, connectionState);
+                }
+			}
+		}
+
+		/// <summary>
+		/// </summary>
+		/// <param name="transport"></param>
+		/// <param name="connectionState"></param>
+		protected void DoRestoreConsumers(ITransport transport, ConnectionState connectionState)
+		{
+			// Restore the session's consumers
+			foreach(ConsumerState consumerState in connectionState.ConsumerStates)
+			{
+				transport.Oneway(consumerState.Info);
+			}
+		}
+
+		public override Response processAddConsumer(ConsumerInfo info)
+		{
+			if(info != null)
+			{
+				SessionId sessionId = info.ConsumerId.ParentId;
+				if(sessionId != null)
+				{
+					ConnectionId connectionId = sessionId.ParentId;
+					if(connectionId != null)
+					{
+						ConnectionState cs = connectionStates[connectionId];
+						if(cs != null)
+						{
+						    cs.addConsumer(info);
+						}
+					}
+				}
+			}
+			return TRACKED_RESPONSE_MARKER;
+		}
+
+		public override Response processRemoveConsumer(ConsumerId id)
+		{
+			if(id != null)
+			{
+				SessionId sessionId = id.ParentId;
+				if(sessionId != null)
+				{
+					ConnectionId connectionId = sessionId.ParentId;
+					if(connectionId != null)
+					{
+						ConnectionState cs = connectionStates[connectionId];
+						if(cs != null)
+						{
+							cs.removeConsumer(id);
+						}
+					}
+				}
+			}
+			return TRACKED_RESPONSE_MARKER;
+		}
+
+		public override Response processAddConnection(ConnectionInfo info)
+		{
+			if(info != null)
+			{
+				connectionStates.Add(info.ConnectionId, new ConnectionState(info));
+			}
+			return TRACKED_RESPONSE_MARKER;
+		}
+
+		public override Response processRemoveConnection(ConnectionId id)
+		{
+			if(id != null)
+			{
+				connectionStates.Remove(id);
+			}
+			return TRACKED_RESPONSE_MARKER;
+		}
+
+		public bool RestoreConsumers
+		{
+			get
+			{
+				return _restoreConsumers;
+			}
+			set
+			{
+				_restoreConsumers = value;
+			}
+		}
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConnectionStateTracker.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConsumerState.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConsumerState.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConsumerState.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConsumerState.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.Stomp.Commands;
+
+namespace Apache.NMS.Stomp.State
+{
+
+	public class ConsumerState
+	{
+		ConsumerInfo info;
+
+		public ConsumerState(ConsumerInfo info)
+		{
+			this.info = info;
+		}
+
+		public override String ToString()
+		{
+			return info.ToString();
+		}
+
+		public ConsumerInfo Info
+		{
+			get
+			{
+				return info;
+			}
+		}
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ConsumerState.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ICommandVisitor.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ICommandVisitor.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ICommandVisitor.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ICommandVisitor.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,49 @@
+/*
+ * 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 Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp.State
+{
+    public interface ICommandVisitor
+    {
+        Response processAddConnection(ConnectionInfo info);
+
+        Response processAddConsumer(ConsumerInfo info);
+
+        Response processRemoveConnection(ConnectionId id);
+
+        Response processRemoveConsumer(ConsumerId id);
+
+        Response processRemoveSubscriptionInfo(RemoveSubscriptionInfo info);
+
+        Response processMessage(Message send);
+
+        Response processMessageAck(MessageAck ack);
+
+        Response processKeepAliveInfo(KeepAliveInfo info);
+
+        Response processShutdownInfo(ShutdownInfo info);
+
+        Response processMessageDispatch(MessageDispatch dispatch);
+
+        Response processConnectionError(ConnectionError error);
+
+        Response processResponse(Response response);
+    }
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ICommandVisitor.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/SynchronizedObjects.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/SynchronizedObjects.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/SynchronizedObjects.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/SynchronizedObjects.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,219 @@
+/*
+ * 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.Collections;
+using System.Collections.Generic;
+
+namespace Apache.NMS.Stomp.State
+{
+	public class AtomicCollection<TValue>
+		where TValue : class
+	{
+		private ArrayList _collection = new ArrayList();
+
+		public AtomicCollection()
+		{
+		}
+
+		public AtomicCollection(ICollection c)
+		{
+			lock(c.SyncRoot)
+			{
+				foreach(object obj in c)
+				{
+					_collection.Add(obj);
+				}
+			}
+		}
+
+		public int Count
+		{
+			get
+			{
+				lock(_collection.SyncRoot)
+				{
+					return _collection.Count;
+				}
+			}
+		}
+
+		public bool IsReadOnly
+		{
+			get
+			{
+				return false;
+			}
+		}
+
+		public int Add(TValue v)
+		{
+			lock(_collection.SyncRoot)
+			{
+				return _collection.Add(v);
+			}
+		}
+
+		public void Clear()
+		{
+			lock(_collection.SyncRoot)
+			{
+				_collection.Clear();
+			}
+		}
+
+		public bool Contains(TValue v)
+		{
+			lock(_collection.SyncRoot)
+			{
+				return _collection.Contains(v);
+			}
+		}
+
+		public void CopyTo(TValue[] a, int index)
+		{
+			lock(_collection.SyncRoot)
+			{
+				_collection.CopyTo(a, index);
+			}
+		}
+
+		public void Remove(TValue v)
+		{
+			lock(_collection.SyncRoot)
+			{
+				_collection.Remove(v);
+			}
+		}
+
+		public void RemoveAt(int index)
+		{
+			lock(_collection.SyncRoot)
+			{
+				_collection.RemoveAt(index);
+			}
+		}
+
+		public TValue this[int index]
+		{
+			get
+			{
+				TValue ret;
+				lock(_collection.SyncRoot)
+				{
+					ret = (TValue) _collection[index];
+				}
+				return (TValue) ret;
+			}
+			set
+			{
+				lock(_collection.SyncRoot)
+				{
+					_collection[index] = value;
+				}
+			}
+		}
+
+		public IEnumerator GetEnumerator()
+		{
+			lock(_collection.SyncRoot)
+			{
+				return _collection.GetEnumerator();
+			}
+		}
+
+#if !NETCF
+		public IEnumerator GetEnumerator(int index, int count)
+		{
+			lock(_collection.SyncRoot)
+			{
+				return _collection.GetEnumerator(index, count);
+			}
+		}
+#endif
+	}
+
+	public class AtomicDictionary<TKey, TValue>
+		where TKey : class
+		where TValue : class
+	{
+		private Dictionary<TKey, TValue> _dictionary = new Dictionary<TKey, TValue>();
+
+		public void Clear()
+		{
+			_dictionary.Clear();
+		}
+
+		public TValue this[TKey key]
+		{
+			get
+			{
+				TValue ret;
+				lock(((ICollection) _dictionary).SyncRoot)
+				{
+					ret = _dictionary[key];
+				}
+				return ret;
+			}
+			set
+			{
+				lock(((ICollection) _dictionary).SyncRoot)
+				{
+					_dictionary[key] = value;
+				}
+			}
+		}
+
+		public AtomicCollection<TKey> Keys
+		{
+			get
+			{
+				lock(((ICollection) _dictionary).SyncRoot)
+				{
+					return new AtomicCollection<TKey>(_dictionary.Keys);
+				}
+			}
+		}
+
+		public AtomicCollection<TValue> Values
+		{
+			get
+			{
+				lock(((ICollection) _dictionary).SyncRoot)
+				{
+					return new AtomicCollection<TValue>(_dictionary.Values);
+				}
+			}
+		}
+
+		public void Add(TKey k, TValue v)
+		{
+			lock(((ICollection) _dictionary).SyncRoot)
+			{
+				_dictionary.Add(k, v);
+			}
+		}
+
+		public bool Remove(TKey v)
+		{
+			lock(((ICollection) _dictionary).SyncRoot)
+			{
+				return _dictionary.Remove(v);
+			}
+		}
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/SynchronizedObjects.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ThreadSimulator.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ThreadSimulator.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ThreadSimulator.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ThreadSimulator.cs
Tue Jul  6 22:27:14 2010
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+namespace Apache.NMS.Stomp.State
+{
+	public abstract class ThreadSimulator
+	{
+		public virtual void Run()
+		{
+			throw new ApplicationException("ThreadSimulator.Run() should be overridden.");
+		}
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/ThreadSimulator.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/Tracked.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/Tracked.cs?rev=961036&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/Tracked.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/Tracked.cs Tue Jul
 6 22:27:14 2010
@@ -0,0 +1,49 @@
+/*
+ * 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 Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp.State
+{
+	public class Tracked : Response
+	{
+		private ThreadSimulator runnable = null;
+
+		public Tracked(ThreadSimulator runnable)
+		{
+			this.runnable = runnable;
+		}
+
+		public void onResponses()
+		{
+			if(runnable != null)
+			{
+				runnable.Run();
+				runnable = null;
+			}
+		}
+
+		virtual public bool WaitingForResponse
+		{
+			get
+			{
+				return runnable != null;
+			}
+		}
+
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/State/Tracked.cs
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message