Author: arnaudsimon
Date: Fri Sep 26 06:13:40 2008
New Revision: 699304

URL: http://svn.apache.org/viewvc?rev=699304&view=rev
Log:
qpid-1277: simplified message interface 

Added:
    incubator/qpid/trunk/qpid/dotnet/client-010/client/client/IMessage.cs
    incubator/qpid/trunk/qpid/dotnet/client-010/client/client/Message.cs
Modified:
    incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientInterface.cs
    incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSession.cs
    
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSessionDelegate.cs
    
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/MessageListenerInterface.cs
    incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs

Modified: 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientInterface.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientInterface.cs?rev=699304&r1=699303&r2=699304&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientInterface.cs 
(original)
+++ 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientInterface.cs 
Fri Sep 26 06:13:40 2008
@@ -18,7 +18,6 @@
 */
 
 using System;
-using client.client;
 
 namespace org.apache.qpid.client
 {

Modified: 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSession.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSession.cs?rev=699304&r1=699303&r2=699304&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSession.cs 
(original)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSession.cs 
Fri Sep 26 06:13:40 2008
@@ -2,8 +2,10 @@
 
 using System;
 using System.Collections.Generic;
-using client.client;
+using System.IO;
+using System.Text;
 using org.apache.qpid.transport;
+using org.apache.qpid.transport.util;
 
 namespace org.apache.qpid.client
 {
@@ -24,20 +26,34 @@
         public static short MESSAGE_ACQUIRE_ANY_AVAILABLE_MESSAGE = 0;
         public static short MESSAGE_ACQUIRE_MESSAGES_IF_ALL_ARE_AVAILABLE = 1;
 
-        private Dictionary<String, MessageListener> _listeners = new 
Dictionary<String, MessageListener>();
+        private Dictionary<String, IMessageListener> _listeners = new 
Dictionary<String, IMessageListener>();
 
         public ClientSession(byte[] name) : base(name)
         {
         }
 
-        public void attachMessageListener(MessageListener listener, string 
Destination)
+        public void attachMessageListener(IMessageListener listener, string 
Destination)
         {
             _listeners.Add(Destination, listener);
         }
 
-        public Dictionary<String, MessageListener> MessageListeners
+        public Dictionary<String, IMessageListener> MessageListeners
         {
             get { return _listeners; }
         }
+
+        public void messageTransfer(String destination, string routingkey, 
IMessage message)
+        {
+            byte[] body = new byte[message.Body.Position];
+            message.Body.Seek(0, SeekOrigin.Begin);
+            message.Body.Read(body, 0, body.Length);
+            message.MessageProperties.setMessageId(UUID.randomUUID());
+            message.DeliveryProperties.setRoutingKey(routingkey);
+            messageTransfer(destination,
+                            MessageAcceptMode.NONE,
+                            MessageAcquireMode.PRE_ACQUIRED,
+                            message.Header,
+                            body);             
+        }
     }
 }
\ No newline at end of file

Modified: 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSessionDelegate.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSessionDelegate.cs?rev=699304&r1=699303&r2=699304&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSessionDelegate.cs
 (original)
+++ 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/ClientSessionDelegate.cs
 Fri Sep 26 06:13:40 2008
@@ -16,8 +16,6 @@
 * specific language governing permissions and limitations
 * under the License.
 */
-using System;
-using client.client;
 using org.apache.qpid.transport;
 using org.apache.qpid.transport.util;
 
@@ -34,8 +32,8 @@
         {
             if (((ClientSession) 
session).MessageListeners.ContainsKey(xfr.getDestination()))
             {
-                MessageListener listener = ((ClientSession) 
session).MessageListeners[xfr.getDestination()];
-                listener.messageTransfer(xfr);
+                IMessageListener listener = 
((ClientSession)session).MessageListeners[xfr.getDestination()];
+                listener.messageTransfer( new Message(xfr));
             }
             else
             {

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/client/IMessage.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/client/IMessage.cs?rev=699304&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/client/IMessage.cs 
(added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/client/IMessage.cs Fri 
Sep 26 06:13:40 2008
@@ -0,0 +1,46 @@
+/*
+*
+* 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 System.IO;
+using org.apache.qpid.transport;
+
+namespace org.apache.qpid.client
+{
+    public interface IMessage
+    {
+        int Id { get; }
+
+        Header Header { get; set; }
+
+        MessageProperties MessageProperties { get; set; }
+
+        DeliveryProperties DeliveryProperties { get; set; }
+
+        Dictionary<String, Object> ApplicationHeaders { get; set; }
+
+        void appendData(byte[] bytes);
+
+        MemoryStream Body { get; }
+
+        void clearData();
+    }
+}

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/client/Message.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/client/Message.cs?rev=699304&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/client/Message.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/client/Message.cs Fri 
Sep 26 06:13:40 2008
@@ -0,0 +1,121 @@
+/*
+*
+* 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.Collections.Generic;
+using System.IO;
+using org.apache.qpid.transport;
+
+namespace org.apache.qpid.client
+{
+    public class Message : IMessage
+    {
+        private readonly MessageTransfer _message;
+
+        public Message(MessageTransfer m)
+        {
+            _message = m;    
+        }
+
+        public Message()
+        {
+            _message = new MessageTransfer();
+            _message.Header = new Header( new MessageProperties(), new 
DeliveryProperties());
+            ((MessageProperties) 
_message.Header.Structs[0]).setApplicationHeaders(new Dictionary<string, 
object>());
+        }
+
+        public MessageProperties MessageProperties
+        {
+            get
+            {
+                if (_message.Header != null)
+                    return (MessageProperties) Header.Structs[0];
+                return null;
+            }
+            set
+            {
+                if (_message.Header != null)
+                {
+                    Header.Structs[0] = value;
+                }
+            }
+        }
+
+        public DeliveryProperties DeliveryProperties
+        {
+            get
+            {
+                if (Header != null)
+                    return (DeliveryProperties) Header.Structs[1];
+                return null;
+            }
+            set
+            {
+                if (Header != null)
+                {
+                    Header.Structs[1] = value;
+                }
+            }
+        }
+
+        public Dictionary<string, object> ApplicationHeaders
+        {
+            get
+            {
+                if (Header != null)
+                    return ((MessageProperties) 
Header.Structs[0]).getApplicationHeaders();
+                return null;
+            }
+            set
+            {
+                if (Header != null)
+                {
+                    ((MessageProperties) 
Header.Structs[0]).setApplicationHeaders(value);
+                }
+            }
+        }
+
+        public void appendData(byte[] bytes)
+        {
+            Body.Write(bytes, 0, bytes.Length);
+        }
+
+        public void clearData()
+        {
+            Body.Seek(0, SeekOrigin.Begin);
+        }
+
+        public Header Header
+        {
+            get{ return _message.Header;}
+            set{ _message.Header = value;}
+        }
+
+        public MemoryStream Body
+        {
+            get { return _message.Body; }
+            set { _message.Body = value; }
+        }
+
+        public int Id
+        {
+            get { return _message.Id; }
+        }
+    }
+}

Modified: 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/MessageListenerInterface.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/client/MessageListenerInterface.cs?rev=699304&r1=699303&r2=699304&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/MessageListenerInterface.cs
 (original)
+++ 
incubator/qpid/trunk/qpid/dotnet/client-010/client/client/MessageListenerInterface.cs
 Fri Sep 26 06:13:40 2008
@@ -16,16 +16,16 @@
 * specific language governing permissions and limitations
 * under the License.
 */
-using org.apache.qpid.transport;
 
-namespace client.client
+
+namespace org.apache.qpid.client
 {
-    public interface MessageListener
+    public interface IMessageListener
     {
         /// <summary>
         /// Inform the listener of the message transfer
         /// </summary>
         /// <param name="xfr">The message transfer object</param>
-        void messageTransfer(MessageTransfer xfr);
+        void messageTransfer(IMessage xfr);
     }
 }

Modified: 
incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs?rev=699304&r1=699303&r2=699304&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs 
(original)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs Fri 
Sep 26 06:13:40 2008
@@ -22,8 +22,6 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Threading;
-using common.org.apache.qpid.transport.util;
-using org.apache.qpid.transport;
 using org.apache.qpid.transport.util;
 using Frame = org.apache.qpid.transport.network.Frame;
 using Logger = org.apache.qpid.transport.util.Logger;


Reply via email to