activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r989335 - in /activemq/activemq-dotnet: Apache.NMS.ActiveMQ/trunk/src/main/csharp/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/ Apache.NMS.ActiveMQ/trunk/src/test/csharp/Util/ Apache.NM...
Date Wed, 25 Aug 2010 20:12:32 GMT
Author: tabish
Date: Wed Aug 25 20:12:31 2010
New Revision: 989335

URL: http://svn.apache.org/viewvc?rev=989335&view=rev
Log:
initial fix for: https://issues.apache.org/activemq/browse/AMQNET-276

Adds MessageTransformation abstract class to NMS util and implements for Stomp and ActiveMQ
clients.


Added:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/ActiveMQMessageTransformation.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Util/ActiveMQMessageTransformationTest.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/StompMessageTransformation.cs
  (with props)
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/MessageTransformation.cs
  (with props)
Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IObjectMessage.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Commands/ActiveMQMessage.cs
Wed Aug 25 20:12:31 2010
@@ -182,6 +182,7 @@ namespace Apache.NMS.ActiveMQ.Commands
 		public IDestination NMSDestination
 		{
 			get { return Destination; }
+            set { Destination = value as ActiveMQDestination; }
 		}
 
 		private TimeSpan timeToLive = TimeSpan.FromMilliseconds(0);
@@ -277,6 +278,24 @@ namespace Apache.NMS.ActiveMQ.Commands
 		public bool NMSRedelivered
 		{
 			get { return (RedeliveryCounter > 0); }
+
+            set
+            {
+                if(value == true)
+                {
+                    if(this.RedeliveryCounter <= 0)
+                    {
+                        this.RedeliveryCounter = 1;
+                    }
+                }
+                else
+                {
+                    if(this.RedeliveryCounter > 0)
+                    {
+                        this.RedeliveryCounter = 0;
+                    }
+                }
+            }
 		}
 
 		/// <summary>

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=989335&r1=989334&r2=989335&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 Aug
25 20:12:31 2010
@@ -71,6 +71,7 @@ namespace Apache.NMS.ActiveMQ
         private ICompressionPolicy compressionPolicy = new CompressionPolicy();
         private IdGenerator clientIdGenerator;
         private volatile CountDownLatch transportInterruptionProcessingComplete;
+        private MessageTransformation messageTransformation = null;
 
         public Connection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator)
         {
@@ -89,6 +90,8 @@ namespace Apache.NMS.ActiveMQ
             this.info = new ConnectionInfo();
             this.info.ConnectionId = id;
             this.info.FaultTolerant = transport.IsFaultTolerant;
+
+            this.messageTransformation = new ActiveMQMessageTransformation(this);
         }
 
         ~Connection()
@@ -351,6 +354,11 @@ namespace Apache.NMS.ActiveMQ
             set { this.compressionPolicy = value; }
         }
 
+        internal MessageTransformation MessageTransformation
+        {
+            get { return this.messageTransformation; }
+        }
+
         #endregion
 
         /// <summary>

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageProducer.cs
Wed Aug 25 20:12:31 2010
@@ -43,6 +43,8 @@ namespace Apache.NMS.ActiveMQ
         private bool disableMessageTimestamp = false;
         protected bool disposed = false;
 
+        private MessageTransformation messageTransformation;
+
         public MessageProducer(Session session, ProducerId id, ActiveMQDestination destination,
TimeSpan requestTimeout)
         {
             this.session = session;            
@@ -52,6 +54,8 @@ namespace Apache.NMS.ActiveMQ
             this.info.ProducerId = id;
             this.info.Destination = destination;
             this.info.WindowSize = session.Connection.ProducerWindowSize;
+
+            this.messageTransformation = session.Connection.MessageTransformation;
             
             // If the destination contained a URI query, then use it to set public
             // properties on the ProducerInfo
@@ -198,7 +202,7 @@ namespace Apache.NMS.ActiveMQ
                 throw new NotSupportedException("This producer can only send messages to:
" + this.info.Destination.PhysicalName);
             }
 
-            ActiveMQMessage activeMessage = (ActiveMQMessage) message;
+            ActiveMQMessage activeMessage = this.messageTransformation.TransformMessage<ActiveMQMessage>(message);
 
             activeMessage.ProducerId = info.ProducerId;
             activeMessage.Destination = dest;

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/ActiveMQMessageTransformation.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/ActiveMQMessageTransformation.cs?rev=989335&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/ActiveMQMessageTransformation.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Util/ActiveMQMessageTransformation.cs
Wed Aug 25 20:12:31 2010
@@ -0,0 +1,89 @@
+/*
+ * 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 Apache.NMS.ActiveMQ.Commands;
+
+namespace Apache.NMS.ActiveMQ.Util
+{
+    public class ActiveMQMessageTransformation : MessageTransformation
+    {
+        private Connection connection;
+
+        public ActiveMQMessageTransformation(Connection connection) : base()
+        {
+            this.connection = connection;
+        }
+
+        #region Creation Methods and Conversion Support Methods
+
+        protected override IMessage DoCreateMessage()
+        {
+            ActiveMQMessage message = new ActiveMQMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IBytesMessage DoCreateBytesMessage()
+        {
+            ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override ITextMessage DoCreateTextMessage()
+        {
+            ActiveMQTextMessage message = new ActiveMQTextMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IStreamMessage DoCreateStreamMessage()
+        {
+            ActiveMQStreamMessage message = new ActiveMQStreamMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IMapMessage DoCreateMapMessage()
+        {
+            ActiveMQMapMessage message = new ActiveMQMapMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IObjectMessage DoCreateObjectMessage()
+        {
+            ActiveMQObjectMessage message = new ActiveMQObjectMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IDestination DoTransformDestination(IDestination destination)
+        {
+            return ActiveMQDestination.Transform(destination);
+        }
+
+        protected override void DoPostProcessMessage(IMessage message)
+        {
+        }
+
+        #endregion
+    }
+}
+

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

Added: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Util/ActiveMQMessageTransformationTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Util/ActiveMQMessageTransformationTest.cs?rev=989335&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Util/ActiveMQMessageTransformationTest.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Util/ActiveMQMessageTransformationTest.cs
Wed Aug 25 20:12:31 2010
@@ -0,0 +1,88 @@
+/*
+ * 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 Apache.NMS.ActiveMQ.Util;
+using Apache.NMS.ActiveMQ.Commands;
+
+using NUnit.Framework;
+
+namespace Apache.NMS.ActiveMQ.Test
+{
+    [TestFixture]
+    public class ActiveMQMessageTransformationTest
+    {
+        MessageTransformation transformer;
+
+        [SetUp]
+        public void SetUp()
+        {
+            this.transformer = new ActiveMQMessageTransformation(null);
+        }
+
+        [Test]
+        public void TestMessageTransformation()
+        {
+            ActiveMQMessage message = new ActiveMQMessage();
+
+            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
+        }
+
+        [Test]
+        public void TestTextMessageTransformation()
+        {
+            ActiveMQTextMessage message = new ActiveMQTextMessage();
+
+            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
+        }
+
+        [Test]
+        public void TestBytesMessageTransformation()
+        {
+            ActiveMQBytesMessage message = new ActiveMQBytesMessage();
+
+            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
+        }
+
+        [Test]
+        public void TestStreamMessageTransformation()
+        {
+            ActiveMQStreamMessage message = new ActiveMQStreamMessage();
+
+            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
+        }
+
+        [Test]
+        public void TestObjectMessageTransformation()
+        {
+            ActiveMQObjectMessage message = new ActiveMQObjectMessage();
+
+            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
+        }
+
+        [Test]
+        public void TestMapMessageTransformation()
+        {
+            ActiveMQMapMessage message = new ActiveMQMapMessage();
+
+            Assert.AreSame(message, transformer.TransformMessage<ActiveMQMessage>(message));
+        }
+    }
+}
+

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

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs Wed
Aug 25 20:12:31 2010
@@ -176,6 +176,7 @@ namespace Apache.NMS.Stomp.Commands
         public IDestination NMSDestination
         {
             get { return Destination; }
+            set { this.Destination = value as Destination; }
         }
 
         private TimeSpan timeToLive = TimeSpan.FromMilliseconds(0);
@@ -286,6 +287,24 @@ namespace Apache.NMS.Stomp.Commands
         public bool NMSRedelivered
         {
             get { return (RedeliveryCounter > 0); }
+
+            set
+            {
+                if(value == true)
+                {
+                    if(this.RedeliveryCounter <= 0)
+                    {
+                        this.RedeliveryCounter = 1;
+                    }
+                }
+                else
+                {
+                    if(this.RedeliveryCounter > 0)
+                    {
+                        this.RedeliveryCounter = 0;
+                    }
+                }
+            }
         }
 
         /// <summary>

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Connection.cs Wed Aug
25 20:12:31 2010
@@ -64,6 +64,7 @@ namespace Apache.NMS.Stomp
         private bool disposed = false;
         private IdGenerator clientIdGenerator;
         private CountDownLatch transportInterruptionProcessingComplete;
+        private MessageTransformation messageTransformation;
 
         public Connection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator)
         {
@@ -81,6 +82,8 @@ namespace Apache.NMS.Stomp
 
             this.info = new ConnectionInfo();
             this.info.ConnectionId = id;
+
+            this.messageTransformation = new StompMessageTransformation(this);
         }
 
         ~Connection()
@@ -272,6 +275,11 @@ namespace Apache.NMS.Stomp
             set { this.prefetchPolicy = value; }
         }
 
+        internal MessageTransformation MessageTransformation
+        {
+            get { return this.messageTransformation; }
+        }
+
         #endregion
 
         /// <summary>

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/MessageProducer.cs Wed
Aug 25 20:12:31 2010
@@ -42,11 +42,14 @@ namespace Apache.NMS.Stomp
         private bool disableMessageTimestamp = false;
         protected bool disposed = false;
 
+        private MessageTransformation messageTransformation;
+
         public MessageProducer(Session session, ProducerInfo info)
         {
             this.session = session;
             this.info = info;
             this.RequestTimeout = session.RequestTimeout;
+            this.messageTransformation = session.Connection.MessageTransformation;
         }
 
         ~MessageProducer()
@@ -165,7 +168,7 @@ namespace Apache.NMS.Stomp
                 throw new NotSupportedException("This producer can only send messages to:
" + this.info.Destination.PhysicalName);
             }
 
-            Message stompMessage = (Message) message;
+            Message stompMessage = this.messageTransformation.TransformMessage<Message>(message);
 
             stompMessage.ProducerId = info.ProducerId;
             stompMessage.FromDestination = dest;

Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/StompMessageTransformation.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/StompMessageTransformation.cs?rev=989335&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/StompMessageTransformation.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/StompMessageTransformation.cs
Wed Aug 25 20:12:31 2010
@@ -0,0 +1,87 @@
+// /*
+//  * 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 Apache.NMS.Stomp.Commands;
+
+namespace Apache.NMS.Stomp
+{
+    public class StompMessageTransformation : MessageTransformation
+    {
+        private Connection connection;
+
+        public StompMessageTransformation(Connection connection) : base()
+        {
+            this.connection = connection;
+        }
+
+        #region Creation Methods and Conversion Support Methods
+
+        protected override IMessage DoCreateMessage()
+        {
+            Message message = new Message();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IBytesMessage DoCreateBytesMessage()
+        {
+            BytesMessage message = new BytesMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override ITextMessage DoCreateTextMessage()
+        {
+            TextMessage message = new TextMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IStreamMessage DoCreateStreamMessage()
+        {
+            StreamMessage message = new StreamMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IMapMessage DoCreateMapMessage()
+        {
+            MapMessage message = new MapMessage();
+            message.Connection = this.connection;
+            return message;
+        }
+
+        protected override IObjectMessage DoCreateObjectMessage()
+        {
+            throw new NotSupportedException("Stomp Cannot process Object Messages");
+        }
+
+        protected override IDestination DoTransformDestination(IDestination destination)
+        {
+            return Destination.Transform(destination);
+        }
+
+        protected override void DoPostProcessMessage(IMessage message)
+        {
+        }
+
+        #endregion
+    }
+}
+

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

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj Wed Aug 25 20:12:31
2010
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="3.5">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -55,27 +55,15 @@
     <NoWarn>3016</NoWarn>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Apache.NMS.Test, Version=1.4.0.2021, Culture=neutral, PublicKeyToken=82756feee3957618,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.Test.dll</HintPath>
-    </Reference>
-    <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77,
processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\NUnit\net-2.0\nunit.framework.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
-    <Reference Include="Apache.NMS, Version=1.4.0.2013, Culture=neutral, PublicKeyToken=82756feee3957618">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath>
-    </Reference>
-    <Reference Include="Apache.NMS.Stomp, Version=1.4.0.2015, Culture=neutral, PublicKeyToken=82756feee3957618">
+    <Reference Include="Apache.NMS.Test, Version=1.4.0.2025, Culture=neutral, PublicKeyToken=82756feee3957618">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>build\mono-2.0\debug\Apache.NMS.Stomp.dll</HintPath>
+      <HintPath>lib\Apache.NMS\mono-2.0\Apache.NMS.Test.dll</HintPath>
     </Reference>
-    <Reference Include="nunit.framework.extensions, Version=2.4.8.0, Culture=neutral,
PublicKeyToken=96d09a1eb7f44a77">
+    <Reference Include="nunit.framework, Version=2.5.5.10112, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\NUnit\mono-2.0\nunit.framework.extensions.dll</HintPath>
+      <HintPath>lib\NUnit\mono-2.0\nunit.framework.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj Wed Aug 25 20:12:31
2010
@@ -55,7 +55,7 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
-    <Reference Include="Apache.NMS, Version=1.4.0.2021, Culture=neutral, PublicKeyToken=82756feee3957618">
+    <Reference Include="Apache.NMS, Version=1.4.0.2049, Culture=neutral, PublicKeyToken=82756feee3957618">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>lib\Apache.NMS\mono-2.0\Apache.NMS.dll</HintPath>
     </Reference>
@@ -161,6 +161,7 @@
     <Compile Include="src\main\csharp\State\SynchronizedObjects.cs" />
     <Compile Include="src\main\csharp\IOException.cs" />
     <Compile Include="src\main\csharp\Util\ThreadUtil.cs" />
+    <Compile Include="src\main\csharp\Util\StompMessageTransformation.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="keyfile\NMSKey.snk" />

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IMessage.cs Wed Aug 25 20:12:31
2010
@@ -58,7 +58,7 @@ namespace Apache.NMS
 		/// <summary>
 		/// The destination of the message.  This property is set by the IMessageProducer.
 		/// </summary>
-		IDestination NMSDestination { get; }
+		IDestination NMSDestination { get; set; }
 
 		/// <summary>
 		/// The amount of time for which this message is valid.  Zero if this message does not
expire.
@@ -68,7 +68,7 @@ namespace Apache.NMS
 		/// <summary>
 		/// The message ID which is set by the provider.
 		/// </summary>
-		string NMSMessageId { get; }
+		string NMSMessageId { get; set; }
 
 		/// <summary>
 		/// Whether or not this message is persistent.
@@ -83,7 +83,7 @@ namespace Apache.NMS
 		/// <summary>
 		/// Returns true if this message has been redelivered to this or another consumer before
being acknowledged successfully.
 		/// </summary>
-		bool NMSRedelivered { get; }
+		bool NMSRedelivered { get; set; }
 
 		/// <summary>
 		/// The destination that the consumer of this message should send replies to
@@ -94,7 +94,7 @@ namespace Apache.NMS
 		/// The timestamp of when the message was pubished in UTC time.  If the publisher disables
setting
 		/// the timestamp on the message, the time will be set to the start of the UNIX epoc (1970-01-01
00:00:00).
 		/// </summary>
-		DateTime NMSTimestamp { get; }
+		DateTime NMSTimestamp { get; set; }
 
 		/// <summary>
 		/// The type name of this message.

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IObjectMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IObjectMessage.cs?rev=989335&r1=989334&r2=989335&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IObjectMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/IObjectMessage.cs Wed Aug 25
20:12:31 2010
@@ -21,6 +21,6 @@ namespace Apache.NMS
 	/// </summary>
 	public interface IObjectMessage : IMessage
 	{
-		object Body { get; }
+		object Body { get; set; }
 	}
 }

Added: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/MessageTransformation.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/MessageTransformation.cs?rev=989335&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/MessageTransformation.cs
(added)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/MessageTransformation.cs
Wed Aug 25 20:12:31 2010
@@ -0,0 +1,168 @@
+/*
+ * 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.Util
+{
+    /// <summary>
+    /// Base Utility class for conversion between IMessage type objects for different
+    /// NMS providers.
+    /// </summary>
+	public abstract class MessageTransformation
+	{
+		public MessageTransformation()
+		{
+		}
+
+        public T TransformMessage<T>(IMessage message)
+        {
+            if(message is T)
+            {
+                return (T) message;
+            }
+            else
+            {
+                IMessage result = null;
+    
+                if(message is IBytesMessage)
+                {
+                    IBytesMessage bytesMsg = message as IBytesMessage;
+                    bytesMsg.Reset();
+                    IBytesMessage msg = DoCreateBytesMessage();
+
+                    try
+                    {
+                        for(;;)
+                        {
+                            // Reads a byte from the message stream until the stream is empty
+                            msg.WriteByte(bytesMsg.ReadByte());
+                        }
+                    }
+                    catch
+                    {
+                    }
+
+                    result = msg;
+                }
+                else if(message is IMapMessage)
+                {
+                    IMapMessage mapMsg = message as IMapMessage;
+                    IMapMessage msg = DoCreateMapMessage();
+
+                    foreach(string key in mapMsg.Body.Keys)
+                    {
+                        msg.Body[key] = mapMsg.Body[key];
+                    }
+
+                    result = msg;
+                }
+                else if(message is IObjectMessage)
+                {
+                    IObjectMessage objMsg = message as IObjectMessage;
+                    IObjectMessage msg = DoCreateObjectMessage();
+                    msg.Body = objMsg.Body;
+
+                    result = msg;
+                }
+                else if(message is IStreamMessage)
+                {
+                    IStreamMessage streamMessage = message as IStreamMessage;
+                    streamMessage.Reset();
+                    IStreamMessage msg = DoCreateStreamMessage();
+
+                    object obj = null;
+
+                    try
+                    {
+                        while((obj = streamMessage.ReadObject()) != null)
+                        {
+                            msg.WriteObject(obj);
+                        }
+                    }
+                    catch
+                    {
+                    }
+
+                    result = msg;
+                }
+                else if(message is ITextMessage)
+                {
+                    ITextMessage textMsg = message as ITextMessage;
+                    ITextMessage msg = DoCreateTextMessage();
+                    msg.Text = textMsg.Text;
+                    result = msg;
+                }
+                else
+                {
+                    result = DoCreateMessage();
+                }
+
+                CopyProperties(message, result);
+
+                // Let the subclass have a chance to do any last minute configurations
+                // on the newly converted message.
+                DoPostProcessMessage(result);
+
+                return (T) result;
+            }
+        }
+
+        /**
+         * Copies the standard JMS and user defined properties from the givem
+         * message to the specified message
+         *
+         * @param fromMessage the message to take the properties from
+         * @param toMessage the message to add the properties to
+         * @throws JMSException
+         */
+        public virtual void CopyProperties(IMessage fromMessage, IMessage toMessage)
+        {
+            toMessage.NMSMessageId = fromMessage.NMSMessageId;
+            toMessage.NMSCorrelationID = fromMessage.NMSCorrelationID;
+            toMessage.NMSReplyTo = DoTransformDestination(fromMessage.NMSReplyTo);
+            toMessage.NMSDestination = DoTransformDestination(fromMessage.NMSDestination);
+            toMessage.NMSDeliveryMode = fromMessage.NMSDeliveryMode;
+            toMessage.NMSRedelivered = fromMessage.NMSRedelivered;
+            toMessage.NMSType = fromMessage.NMSType;
+            toMessage.NMSPriority = fromMessage.NMSPriority;
+            toMessage.NMSTimestamp = fromMessage.NMSTimestamp;
+            toMessage.NMSTimeToLive = fromMessage.NMSTimeToLive;
+
+            foreach(string key in fromMessage.Properties.Keys)
+            {
+                toMessage.Properties[key] = fromMessage.Properties[key];
+            }
+        }
+
+        #region Creation Methods and Conversion Support Methods
+
+        protected abstract IMessage DoCreateMessage();
+        protected abstract IBytesMessage DoCreateBytesMessage();
+        protected abstract ITextMessage DoCreateTextMessage();
+        protected abstract IStreamMessage DoCreateStreamMessage();
+        protected abstract IMapMessage DoCreateMapMessage();
+        protected abstract IObjectMessage DoCreateObjectMessage();
+
+        protected abstract IDestination DoTransformDestination(IDestination destination);
+        protected abstract void DoPostProcessMessage(IMessage message);
+
+        #endregion
+
+	}
+}
+

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



Mime
View raw message