summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-05-28 18:09:10 +0000
committerTed Ross <tross@apache.org>2010-05-28 18:09:10 +0000
commit947b1491d7a39c87c4560126a6e50646aa2a2b24 (patch)
tree19a5c7ac347d807125f8352ef5f2d41810d79281 /cpp
parent8d317104053b8258380c47af8d792517c4da10b7 (diff)
downloadqpid-python-947b1491d7a39c87c4560126a6e50646aa2a2b24.tar.gz
QPID-2628 - Patch from Chuck Rolke
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@949245 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/bindings/qpid/dotnet/ReadMe.txt33
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs19
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.csproj12
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs15
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.csproj12
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/Properties/AssemblyInfo.cs54
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs280
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj69
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/Properties/AssemblyInfo.cs54
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs146
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.csproj66
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj16
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs4
-rw-r--r--cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj12
-rw-r--r--cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln44
-rw-r--r--cpp/bindings/qpid/dotnet/src/Address.cpp186
-rw-r--r--cpp/bindings/qpid/dotnet/src/Address.h89
-rw-r--r--cpp/bindings/qpid/dotnet/src/Connection.cpp194
-rw-r--r--cpp/bindings/qpid/dotnet/src/Connection.h21
-rw-r--r--cpp/bindings/qpid/dotnet/src/Duration.h65
-rw-r--r--cpp/bindings/qpid/dotnet/src/Message.cpp515
-rw-r--r--cpp/bindings/qpid/dotnet/src/Message.h82
-rw-r--r--cpp/bindings/qpid/dotnet/src/QpidException.h (renamed from cpp/bindings/qpid/dotnet/src/resource.h)22
-rw-r--r--cpp/bindings/qpid/dotnet/src/QpidMarshal.h1
-rw-r--r--cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h75
-rw-r--r--cpp/bindings/qpid/dotnet/src/Receiver.cpp145
-rw-r--r--cpp/bindings/qpid/dotnet/src/Receiver.h20
-rw-r--r--cpp/bindings/qpid/dotnet/src/Sender.cpp29
-rw-r--r--cpp/bindings/qpid/dotnet/src/Sender.h33
-rw-r--r--cpp/bindings/qpid/dotnet/src/Session.cpp305
-rw-r--r--cpp/bindings/qpid/dotnet/src/Session.h47
-rw-r--r--cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp411
-rw-r--r--cpp/bindings/qpid/dotnet/src/TypeTranslator.h70
-rw-r--r--cpp/bindings/qpid/dotnet/src/app.rc1
-rw-r--r--cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc101
-rw-r--r--cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj34
-rw-r--r--cpp/bindings/qpid/dotnet/src/qpid.snkbin0 -> 596 bytes
-rw-r--r--cpp/bindings/qpid/dotnet/src/resource1.h14
-rw-r--r--cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs55
-rw-r--r--cpp/bindings/qpid/dotnet/src/sessionreceiver/org.apache.qpid.messaging.sessionreceiver.csproj65
-rw-r--r--cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs133
-rw-r--r--cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs62
-rw-r--r--cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.csproj18
43 files changed, 2978 insertions, 651 deletions
diff --git a/cpp/bindings/qpid/dotnet/ReadMe.txt b/cpp/bindings/qpid/dotnet/ReadMe.txt
index 66ac7ae50e..faa1b79d4b 100644
--- a/cpp/bindings/qpid/dotnet/ReadMe.txt
+++ b/cpp/bindings/qpid/dotnet/ReadMe.txt
@@ -3,31 +3,46 @@ Qpid.cpp.bindings.qpid.dotnet binding package.
1. Features
===========
-This binding package is a .NET Interop wrapper around the Qpid Messaging interface.
-It exposes the Messaging interface through a series of managed code classes that
-may be used by any .NET language.
+A. This binding package provides a .NET Interop wrapper around the C++
+ Qpid Messaging interface. It exposes the Messaging interface through
+ a series of managed code classes that may be used by any .NET language.
+
+B. A sessionreceiver assembly provides session callback functionality
+ above the C++ layer.
2. Prerequisites
================
-1. A build of the Qpid C++ libraries is available.
+A. A build of the Qpid C++ libraries is available.
-2. Refer to this library using environment variable QPID_BUILD_ROOT.
+B. Refer to this library using environment variable QPID_BUILD_ROOT.
for example: SET QPID_BUILD_ROOT=D:\users\submitter\svn\qpid\cpp
3. Building the solution
========================
-1. Build the solution.
+A. The solution is cpp\bindings\qpid\dotnet\org.apache.qpid.messaging.sln
+
+B. Build the solution (Debug only - Release is not set up yet).
-4. Runing the examples
+C. Project output goes to %QPID_BUILD_ROOT%\src\Debug. This puts all the
+ solution artifacts is the same directory as the C++ DLLs.
+
+
+4. Running the examples
======================
-CWIP
+A. csharp.direct.receiver
+B. csharp.direct.sender
+C. csharp.map.receiver
+D. csharp.map.sender
+E. csharp.map.callback.receiver
+F. csharp.map.callback.sender
+
5. Running the tests
====================
-CWIP
+A. messaging.test
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
index 6cc2a5e0a5..4888023830 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs
@@ -37,7 +37,20 @@ namespace CSharpDirect
{
String host = "localhost:5672";
String addr = "amq.direct/key";
- int nMsg = 10;
+ Int32 nMsg = 10;
+
+ if (args.Length > 0)
+ host = args[0];
+ if (args.Length > 1)
+ addr = args[1];
+ if (args.Length > 2)
+ nMsg = Convert.ToInt32(args[2]);
+
+ Console.WriteLine("csharp.direct.receiver");
+ Console.WriteLine("host : {0}", host);
+ Console.WriteLine("addr : {0}", addr);
+ Console.WriteLine("nMsg : {0}", nMsg);
+ Console.WriteLine();
Connection conn = new Connection(host);
@@ -52,7 +65,7 @@ namespace CSharpDirect
Session sess = conn.createSession();
- Duration dur = new Duration(1000 * 3600 * 24); // Wait one day
+ Duration dura = new Duration(3600000); // wait forever
Receiver rcv = sess.createReceiver(addr);
@@ -62,7 +75,7 @@ namespace CSharpDirect
{
try
{
- Message msg2 = rcv.fetch(dur);
+ Message msg2 = rcv.fetch(dura);
Console.WriteLine("Rcvd msg {0} : {1}", i, msg2.getContent());
}
catch (Exception e)
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.csproj
index 8cb4826a01..7bfcfb8331 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.csproj
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.csproj
@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -31,10 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="org.apache.qpid.messagingd, Version=1.0.3779.23054, Culture=neutral, PublicKeyToken=679e1f50b62dbace, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\bin\Debug\org.apache.qpid.messagingd.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -52,6 +48,12 @@
<Compile Include="csharp.direct.receiver.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs
index bf49787f9b..1fe56aa8a9 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs
@@ -33,7 +33,20 @@ namespace csharp.direct.sender
{
String host = "localhost:5672";
String addr = "amq.direct/key";
- int nMsg = 10;
+ Int32 nMsg = 10;
+
+ if (args.Length > 0)
+ host = args[0];
+ if (args.Length > 1)
+ addr = args[1];
+ if (args.Length > 2)
+ nMsg = Convert.ToInt32(args[2]);
+
+ Console.WriteLine("csharp.direct.sender");
+ Console.WriteLine("host : {0}", host);
+ Console.WriteLine("addr : {0}", addr);
+ Console.WriteLine("nMsg : {0}", nMsg);
+ Console.WriteLine();
Connection conn = new Connection(host);
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.csproj
index f109d64b80..7ff92e163b 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.csproj
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.csproj
@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -31,10 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="org.apache.qpid.messagingd, Version=1.0.3779.23054, Culture=neutral, PublicKeyToken=679e1f50b62dbace, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\bin\Debug\org.apache.qpid.messagingd.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -52,6 +48,12 @@
<Compile Include="csharp.direct.sender.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/Properties/AssemblyInfo.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..8e2add189d
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/Properties/AssemblyInfo.cs
@@ -0,0 +1,54 @@
+/*
+* 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("csharp.map.receiver")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("csharp.map.receiver")]
+[assembly: AssemblyCopyright("Copyright © 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("002049f9-41c5-420f-9ff6-45bb652dded6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs
new file mode 100644
index 0000000000..e7294c6e1a
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs
@@ -0,0 +1,280 @@
+/*
+ *
+ * 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 org.apache.qpid.messaging;
+using org.apache.qpid.messaging.sessionreceiver;
+
+namespace org.apache.qpid.messaging.examples
+{
+ /// <summary>
+ /// A class with functions to display structured messages.
+ /// </summary>
+ public static class MessageViewer
+ {
+ /// <summary>
+ /// A Function to display a amqp/map message packaged as a Dictionary.
+ /// </summary>
+ /// <param name="dict">The AMQP map</param>
+ /// <param name="level">Nested depth</param>
+ public static void ShowDictionary(Dictionary<string, object> dict, int level)
+ {
+ foreach (KeyValuePair<string, object> kvp in dict)
+ {
+ Console.Write(new string(' ', level * 4));
+
+ if (QpidTypeCheck.ObjectIsMap(kvp.Value))
+ {
+ Console.WriteLine("Key: {0}, Value: Dictionary", kvp.Key);
+ ShowDictionary((Dictionary<string, object>)kvp.Value, level + 1);
+ }
+ else if (QpidTypeCheck.ObjectIsList(kvp.Value))
+ {
+ Console.WriteLine("Key: {0}, Value: List", kvp.Key);
+ ShowList((List<object>)kvp.Value, level + 1);
+ }
+ else
+ Console.WriteLine("Key: {0}, Value: {1}, Type: {2}",
+ kvp.Key, kvp.Value, kvp.Value.GetType().ToString());
+ }
+ }
+
+ /// <summary>
+ /// A function to display a ampq/list message packaged as a List.
+ /// </summary>
+ /// <param name="list">The AMQP list</param>
+ /// <param name="level">Nested depth</param>
+ public static void ShowList(List<object> list, int level)
+ {
+ foreach (object obj in list)
+ {
+ Console.Write(new string(' ', level * 4));
+
+ if (QpidTypeCheck.ObjectIsMap(obj))
+ {
+ Console.WriteLine("Dictionary");
+ ShowDictionary((Dictionary<string, object>)obj, level + 1);
+ }
+ else if (QpidTypeCheck.ObjectIsList(obj))
+ {
+ Console.WriteLine("List");
+ ShowList((List<object>)obj, level + 1);
+ }
+ else
+ Console.WriteLine("Value: {0}, Type: {1}",
+ obj.ToString(), obj.GetType().ToString());
+ }
+ }
+
+ /// <summary>
+ /// A function to diplay a Message. The native Object type is
+ /// decomposed into AMQP types.
+ /// </summary>
+ /// <param name="message">The Message</param>
+ public static void ShowMessage(Message message)
+ {
+ if ("amqp/map" == message.getContentType())
+ {
+ Console.WriteLine("Received a Dictionary");
+ Dictionary<string, object> content = new Dictionary<string, object>();
+ message.getContent(content);
+ ShowDictionary(content, 0);
+ }
+ else if ("amqp/list" == message.getContentType())
+ {
+ Console.WriteLine("Received a List");
+ List<object> content = new List<object>();
+ message.getContent(content);
+ ShowList(content, 0);
+ }
+ else
+ {
+ Console.WriteLine("Received a String");
+ Console.WriteLine(message.getContent());
+ }
+ }
+ }
+
+
+
+ /// <summary>
+ /// A model class to demonstrate how a user may use the Qpid Messaging
+ /// interface to receive Session messages using a callback.
+ /// </summary>
+ class ReceiverProcess : ISessionReceiver
+ {
+ UInt32 messagesReceived = 0;
+
+ /// <summary>
+ /// SessionReceiver implements the ISessionReceiver interface.
+ /// It is the callback function that receives all messages for a Session.
+ /// It may be called any time server is running.
+ /// It is always called on server's private thread.
+ /// </summary>
+ /// <param name="receiver">The Receiver associated with the message.</param>
+ /// <param name="message">The Message</param>
+ public void SessionReceiver(Receiver receiver, Message message)
+ {
+ //
+ // Indicate message reception
+ //
+ Console.WriteLine("--- Message {0}", ++messagesReceived);
+
+ //
+ // Display the received message
+ //
+ MessageViewer.ShowMessage(message);
+
+ //
+ // Acknowledge the receipt of all received messages.
+ //
+ receiver.getSession().acknowledge();
+ }
+
+
+ /// <summary>
+ /// Usage
+ /// </summary>
+ /// <param name="url">Connection target</param>
+ /// <param name="addr">Address: broker exchange + routing key</param>
+ /// <param name="nSec">n seconds to keep callback open</param>
+ static void usage(string url, string addr, int nSec)
+ {
+
+ Console.WriteLine("usage: {0} [url [addr [nSec]]]",
+ System.Diagnostics.Process.GetCurrentProcess().ProcessName);
+ Console.WriteLine();
+ Console.WriteLine("A program to connect to a broker and receive");
+ Console.WriteLine("messages from a named exchange with a routing key.");
+ Console.WriteLine("The receiver uses a session callback and keeps the callback");
+ Console.WriteLine("server open for so many seconds.");
+ Console.WriteLine("The details of the message body's types and values are shown.");
+ Console.WriteLine();
+ Console.WriteLine(" url = target address for 'new Connection(url)'");
+ Console.WriteLine(" addr = address for 'session.createReceiver(addr)'");
+ Console.WriteLine(" nSec = time in seconds to keep the receiver callback open");
+ Console.WriteLine();
+ Console.WriteLine("Default values:");
+ Console.WriteLine(" {0} {1} {2} {3}",
+ System.Diagnostics.Process.GetCurrentProcess().ProcessName,
+ url, addr, nSec);
+ }
+
+
+ /// <summary>
+ /// A function to illustrate how to open a Session callback and
+ /// receive messages.
+ /// </summary>
+ /// <param name="args">Main program arguments</param>
+ public void TestProgram(string[] args)
+ {
+ string url = "amqp:tcp:localhost:5672";
+ string addr = "amq.direct/map_example";
+ int nSec = 30;
+
+ if (1 == args.Length)
+ {
+ if (args[0].Equals("-h") || args[0].Equals("-H") || args[0].Equals("/?"))
+ {
+ usage(url, addr, nSec);
+ return;
+ }
+ }
+
+ if (args.Length > 0)
+ url = args[0];
+ if (args.Length > 1)
+ addr = args[1];
+ if (args.Length > 2)
+ nSec = System.Convert.ToInt32(args[2]);
+
+ //
+ // Create and open an AMQP connection to the broker URL
+ //
+ Connection connection = new Connection(url);
+ connection.open();
+
+ //
+ // Create a session.
+ //
+ Session session = connection.createSession();
+
+ //
+ // Receive through callback
+ //
+ // Create callback server and implicitly start it
+ //
+ sessionreceiver.server cbServer =
+ new sessionreceiver.server(session, this);
+
+ //
+ // The callback server is running and executing callbacks on a
+ // separate thread.
+ //
+
+ //
+ // Create a receiver for the direct exchange using the
+ // routing key "map_example".
+ //
+ Receiver receiver = session.createReceiver(addr);
+
+ //
+ // Establish a capacity
+ //
+ receiver.setCapacity(100);
+
+ //
+ // Wait so many seconds for messages to arrive.
+ //
+ System.Threading.Thread.Sleep(nSec * 1000); // in mS
+
+ //
+ // Stop the callback server.
+ //
+ cbServer.close();
+
+ //
+ // Close the receiver and the connection.
+ //
+ receiver.close();
+ connection.close();
+ }
+ }
+
+
+ class MapCallbackReceiverMain
+ {
+ /// <summary>
+ /// Main program
+ /// </summary>
+ /// <param name="args">Main prgram args</param>
+ static void Main(string[] args)
+ {
+ // Invoke 'TestProgram' as non-static class.
+ ReceiverProcess mainProc = new ReceiverProcess();
+
+ mainProc.TestProgram(args);
+
+ }
+ }
+}
+
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj
new file mode 100644
index 0000000000..e8aae4be7d
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.csproj
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{68A43817-2358-4A31-8FDF-FE21722BFBCF}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>csharp.map.callback.receiver</RootNamespace>
+ <AssemblyName>csharp.map.callback.receiver</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="csharp.map.callback.receiver.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\src\sessionreceiver\org.apache.qpid.messaging.sessionreceiver.csproj">
+ <Project>{B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}</Project>
+ <Name>org.apache.qpid.messaging.sessionreceiver</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/Properties/AssemblyInfo.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..1f849441d4
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/Properties/AssemblyInfo.cs
@@ -0,0 +1,54 @@
+/*
+* 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("csharp.map.sender")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("csharp.map.sender")]
+[assembly: AssemblyCopyright("Copyright © 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1eec2eca-adbd-4394-8b01-f4c4645bb122")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs
new file mode 100644
index 0000000000..a097267f5f
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.Linq;
+using System.Text;
+using org.apache.qpid.messaging;
+
+namespace org.apache.qpid.messaging.examples
+{
+ class MapSender
+ {
+ //
+ // usage
+ //
+ static void usage(string url, string addr, UInt32 count)
+ {
+
+ Console.WriteLine("usage: {0} [url [addr [count]]]",
+ System.Diagnostics.Process.GetCurrentProcess().ProcessName);
+ Console.WriteLine();
+ Console.WriteLine("A program to connect to a broker and send N");
+ Console.WriteLine("messages to a named exchange with a routing key.");
+ Console.WriteLine();
+ Console.WriteLine(" url = target address for 'new Connection(url)'");
+ Console.WriteLine(" addr = address for 'session.createReceiver(addr)'");
+ Console.WriteLine(" count = number of messages to send");
+ Console.WriteLine();
+ Console.WriteLine("Default values:");
+ Console.WriteLine(" {0} {1} {2} {3}",
+ System.Diagnostics.Process.GetCurrentProcess().ProcessName,
+ url, addr, count);
+ }
+
+
+ //
+ // TestProgram
+ //
+ public void TestProgram(string[] args)
+ {
+ string url = "amqp:tcp:localhost:5672";
+ string addr = "amq.direct/map_example";
+ UInt32 count = 1;
+
+ if (1 == args.Length)
+ {
+ if (args[0].Equals("-h") || args[0].Equals("-H") || args[0].Equals("/?"))
+ {
+ usage(url, addr, count);
+ return;
+ }
+ }
+
+ if (args.Length > 0)
+ url = args[0];
+ if (args.Length > 1)
+ addr = args[1];
+ if (args.Length > 2)
+ count = System.Convert.ToUInt32(args[2]);
+
+
+ //
+ // Create and open an AMQP connection to the broker URL
+ //
+ Connection connection = new Connection(url);
+ connection.open();
+
+ //
+ // Create a session and a sender to the direct exchange using the
+ // routing key "map_example".
+ //
+ Session session = connection.createSession();
+ Sender sender = session.createSender(addr);
+
+ //
+ // Create structured content for the message. This example builds a
+ // map of items including a nested map and a list of values.
+ //
+ Dictionary<string, object> content = new Dictionary<string, object>();
+ Dictionary<string, object> subMap = new Dictionary<string, object>();
+ List<object> colors = new List<object>();
+
+ content["id"] = 987654321;
+ content["name"] = "Widget";
+ content["percent"] = 0.99;
+
+ subMap["name"] = "Smith";
+ subMap["number"] = 354;
+
+ content["nested"] = subMap;
+
+ colors.Add("red");
+ colors.Add("green");
+ colors.Add("white");
+
+ content["colors"] = colors;
+
+ //
+ // Construct a message with the map content and send it synchronously
+ // via the sender.
+ //
+ Message message = new Message(content);
+ for (UInt32 i = 0; i<count; i++)
+ sender.send(message, true);
+
+ //
+ // Close the connection.
+ //
+ connection.close();
+ }
+ }
+
+ class MapSenderMain
+ {
+ //
+ // Main
+ //
+ static void Main(string[] args)
+ {
+ // Invoke 'TestProgram' as non-static class.
+ MapSender mainProc = new MapSender();
+
+ mainProc.TestProgram(args);
+
+ }
+ }
+}
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.csproj
new file mode 100644
index 0000000000..5089737dbe
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.csproj
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{12F1C14F-5C7D-4075-9BAE-C091394FF99A}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>csharp.map.callback.sender</RootNamespace>
+ <AssemblyName>csharp.map.callback.sender</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="csharp.map.callback.sender.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj
index a491274c62..380e33bb7d 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.receiver.csproj
@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -31,10 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="org.apache.qpid.messagingd, Version=1.0.3786.14109, Culture=neutral, PublicKeyToken=7e57166074abee8c, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\bin\Debug\org.apache.qpid.messagingd.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -52,6 +48,16 @@
<Compile Include="csharp.map.recevier.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\src\sessionreceiver\org.apache.qpid.messaging.sessionreceiver.csproj">
+ <Project>{B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}</Project>
+ <Name>org.apache.qpid.messaging.sessionreceiver</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs
index 461708ee16..9a425c03b7 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs
@@ -29,8 +29,8 @@ namespace org.apache.qpid.messaging.examples
{
static void Main(string[] args)
{
-// string url = "amqp:tcp:localhost:5672";
- string url = "10.16.18.254:5672";
+ string url = "amqp:tcp:localhost:5672";
+// string url = "10.16.18.254:5672";
if (args.Length > 0)
url = args[0];
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj
index d647509474..4482e6ab02 100644
--- a/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj
+++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.csproj
@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -31,10 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="org.apache.qpid.messagingd, Version=1.0.3786.14109, Culture=neutral, PublicKeyToken=7e57166074abee8c, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\bin\Debug\org.apache.qpid.messagingd.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -52,6 +48,12 @@
<Compile Include="csharp.map.sender.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln b/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln
index 0619727239..8b0b3fd357 100644
--- a/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln
+++ b/cpp/bindings/qpid/dotnet/org.apache.qpid.messaging.sln
@@ -28,8 +28,20 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StructuredMessage", "StructuredMessage", "{E99FEFEE-B866-4BBA-9AA3-79DDF1C92960}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.map.sender", "examples\csharp.map.sender\csharp.map.sender.csproj", "{5D8252F5-E1D3-44A0-94C7-7CB75E843C10}"
+ ProjectSection(ProjectDependencies) = postProject
+ {AA5A3B83-5F98-406D-A01C-5A921467A57D} = {AA5A3B83-5F98-406D-A01C-5A921467A57D}
+ EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.map.receiver", "examples\csharp.map.receiver\csharp.map.receiver.csproj", "{AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}"
+ ProjectSection(ProjectDependencies) = postProject
+ {AA5A3B83-5F98-406D-A01C-5A921467A57D} = {AA5A3B83-5F98-406D-A01C-5A921467A57D}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "org.apache.qpid.messaging.sessionreceiver", "src\sessionreceiver\org.apache.qpid.messaging.sessionreceiver.csproj", "{B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.map.callback.receiver", "examples\csharp.map.callback.receiver\csharp.map.callback.receiver.csproj", "{68A43817-2358-4A31-8FDF-FE21722BFBCF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharp.map.callback.sender", "examples\csharp.map.callback.sender\csharp.map.callback.sender.csproj", "{12F1C14F-5C7D-4075-9BAE-C091394FF99A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -101,6 +113,36 @@ Global
{AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9}.Release|Win32.ActiveCfg = Release|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}.Release|Win32.ActiveCfg = Release|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF}.Release|Win32.ActiveCfg = Release|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A}.Release|Win32.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -114,5 +156,7 @@ Global
{AF2FBC78-266C-430C-BC29-9477AB596A36} = {39E9D1BF-3A0B-4D86-BF6B-F463E1A2245A}
{5D8252F5-E1D3-44A0-94C7-7CB75E843C10} = {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960}
{AD9E53D7-DB10-4DA2-84D2-A81BE09B04E9} = {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960}
+ {68A43817-2358-4A31-8FDF-FE21722BFBCF} = {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960}
+ {12F1C14F-5C7D-4075-9BAE-C091394FF99A} = {E99FEFEE-B866-4BBA-9AA3-79DDF1C92960}
EndGlobalSection
EndGlobal
diff --git a/cpp/bindings/qpid/dotnet/src/Address.cpp b/cpp/bindings/qpid/dotnet/src/Address.cpp
new file mode 100644
index 0000000000..8b48a2037f
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/Address.cpp
@@ -0,0 +1,186 @@
+/*
+* 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.
+*/
+
+#include <windows.h>
+#include <msclr\lock.h>
+#include <oletx2xa.h>
+#include <string>
+#include <limits>
+
+#include "qpid/messaging/Address.h"
+
+#include "Address.h"
+#include "QpidMarshal.h"
+#include "QpidTypeCheck.h"
+#include "TypeTranslator.h"
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+ /// <summary>
+ /// Address is a managed wrapper for a qpid::messaging::Address
+ /// </summary>
+
+ // Create empty
+ Address::Address() :
+ addressp(new ::qpid::messaging::Address(QpidMarshal::ToNative("")))
+ {
+ }
+
+ // Create string address
+ Address::Address(System::String ^ address) :
+ addressp(new ::qpid::messaging::Address(QpidMarshal::ToNative(address)))
+ {
+ }
+
+ // Create with options
+ Address::Address(System::String ^ name,
+ System::String ^ subject,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options) :
+ addressp(new ::qpid::messaging::Address())
+ {
+ setName(name);
+ setSubject(subject);
+ setOptions(options);
+ setType("");
+ }
+
+
+ Address::Address(System::String ^ name,
+ System::String ^ subject,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options,
+ System::String ^ type) :
+ addressp(new ::qpid::messaging::Address())
+ {
+ setName(name);
+ setSubject(subject);
+ setOptions(options);
+ setType(type);
+ }
+
+
+ // Create from received address
+ Address::Address(::qpid::messaging::Address * addrp) :
+ addressp(addrp)
+ {
+ }
+
+ // Destructor
+ Address::~Address()
+ {
+ Cleanup();
+ }
+
+
+ // Finalizer
+ Address::!Address()
+ {
+ Cleanup();
+ }
+
+
+ // Destroys kept object
+ // TODO: add lock
+ void Address::Cleanup()
+ {
+ if (NULL != addressp)
+ {
+ delete addressp;
+ addressp = NULL;
+ }
+ }
+
+
+ //
+ // name
+ //
+ System::String ^ Address::getName()
+ {
+ return gcnew System::String(addressp->getName().c_str());
+ }
+
+ void Address::setName(System::String ^ name)
+ {
+ addressp->::qpid::messaging::Address::setName(QpidMarshal::ToNative(name));
+ }
+
+ //
+ // subject
+ //
+ System::String ^ Address::getSubject()
+ {
+ return gcnew System::String(addressp->getSubject().c_str());
+ }
+
+ void Address::setSubject(System::String ^ subject)
+ {
+ addressp->setName(QpidMarshal::ToNative(subject));
+ }
+
+ //
+ // options
+ //
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ Address::getOptions()
+ {
+ ::qpid::types::Variant::Map map;
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ newMap =
+ gcnew System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^>;
+ map = addressp->getOptions();
+ TypeTranslator::NativeToManaged(newMap, map);
+ return newMap;
+ }
+
+
+ void Address::setOptions(System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options)
+ {
+ ::qpid::types::Variant::Map map;
+ TypeTranslator::ManagedToNative(map, options);
+ addressp->setOptions(map);
+ }
+
+ //
+ // type
+ //
+ System::String ^ Address::getType()
+ {
+ return gcnew System::String(addressp->getType().c_str());
+ }
+
+
+ void Address::setType(System::String ^ type)
+ {
+ addressp->setName(QpidMarshal::ToNative(type));
+ }
+
+ //
+ // str
+ //
+ System::String ^ Address::str()
+ {
+ return gcnew System::String(addressp->str().c_str());
+ }
+}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Address.h b/cpp/bindings/qpid/dotnet/src/Address.h
new file mode 100644
index 0000000000..72eed76eb0
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/Address.h
@@ -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.
+*/
+
+#pragma once
+
+#include <windows.h>
+#include <msclr\lock.h>
+#include <oletx2xa.h>
+#include <string>
+#include <limits>
+
+#include "qpid/messaging/Address.h"
+
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+ /// <summary>
+ /// Address is a managed wrapper for a qpid::messaging::Address
+ /// </summary>
+
+ public ref class Address
+ {
+ private:
+ // Kept object deletion code
+ void Cleanup();
+
+ public:
+ // The kept object in the Messaging C++ DLL
+ ::qpid::messaging::Address * addressp;
+
+ Address();
+
+ Address(System::String ^ address);
+
+ Address(System::String ^ name,
+ System::String ^ subject,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options);
+
+ Address(System::String ^ name,
+ System::String ^ subject,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options,
+ System::String ^ type);
+
+ // Create from received address
+ Address(::qpid::messaging::Address * addrp);
+
+ ~Address();
+ !Address();
+// Address(const Address % rhs);
+
+ System::String ^ getName();
+ void setName(System::String ^ name);
+
+ System::String ^ getSubject();
+ void setSubject(System::String ^ subject);
+
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ getOptions();
+
+ void setOptions(System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options);
+
+ System::String ^ getType();
+ void setType(System::String ^ type);
+
+ System::String ^ str();
+ };
+}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Connection.cpp b/cpp/bindings/qpid/dotnet/src/Connection.cpp
index 58b93f6b24..4936e18c4e 100644
--- a/cpp/bindings/qpid/dotnet/src/Connection.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Connection.cpp
@@ -25,10 +25,13 @@
#include "qpid/messaging/Connection.h"
#include "qpid/messaging/Session.h"
+#include "qpid/messaging/exceptions.h"
#include "QpidMarshal.h"
#include "Connection.h"
#include "Session.h"
+#include "QpidException.h"
+#include "TypeTranslator.h"
namespace org {
namespace apache {
@@ -39,12 +42,25 @@ namespace messaging {
/// Connection is a managed wrapper for a qpid::messaging::Connection
/// </summary>
- // Public constructor
+ // constructors
Connection::Connection(System::String ^ url) :
connectionp(new ::qpid::messaging::Connection(QpidMarshal::ToNative(url)))
{
}
+
+ Connection::Connection(System::String ^ url,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options) :
+ connectionp(new ::qpid::messaging::Connection(QpidMarshal::ToNative(url)))
+ {
+ for each (System::Collections::Generic::KeyValuePair<System::String^, System::Object^> kvp in options)
+ {
+ setOption(kvp.Key, kvp.Value);
+ }
+ }
+
+
Connection::Connection(System::String ^ url, System::String ^ options) :
connectionp(new ::qpid::messaging::Connection(QpidMarshal::ToNative(url),
QpidMarshal::ToNative(options)))
@@ -77,39 +93,185 @@ namespace messaging {
}
}
- Session ^ Connection::createSession()
+
+ void Connection::setOption(System::String ^ name, System::Object ^ value)
{
- return createSession("");
+ ::qpid::types::Variant entryValue;
+ TypeTranslator::ManagedToNativeObject(value, entryValue);
+ std::string entryName = QpidMarshal::ToNative(name);
+ connectionp->::qpid::messaging::Connection::setOption(entryName, entryValue);
}
+ void Connection::open()
+ {
+ connectionp->open();
+ }
- Session ^ Connection::createSession(System::String ^ name)
+ System::Boolean Connection::isOpen()
{
- // allocate native session
- ::qpid::messaging::Session * sessionp = new ::qpid::messaging::Session;
+ return connectionp->isOpen();
+ }
- // create native session
- *sessionp = connectionp->createSession(QpidMarshal::ToNative(name));
+ void Connection::close()
+ {
+ connectionp->close();
+ }
+
+ //
+ // createTransactionalSession()
+ //
+ Session ^ Connection::createTransactionalSession()
+ {
+ return createTransactionalSession("");
+ }
+
+
+ Session ^ Connection::createTransactionalSession(System::String ^ name)
+ {
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Session * sessionp = NULL;
+ Session ^ newSession = nullptr;
- // create managed session
- Session ^ newSession = gcnew Session(sessionp, this);
+ try
+ {
+ // allocate native session
+ sessionp = new ::qpid::messaging::Session ;
+
+ // create native session
+ *sessionp = connectionp->createTransactionalSession(QpidMarshal::ToNative(name));
+
+ // create managed session
+ newSession = gcnew Session(sessionp, this);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Connection::createTransactionalSession unknown error");
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sessionp != NULL)
+ {
+ delete sessionp;
+ }
+ throw newException;
+ }
+ }
return newSession;
}
- void Connection::open()
+ //
+ // createSession()
+ //
+ Session ^ Connection::createSession()
{
- connectionp->open();
+ return createSession("");
}
- bool Connection::isOpen()
+
+ Session ^ Connection::createSession(System::String ^ name)
{
- return connectionp->isOpen();
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Session * sessionp = NULL;
+ Session ^ newSession = nullptr;
+
+ try
+ {
+ // allocate native session
+ sessionp = new ::qpid::messaging::Session ;
+
+ // create native session
+ *sessionp = connectionp->createSession(QpidMarshal::ToNative(name));
+
+ // create managed session
+ newSession = gcnew Session(sessionp, this);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Connection::createSession unknown error");
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sessionp != NULL)
+ {
+ delete sessionp;
+ }
+ throw newException;
+ }
+ }
+
+ return newSession;
}
- void Connection::close()
+
+ Session ^ Connection::getSession(System::String ^ name)
{
- connectionp->close();
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Session * sess = NULL;
+ Session ^ newSession = nullptr;
+
+ try
+ {
+ const std::string n = QpidMarshal::ToNative(name);
+
+ *sess = connectionp->::qpid::messaging::Connection::getSession(n);
+
+ newSession = gcnew Session(sess, this);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Connection::getSession unknown error");
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sess != NULL)
+ {
+ delete sess;
+ }
+ throw newException;
+ }
+ }
+
+ return newSession;
}
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Connection.h b/cpp/bindings/qpid/dotnet/src/Connection.h
index e16cb1e24e..894a96d224 100644
--- a/cpp/bindings/qpid/dotnet/src/Connection.h
+++ b/cpp/bindings/qpid/dotnet/src/Connection.h
@@ -50,14 +50,29 @@ namespace messaging {
public:
Connection(System::String ^ url);
+
+ Connection(System::String ^ url,
+ System::Collections::Generic::Dictionary<
+ System::String ^, System::Object ^> ^ options);
+
Connection(System::String ^ url, System::String ^ options);
~Connection();
!Connection();
- Session ^ createSession();
- Session ^ createSession(System::String ^ name);
+ void setOption(System::String ^ name, System::Object ^ value);
+
void open();
- bool isOpen();
+ System::Boolean isOpen();
void close();
+
+ // createTransactionalSession()
+ Session ^ createTransactionalSession();
+ Session ^ createTransactionalSession(System::String ^ name);
+
+ // createSession()
+ Session ^ createSession();
+ Session ^ createSession(System::String ^ name);
+
+ Session ^ getSession(System::String ^ name);
};
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Duration.h b/cpp/bindings/qpid/dotnet/src/Duration.h
index 9b763a7fdf..b7d2bf147e 100644
--- a/cpp/bindings/qpid/dotnet/src/Duration.h
+++ b/cpp/bindings/qpid/dotnet/src/Duration.h
@@ -25,8 +25,6 @@
#include <string>
#include <limits>
-#include "qpid/messaging/Duration.h"
-
namespace org {
namespace apache {
namespace qpid {
@@ -34,34 +32,59 @@ namespace messaging {
/// <summary>
/// Duration is a time interval in milliseconds.
- /// It is a managed wrapper for a ::qpid::messaging::Duration
+ /// It is a managed equivalent of ::qpid::messaging::Duration
/// </summary>
public ref class Duration
{
private:
- // Experimental constructor
- Duration(const ::qpid::messaging::Duration *);
-
- // Kept object deletion code
- void Cleanup();
+ System::UInt64 milliseconds;
public:
- Duration(System::UInt64 milliseconds);
- ~Duration();
- !Duration();
- // The kept object in the Messaging C++ DLL
- const ::qpid::messaging::Duration * durationp;
+ Duration(const Duration % rhs) :
+ milliseconds(rhs.milliseconds)
+ {
+ };
+
+ explicit Duration(System::UInt64 mS) :
+ milliseconds(mS) {};
+
+ Duration() :
+ milliseconds(System::UInt64::MaxValue) {};
+
+ property System::UInt64 Milliseconds
+ {
+ System::UInt64 get () { return milliseconds; }
+ }
+
+ static Duration ^ operator * (Duration ^ dur, const System::UInt64 multiplier)
+ {
+ Duration ^ result = gcnew Duration(dur->Milliseconds * multiplier);
+ return result;
+ }
- System::UInt64 getMilliseconds();
+ static Duration ^ operator * (const System::UInt64 multiplier, Duration ^ dur)
+ {
+ Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds);
+ return result;
+ }
+ };
+
+ public ref class DurationConstants
+ {
+ public:
+ static Duration ^ FORVER;
+ static Duration ^ IMMEDIATE;
+ static Duration ^ SECOND;
+ static Duration ^ MINUTE;
- // Return value(s) for constant durations
- // NOTE: These return the duration mS and not a Duration
- // object like the C++ code gets.
- System::UInt64 FOREVER();
- System::UInt64 IMMEDIATE();
- System::UInt64 SECOND();
- System::UInt64 MINUTE();
+ static DurationConstants()
+ {
+ FORVER = gcnew Duration();
+ IMMEDIATE = gcnew Duration(0);
+ SECOND = gcnew Duration(1000);
+ MINUTE = gcnew Duration(60000);
+ }
};
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Message.cpp b/cpp/bindings/qpid/dotnet/src/Message.cpp
index 9c28e728f6..193a2eb976 100644
--- a/cpp/bindings/qpid/dotnet/src/Message.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Message.cpp
@@ -29,7 +29,12 @@
#include "qpid/types/Variant.h"
#include "QpidMarshal.h"
+#include "Address.h"
+#include "Duration.h"
#include "Message.h"
+#include "QpidTypeCheck.h"
+#include "QpidException.h"
+#include "TypeTranslator.h"
namespace org {
namespace apache {
@@ -40,38 +45,26 @@ namespace messaging {
/// Message is a managed wrapper for a ::qpid::messaging::Message
/// </summary>
- // This constructor is used to create a message from bytes to put into the message
- Message::Message(System::String ^ bytes) :
- aVMap(gcnew VMap()),
- aVList(gcnew VList()),
- pVMapType(aVMap.GetType()),
- pVListType(aVList.GetType()),
- messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative(bytes)))
+ // Create empty message
+ Message::Message() :
+ messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative("")))
{
}
- // This constructor creates a message from a native received message
- Message::Message(::qpid::messaging::Message * msgp) :
- aVMap(gcnew VMap()),
- aVList(gcnew VList()),
- pVMapType(aVMap.GetType()),
- pVListType(aVList.GetType()),
- messagep(msgp)
+ // Create from string
+ Message::Message(System::String ^ string) :
+ messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative(string)))
{
}
-
+ // Create from object
Message::Message(System::Object ^ objp) :
- aVMap(gcnew VMap()),
- aVList(gcnew VList()),
- pVMapType(aVMap.GetType()),
- pVListType(aVList.GetType()),
messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative("")))
{
::qpid::types::Variant * variantp = 0;
std::string * variantsp = 0;
- if (objIsMap(objp))
+ if (QpidTypeCheck::ObjectIsMap(objp))
{
// Create a mapped message using given dictionary
@@ -79,7 +72,7 @@ namespace messaging {
::qpid::types::Variant::Map newMap;
// Add the map variables to the map
- Encode(newMap, (VMap ^)objp);
+ TypeTranslator::ManagedToNative(newMap, (QpidMap ^)objp);
// Set message content type
messagep->setContentType("ampq/map");
@@ -87,7 +80,7 @@ namespace messaging {
// Insert the map into the message
::qpid::messaging::encode(newMap, *messagep, QpidMarshal::ToNative("amqp/map"));
}
- else if (objIsList(objp))
+ else if (QpidTypeCheck::ObjectIsList(objp))
{
// Create a list message using given list
@@ -95,7 +88,7 @@ namespace messaging {
::qpid::types::Variant::List newList;
// Add the list variables to the list
- Encode(newList, (VList ^)objp);
+ TypeTranslator::ManagedToNative(newList, (QpidList ^)objp);
// Set message content type
messagep->setContentType("ampq/list");
@@ -110,6 +103,12 @@ namespace messaging {
}
}
+ // Create from received message
+ Message::Message(::qpid::messaging::Message * msgp) :
+ messagep(msgp)
+ {
+ }
+
// Destructor
Message::~Message()
@@ -125,6 +124,7 @@ namespace messaging {
}
// Copy constructor
+ // TODO: prevent copy
Message::Message(const Message % rhs)
{
messagep = rhs.messagep;
@@ -143,209 +143,25 @@ namespace messaging {
//
- // The given object is a Dictionary.
- // Add its elements to the qpid map.
+ // ReplyTo
//
- void Message::Encode(::qpid::types::Variant::Map & theMapp,
- VMap ^ theObjp)
+ void Message::setReplyTo(Address ^ address)
{
- // iterate the items, converting each to a variant and adding to the map
- for each (System::Collections::Generic::KeyValuePair<System::String^, System::Object^> kvp in theObjp)
- {
- if (objIsMap(kvp.Value))
- {
- // Recurse on inner map
- // Allocate a map
- ::qpid::types::Variant::Map newMap;
-
- // Add the map variables to the map
- Encode(newMap, (VMap ^)kvp.Value);
-
- // Create a variant entry for the inner map
- std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newMap));
-
- // Get map's name
- std::string entryName = QpidMarshal::ToNative(kvp.Key);
-
- // Add inner map to outer map
- theMapp.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, *newVariantp));
- }
- else if (objIsList(kvp.Value))
- {
- // Recurse on inner list
- // Allocate a list
- ::qpid::types::Variant::List newList;
-
- // Add the List variables to the list
- Encode(newList, (VList ^)kvp.Value);
-
- // Create a variant entry for the inner map
- ::qpid::types::Variant::List newVariant(newList);
-
- //std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newList));
-
- // Get list's name
- std::string entryName = QpidMarshal::ToNative(kvp.Key);
-
- // Add inner list to outer map
- theMapp.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, newVariant));
- }
- else
- {
- // Add a simple native type to map
- ::qpid::types::Variant entryValue;
- EncodeObject(kvp.Value, entryValue);
- std::string entryName = QpidMarshal::ToNative(kvp.Key);
- theMapp.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, entryValue));
- }
- }
+ messagep->setReplyTo(*(address->addressp));
}
-
-
- //
- // The given object is a List.
- // Add its elements to the qpid list.
- //
- void Message::Encode(::qpid::types::Variant::List & theListp,
- VList ^ theObjp)
+ Address ^ Message::getReplyTo()
{
- // iterate the items, converting each to a variant and adding to the map
- for each (System::Object ^ listObj in theObjp)
- {
- if (objIsMap(listObj))
- {
- // Recurse on inner map
- // Allocate a map
- ::qpid::types::Variant::Map newMap;
-
- // Add the map variables to the map
- Encode(newMap, (VMap ^)listObj);
-
- // Create a variant entry for the inner map
- std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newMap));
-
- // Add inner map to outer list
- theListp.push_back(*newVariantp);
- }
- else if (objIsList(listObj))
- {
- // Recurse on inner list
- // Allocate a list
- ::qpid::types::Variant::List newList;
-
- // Add the List variables to the list
- Encode(newList, (VList ^)listObj);
-
- // Create a variant entry for the inner list
- std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newList));
-
- // Add inner list to outer list
- theListp.push_back(*newVariantp);
- }
- else
- {
- // Add a simple native type to list
- ::qpid::types::Variant entryValue;
- EncodeObject(listObj, entryValue);
- theListp.push_back(entryValue);
- }
- }
- }
+ const ::qpid::messaging::Address & addrp =
+ messagep->::qpid::messaging::Message::getReplyTo();
+ return gcnew Address(const_cast<::qpid::messaging::Address *>(&addrp));
+ }
//
- // Returns a variant representing simple native type object.
- // Not to be called for Map/List objects.
+ // Subject
//
- void Message::EncodeObject(System::Object ^ theObjp,
- ::qpid::types::Variant & targetp)
- {
- System::Type ^ typeP = (*theObjp).GetType();
- System::TypeCode typeCode = System::Type::GetTypeCode( typeP );
-
- switch (typeCode)
- {
- case System::TypeCode::Boolean :
- targetp = System::Convert::ToBoolean(theObjp);
- break;
-
- case System::TypeCode::Byte :
- targetp = System::Convert::ToByte(theObjp);
- break;
-
- case System::TypeCode::UInt16 :
- targetp = System::Convert::ToUInt16(theObjp);
- break;
-
- case System::TypeCode::UInt32 :
- targetp = System::Convert::ToUInt32(theObjp);
- break;
-
- case System::TypeCode::UInt64 :
- targetp = System::Convert::ToUInt64(theObjp);
- break;
-
- case System::TypeCode::Char :
- case System::TypeCode::SByte :
- targetp = System::Convert::ToSByte(theObjp);
- break;
-
- case System::TypeCode::Int16 :
- targetp = System::Convert::ToInt16(theObjp);
- break;
-
- case System::TypeCode::Int32 :
- targetp = System::Convert::ToInt32(theObjp);
- break;
-
- case System::TypeCode::Int64 :
- targetp = System::Convert::ToInt64(theObjp);
- break;
-
- case System::TypeCode::Single :
- targetp = System::Convert::ToSingle(theObjp);
- break;
-
- case System::TypeCode::Double :
- targetp = System::Convert::ToDouble(theObjp);
- break;
-
- case System::TypeCode::String :
- {
- std::string rString;
- System::String ^ rpString;
-
- rpString = System::Convert::ToString(theObjp);
- rString = QpidMarshal::ToNative(rpString);
- targetp = rString;
- targetp.setEncoding(QpidMarshal::ToNative("utf8"));
- }
- break;
-
-
- default:
-
- throw gcnew System::NotImplementedException();
-
- }
- }
-
-
- // Properties...
-
- //void Message::setReplyTo(System::String ^ address)
- //{
- // messagep->setReplyTo(QpidMarshal::ToNative(address));
- //}
-
- //System::String ^ Message::getReplyTo()
- //{
- // return gcnew String(messagep->getReplyTo().c_str());
- //}
-
-
void Message::setSubject(System::String ^ subject)
{
messagep->setSubject(QpidMarshal::ToNative(subject));
@@ -357,6 +173,9 @@ namespace messaging {
}
+ //
+ // ContentType
+ //
void Message::setContentType(System::String ^ ct)
{
messagep->setContentType(QpidMarshal::ToNative(ct));
@@ -368,6 +187,9 @@ namespace messaging {
}
+ //
+ // MessageId
+ //
void Message::setMessageId(System::String ^ mId)
{
messagep->setMessageId(QpidMarshal::ToNative(mId));
@@ -379,6 +201,9 @@ namespace messaging {
}
+ //
+ // UserId
+ //
void Message::setUserId(System::String ^ uId)
{
messagep->setUserId(QpidMarshal::ToNative(uId));
@@ -390,6 +215,9 @@ namespace messaging {
}
+ //
+ // CorrelationId
+ //
void Message::setCorrelationId(System::String ^ cId)
{
messagep->setCorrelationId(QpidMarshal::ToNative(cId));
@@ -401,6 +229,9 @@ namespace messaging {
}
+ //
+ // Priority
+ //
void Message::setPriority(unsigned char priority)
{
messagep->setPriority(priority);
@@ -412,8 +243,22 @@ namespace messaging {
}
- //void setTtl(Duration ttl);
- //Duration getTtl();
+ //
+ // Ttl
+ //
+ void Message::setTtl(Duration ^ ttl)
+ {
+ ::qpid::messaging::Duration dur(ttl->Milliseconds);
+
+ messagep->setTtl(dur);
+ }
+
+ Duration ^ Message::getTtl()
+ {
+ Duration ^ dur = gcnew Duration(messagep->getTtl().getMilliseconds());
+
+ return dur;
+ }
void Message::setDurable(bool durable)
{
@@ -437,11 +282,22 @@ namespace messaging {
}
- //System::String ^ Message::getProperties()
- //{
- // pqid::types::Variant::Map * mapp = new
- // return gcnew String(messagep->getReplyTo().c_str());
- //}
+ System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ Message::getProperties()
+ {
+ ::qpid::types::Variant::Map map;
+
+ map = messagep->getProperties();
+
+ System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ dict =
+ gcnew System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ;
+
+ TypeTranslator::NativeToManaged(dict, map);
+
+ return dict;
+ }
void Message::setContent(System::String ^ content)
@@ -468,100 +324,7 @@ namespace messaging {
::qpid::messaging::decode(*messagep, map, QpidMarshal::ToNative("amqp/map"));
- Decode(dict, map);
- }
-
-
- // Given a user Dictionary and a qpid map,
- // extract the qpid elements and put them into the dictionary.
- //
- void Message::Decode(VMap ^ dict, ::qpid::types::Variant::Map & map)
- {
- // For each object in the message map,
- // create a .NET object and add it to the dictionary.
- for (::qpid::types::Variant::Map::const_iterator i = map.begin(); i != map.end(); ++i) {
- // Get the name
- System::String ^ elementName = gcnew String(i->first.c_str());
-
- ::qpid::types::Variant variant = i->second;
- ::qpid::types::VariantType vType = variant.getType();
-
- switch (vType)
- {
- case ::qpid::types::VAR_BOOL:
- dict[elementName] = variant.asBool();
- break;
-
- case ::qpid::types::VAR_UINT8:
- dict[elementName] = variant.asUint8();
- break;
-
- case ::qpid::types::VAR_UINT16:
- dict[elementName] = variant.asUint16();
- break;
-
- case ::qpid::types::VAR_UINT32:
- dict[elementName] = variant.asUint32();
- break;
-
- case ::qpid::types::VAR_UINT64:
- dict[elementName] = variant.asUint64();
- break;
-
- case ::qpid::types::VAR_INT8:
- dict[elementName] = variant.asInt8();
- break;
-
- case ::qpid::types::VAR_INT16:
- dict[elementName] = variant.asInt16();
- break;
-
- case ::qpid::types::VAR_INT32:
- dict[elementName] = variant.asInt32();
- break;
-
- case ::qpid::types::VAR_INT64:
- dict[elementName] = variant.asInt64();
- break;
-
- case ::qpid::types::VAR_FLOAT:
- dict[elementName] = variant.asFloat();
- break;
-
- case ::qpid::types::VAR_DOUBLE:
- dict[elementName] = variant.asDouble();
- break;
-
- case ::qpid::types::VAR_STRING:
- {
- System::String ^ elementValue = gcnew System::String(variant.asString().c_str());
- dict[elementName] = elementValue;
- break;
- }
- case ::qpid::types::VAR_MAP:
- {
- VMap ^ newDict = gcnew VMap();
-
- Decode (newDict, variant.asMap());
-
- dict[elementName] = newDict;
- break;
- }
-
- case ::qpid::types::VAR_LIST:
- {
- VList ^ newList = gcnew VList();
-
- Decode (newList, variant.asList());
-
- dict[elementName] = newList;
- break;
- }
-
- case ::qpid::types::VAR_UUID:
- break;
- }
- }
+ TypeTranslator::NativeToManaged(dict, map);
}
@@ -571,99 +334,43 @@ namespace messaging {
void Message::getContent(System::Collections::Generic::List<
System::Object^> ^ list)
{
- // Extract the message map from the message
- ::qpid::types::Variant::List vList;
+ // allocate a native messaging::List
+ ::qpid::types::Variant::List nativeList;
- ::qpid::messaging::decode(*messagep, vList, QpidMarshal::ToNative("amqp/list"));
+ // Extract the list from the message in native format
+ ::qpid::messaging::decode(*messagep, nativeList, QpidMarshal::ToNative("amqp/list"));
- Decode(list, vList);
+ // translate native list into user's managed list
+ TypeTranslator::NativeToManaged(list, nativeList);
}
-
- void Message::Decode(VList ^ vList, ::qpid::types::Variant::List & qpidList)
+ //
+ // User wants content as bytes.
+ // result array must be correct size already
+ //
+ void Message::getRaw(array<System::Byte> ^ arr)
{
- // For each object in the message map,
- // create a .NET object and add it to the dictionary.
- for (::qpid::types::Variant::List::const_iterator i = qpidList.begin(); i != qpidList.end(); ++i)
+ System::UInt32 size = messagep->getContentSize();
+
+ if (0 == size)
+ throw gcnew QpidException("Message::getRaw - message size is zero");
+
+ if (arr->Length != size)
+ throw gcnew QpidException("Message::getRaw - receive buffer is too small");
+
+ const char * ptr = messagep->getContentPtr();
+
+ // TODO: System::Runtime::InteropServices::Marshal::Copy(ptr, arr, 0, size);
+
+ for (UInt32 i = 0; i < size; i++)
{
- ::qpid::types::Variant variant = *i;
- ::qpid::types::VariantType vType = variant.getType();
-
- switch (vType)
- {
- case ::qpid::types::VAR_BOOL:
- (*vList).Add(variant.asBool());
- break;
-
- case ::qpid::types::VAR_UINT8:
- (*vList).Add(variant.asUint8());
- break;
-
- case ::qpid::types::VAR_UINT16:
- (*vList).Add(variant.asUint16());
- break;
-
- case ::qpid::types::VAR_UINT32:
- (*vList).Add(variant.asUint32());
- break;
-
- case ::qpid::types::VAR_UINT64:
- (*vList).Add(variant.asUint64());
- break;
-
- case ::qpid::types::VAR_INT8:
- (*vList).Add(variant.asInt8());
- break;
-
- case ::qpid::types::VAR_INT16:
- (*vList).Add(variant.asInt16());
- break;
-
- case ::qpid::types::VAR_INT32:
- (*vList).Add(variant.asInt32());
- break;
-
- case ::qpid::types::VAR_INT64:
- (*vList).Add(variant.asInt64());
- break;
-
- case ::qpid::types::VAR_FLOAT:
- (*vList).Add(variant.asFloat());
- break;
-
- case ::qpid::types::VAR_DOUBLE:
- (*vList).Add(variant.asDouble());
- break;
-
- case ::qpid::types::VAR_STRING:
- {
- System::String ^ elementValue = gcnew System::String(variant.asString().c_str());
- (*vList).Add(elementValue);
- break;
- }
- case ::qpid::types::VAR_MAP:
- {
- VMap ^ newDict = gcnew VMap();
-
- Decode (newDict, variant.asMap());
-
- (*vList).Add(newDict);
- break;
- }
-
- case ::qpid::types::VAR_LIST:
- {
- VList ^ newList = gcnew VList();
-
- Decode (newList, variant.asList());
-
- (*vList).Add(newList);
- break;
- }
-
- case ::qpid::types::VAR_UUID:
- break;
- }
+ arr[i] = ptr[i];
}
}
+
+
+ System::UInt64 Message::getContentSize()
+ {
+ return messagep->getContentSize();
+ }
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Message.h b/cpp/bindings/qpid/dotnet/src/Message.h
index c308fdf29f..ab06588634 100644
--- a/cpp/bindings/qpid/dotnet/src/Message.h
+++ b/cpp/bindings/qpid/dotnet/src/Message.h
@@ -31,14 +31,8 @@ namespace apache {
namespace qpid {
namespace messaging {
-typedef System::Collections::Generic::Dictionary<
- System::String^,
- System::Object^>
- VMap;
-
-typedef System::Collections::Generic::List<
- System::Object^>
- VList;
+ ref class Address;
+ ref class Duration;
/// <summary>
/// Message is a managed wrapper for a ::qpid::messaging::Message
@@ -51,51 +45,20 @@ typedef System::Collections::Generic::List<
// Kept object deletion code
void Cleanup();
- bool objIsMap (System::Object ^ op)
- {
- return (*op).GetType() == pVMapType;
- }
-
- bool objIsList(System::Object ^ op)
- {
- return (*op).GetType() == pVListType;
- }
-
- // The given object is a Dictionary.
- // Add its elements to the qpid map.
- void Encode(::qpid::types::Variant::Map & theMapp,
- VMap ^ theObjp);
-
- // The given object is a List.
- // Add its elements to the qpid list.
- void Encode(::qpid::types::Variant::List & theListp,
- VList ^ theObjp);
-
- // Returns a variant representing simple native type object.
- // Not to be called for Map/List objects.
- void EncodeObject(System::Object ^ theObjp,
- ::qpid::types::Variant & targetp);
-
-
- void Decode(VMap ^ dict, ::qpid::types::Variant::Map & map);
-
- void Decode(VList ^ vList, ::qpid::types::Variant::List & qpidList);
-
-
- // map and list for type comparison
- VMap aVMap;
- VList aVList;
- System::Type ^ pVMapType;
- System::Type ^ pVListType;
-
public:
+ // Create empty message
+ Message();
+
// Create from String
- Message(System::String ^ bytes);
+ Message(System::String ^ string);
// Create from object
Message(System::Object ^ obj);
- // Create reference copy
+ // TODO: Create from bytes
+ // Message(System::Byte [] ^ bytes);
+
+ // Create from received message
Message(::qpid::messaging::Message * msgp);
~Message();
@@ -107,8 +70,8 @@ typedef System::Collections::Generic::List<
// The kept object in the Messaging C++ DLL
::qpid::messaging::Message * messagep;
- //void setReplyTo(System::String ^ address);
- //System::String ^ getReplyTo();
+ void setReplyTo(Address ^ address);
+ Address ^ getReplyTo();
void setSubject(System::String ^ subject);
System::String ^ getSubject();
@@ -128,8 +91,8 @@ typedef System::Collections::Generic::List<
void setPriority(unsigned char priority);
unsigned char getPriority();
- //void setTtl(Duration ttl);
- //Duration getTtl();
+ void setTtl(Duration ^ ttl);
+ Duration ^ getTtl();
void setDurable(bool durable);
bool getDurable();
@@ -137,17 +100,32 @@ typedef System::Collections::Generic::List<
bool getRedelivered();
void setRedelivered(bool redelivered);
- //System::String ^ getProperties();
+ System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ getProperties();
void setContent(System::String ^ content);
+ //TODO:: void setContent(Bytes{} bytes, offset, length);
+
+ // get content as string
System::String ^ getContent();
+ // get content as dictionary
void getContent(System::Collections::Generic::Dictionary<
System::String^,
System::Object^> ^ dict);
+ // get content as map
void getContent(System::Collections::Generic::List<
System::Object^> ^);
+
+ // get content as bytes
+ void getRaw(cli::array<System::Byte> ^ arr);
+
+ System::UInt64 getContentSize();
+
+ //TODO: EncodingException
+
+ // Note: encode/decode functions are in TypeTranslator
};
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/resource.h b/cpp/bindings/qpid/dotnet/src/QpidException.h
index e2f47357fe..eecc54526b 100644
--- a/cpp/bindings/qpid/dotnet/src/resource.h
+++ b/cpp/bindings/qpid/dotnet/src/QpidException.h
@@ -17,6 +17,22 @@
* under the License.
*/
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by app.rc
+#pragma once
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+using namespace System;
+
+public ref class QpidException : System::Exception
+{
+ public:
+
+ QpidException() : System::Exception() {}
+ QpidException(String^ estring) : System::Exception(estring) {}
+
+};
+
+}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/QpidMarshal.h b/cpp/bindings/qpid/dotnet/src/QpidMarshal.h
index 7667db848c..7b523464b1 100644
--- a/cpp/bindings/qpid/dotnet/src/QpidMarshal.h
+++ b/cpp/bindings/qpid/dotnet/src/QpidMarshal.h
@@ -37,6 +37,7 @@ public:
/// <summary>
/// Convert managed String into native UTF8-encoded string
+ /// TODO: figure out some encoding other that UTF-8
/// </summary>
static std::string ToNative (System::String^ managed)
diff --git a/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h b/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h
new file mode 100644
index 0000000000..2e87c3e376
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h
@@ -0,0 +1,75 @@
+/*
+* 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.
+*/
+#pragma once
+
+#include <windows.h>
+#include <msclr\lock.h>
+#include <oletx2xa.h>
+#include <string>
+#include <limits>
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+ /// <summary>
+ /// QpidTypeCheck determines if a given managed object represents
+ /// a qpid type per the scheme presented by the messaging DLL.
+ ///
+ // The supported mapping is:
+ /// * a managed Dictionary and a Qpid Messaging Map
+ /// * a managed List and a Qpid Messaging List
+ /// </summary>
+
+ typedef System::Collections::Generic::Dictionary<
+ System::String^,
+ System::Object^>
+ QpidMap;
+
+ typedef System::Collections::Generic::List<
+ System::Object^>
+ QpidList;
+
+ private ref class QpidTypeCheckConstants
+ {
+ public:
+ static System::Type const ^ const mapTypeP = System::Type::GetType(
+ "System.Collections.Generic.Dictionary`2[System.String,System.Object]");
+ static System::Type const ^ const listTypeP = System::Type::GetType(
+ "System.Collections.Generic.List`1[System.Object]");
+ };
+
+
+ public ref class QpidTypeCheck
+ {
+
+ public:
+
+ static bool ObjectIsMap (System::Object ^ object)
+ {
+ return (*object).GetType() == QpidTypeCheckConstants::mapTypeP;
+ }
+
+ static bool ObjectIsList(System::Object ^ object)
+ {
+ return (*object).GetType() == QpidTypeCheckConstants::listTypeP;
+ }
+ };
+}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp
index 3902ea75c2..d647315620 100644
--- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp
@@ -26,11 +26,13 @@
#include "qpid/messaging/Receiver.h"
#include "qpid/messaging/Session.h"
#include "qpid/messaging/Message.h"
+#include "qpid/messaging/exceptions.h"
#include "Receiver.h"
#include "Session.h"
#include "Message.h"
#include "Duration.h"
+#include "QpidException.h"
namespace org {
namespace apache {
@@ -82,56 +84,163 @@ namespace messaging {
}
}
+ //
+ // get(message)
+ //
bool Receiver::get(Message ^ mmsgp)
{
- return receiverp->Receiver::get(*((*mmsgp).messagep));
+ return get(mmsgp, DurationConstants::FORVER);
}
bool Receiver::get(Message ^ mmsgp, Duration ^ durationp)
{
- return receiverp->Receiver::get(*((*mmsgp).messagep),
- *((*durationp).durationp));
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ return receiverp->Receiver::get(*(mmsgp->messagep), dur);
}
+ //
+ // message = get()
+ //
+ Message ^ Receiver::get()
+ {
+ return get(DurationConstants::FORVER);
+ }
+
+
Message ^ Receiver::get(Duration ^ durationp)
{
- // allocate a message
- ::qpid::messaging::Message * msgp = new ::qpid::messaging::Message;
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Message * msgp = NULL;
+ Message ^ newMessage = nullptr;
- // get the message
- *msgp = receiverp->::qpid::messaging::Receiver::get(*((*durationp).durationp));
+ try
+ {
+ // allocate a message
+ msgp = new ::qpid::messaging::Message;
+
+ // translate the duration
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
- // create new managed message with received message embedded in it
- Message ^ newMessage = gcnew Message(msgp);
+ // get the message
+ *msgp = receiverp->::qpid::messaging::Receiver::get(dur);
+
+ // create new managed message with received message embedded in it
+ newMessage = gcnew Message(msgp);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Receiver:get unknown error");
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (msgp != NULL)
+ {
+ delete msgp;
+ }
+
+ throw newException;
+ }
+ }
return newMessage;
}
+ //
+ // fetch(message)
+ //
bool Receiver::fetch(Message ^ mmsgp)
{
- return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep));
+ return fetch(mmsgp, DurationConstants::FORVER);
}
bool Receiver::fetch(Message ^ mmsgp, Duration ^ durationp)
{
- return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep),
- *((*durationp).durationp));
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep), dur);
}
+
+ //
+ // message = fetch()
+ //
+
+ Message ^ Receiver::fetch()
+ {
+ return fetch(DurationConstants::FORVER);
+ }
+
Message ^ Receiver::fetch(Duration ^ durationp)
{
- // allocate a message
- ::qpid::messaging::Message * msgp = new ::qpid::messaging::Message;
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Message * msgp = NULL;
+ Message ^ newMessage = nullptr;
+
+ try
+ {
+ // allocate a message
+ ::qpid::messaging::Message * msgp = new ::qpid::messaging::Message;
+
+ // translate the duration
+ ::qpid::messaging::Duration dur((*durationp).Milliseconds);
+
+ // get the message
+ *msgp = receiverp->::qpid::messaging::Receiver::fetch(dur);
+
+ // create new managed message with received message embedded in it
+ newMessage = gcnew Message(msgp);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Receiver:fetch unknown error");
- // get the message
- *msgp = receiverp->::qpid::messaging::Receiver::fetch(*((*durationp).durationp));
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (msgp != NULL)
+ {
+ delete msgp;
+ }
- // create new managed message with received message embedded in it
- Message ^ newMessage = gcnew Message(msgp);
+ throw newException;
+ }
+ }
return newMessage;
}
+ void Receiver::setCapacity(System::UInt32 capacity)
+ {
+ receiverp->setCapacity(capacity);
+ }
+
System::UInt32 Receiver::getCapacity()
{
return receiverp->getCapacity();
diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.h b/cpp/bindings/qpid/dotnet/src/Receiver.h
index ef2cf1a702..26d0402a3c 100644
--- a/cpp/bindings/qpid/dotnet/src/Receiver.h
+++ b/cpp/bindings/qpid/dotnet/src/Receiver.h
@@ -51,33 +51,39 @@ namespace messaging {
public ref class Receiver
{
private:
- // The kept object in the Messaging C++ DLL
- ::qpid::messaging::Receiver * receiverp;
-
// The session that created this Receiver
Session ^ parentSession;
- // Kept object lifetime flag
- bool disposed;
-
// Kept object deletion code
void Cleanup();
public:
+ // The kept object in the Messaging C++ DLL
+ ::qpid::messaging::Receiver * receiverp;
+
Receiver(::qpid::messaging::Receiver * r,
Session ^ sessRef);
~Receiver();
!Receiver();
Receiver(const Receiver ^ rhs);
+ // get(message)
bool get(Message ^ mmsgp);
bool get(Message ^ mmsgp, Duration ^ durationp);
+
+ // message = get()
+ Message ^ get();
Message ^ get(Duration ^ durationp);
+ // fetch(message)
bool fetch(Message ^ mmsgp);
- bool fetch(Message ^ mmsgp, Duration ^ durationp);
+ bool fetch(Message ^ mmsgp, Duration ^ duration);
+
+ // message = fetch()
+ Message ^ fetch();
Message ^ fetch(Duration ^ durationp);
+ void setCapacity(System::UInt32 capacity);
System::UInt32 getCapacity();
System::UInt32 getAvailable();
System::UInt32 getUnsettled();
diff --git a/cpp/bindings/qpid/dotnet/src/Sender.cpp b/cpp/bindings/qpid/dotnet/src/Sender.cpp
index 0550995970..1708359104 100644
--- a/cpp/bindings/qpid/dotnet/src/Sender.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Sender.cpp
@@ -28,7 +28,6 @@
#include "qpid/messaging/Message.h"
#include "Sender.h"
-#include "Session.h"
#include "Message.h"
namespace org {
@@ -79,9 +78,12 @@ namespace messaging {
}
}
+ //
+ // send(msg)
+ //
void Sender::send(Message ^ mmsgp)
{
- senderp->::qpid::messaging::Sender::send(*((*mmsgp).messagep));
+ send(mmsgp, false);
}
void Sender::send(Message ^ mmsgp, bool sync)
@@ -89,29 +91,10 @@ namespace messaging {
senderp->::qpid::messaging::Sender::send(*((*mmsgp).messagep), sync);
}
- void Sender::setCapacity(System::UInt32 capacity)
- {
- senderp->setCapacity(capacity);
- }
-
- System::UInt32 Sender::getCapacity()
- {
- return senderp->getCapacity();
- }
-
- System::UInt32 Sender::getUnsettled()
- {
- return senderp->getUnsettled();
- }
-
- System::UInt32 Sender::getAvailable()
- {
- return senderp->getAvailable();
- }
- System::String ^ Sender::getName()
+ void Sender::close()
{
- return gcnew System::String(senderp->getName().c_str());
+ senderp->close();
}
Session ^ Sender::getSession()
diff --git a/cpp/bindings/qpid/dotnet/src/Sender.h b/cpp/bindings/qpid/dotnet/src/Sender.h
index 482d434a55..17f7e822c4 100644
--- a/cpp/bindings/qpid/dotnet/src/Sender.h
+++ b/cpp/bindings/qpid/dotnet/src/Sender.h
@@ -65,13 +65,36 @@ namespace messaging {
!Sender();
Sender(const Sender % rhs);
+ // send(message)
void send(Message ^ mmsgp);
void send(Message ^ mmsgp, bool sync);
- void setCapacity(System::UInt32 capacity);
- System::UInt32 getCapacity();
- System::UInt32 getUnsettled();
- System::UInt32 getAvailable();
- System::String ^ getName();
+
+ void close();
+
+ property System::UInt32 Capacity
+ {
+ System::UInt32 get () { return senderp->getCapacity(); }
+ void set (System::UInt32 capacity) { senderp->setCapacity(capacity); }
+ }
+
+ property System::UInt32 Unsettled
+ {
+ System::UInt32 get () { return senderp->getUnsettled(); }
+ }
+
+ property System::UInt32 Available
+ {
+ System::UInt32 get () { return senderp->getAvailable(); }
+ }
+
+ property System::String ^ Name
+ {
+ System::String ^ get ()
+ {
+ return gcnew System::String(senderp->getName().c_str());
+ }
+ }
+
Session ^ getSession();
};
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/Session.cpp b/cpp/bindings/qpid/dotnet/src/Session.cpp
index 04db52988e..c070f10333 100644
--- a/cpp/bindings/qpid/dotnet/src/Session.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Session.cpp
@@ -24,6 +24,7 @@
#include <limits>
#include "qpid/messaging/Session.h"
+#include "qpid/messaging/exceptions.h"
#include "QpidMarshal.h"
#include "Session.h"
@@ -31,6 +32,8 @@
#include "Duration.h"
#include "Receiver.h"
#include "Sender.h"
+#include "Message.h"
+#include "QpidException.h"
namespace org {
namespace apache {
@@ -65,7 +68,7 @@ namespace messaging {
// copy constructor
Session::Session(const Session % rhs)
{
- sessionp = rhs.sessionp;
+ sessionp = rhs.sessionp;
parentConnectionp = rhs.parentConnectionp;
}
@@ -98,7 +101,7 @@ namespace messaging {
void Session::acknowledge()
{
- sessionp->acknowledge();
+ acknowledge(false);
}
void Session::acknowledge(bool sync)
@@ -106,9 +109,19 @@ namespace messaging {
sessionp->acknowledge(sync);
}
+ void Session::reject(Message ^ message)
+ {
+ sessionp->::qpid::messaging::Session::reject(*(message->messagep));
+ }
+
+ void Session::release(Message ^ message)
+ {
+ sessionp->::qpid::messaging::Session::release(*(message->messagep));
+ }
+
void Session::sync()
{
- sessionp->sync();
+ sync(true);
}
void Session::sync(bool block)
@@ -116,67 +129,291 @@ namespace messaging {
sessionp->sync(block);
}
- System::UInt32 Session::getReceivable()
+ // next(receiver)
+ bool Session::nextReceiver(Receiver ^ rcvr)
{
- return sessionp->getReceivable();
+ return nextReceiver(rcvr, DurationConstants::FORVER);
}
- System::UInt32 Session::getUnsettledAcks()
+ bool Session::nextReceiver(Receiver ^ rcvr, Duration ^ timeout)
{
- return sessionp->getUnsettledAcks();
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ ::qpid::messaging::Duration dur(timeout->Milliseconds);
+
+ return sessionp->nextReceiver(*(rcvr->receiverp), dur);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ if (errmsg = "No message to fetch")
+ {
+ // on timeout return null
+ return false;
+ }
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Session::nextReceiver unknown error");
+
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sessionp != NULL)
+ {
+ delete sessionp;
+ }
+
+ throw newException;
+ }
+ }
+ return true;
}
- //bool Session::nextReceiver(Receiver)
- //{
- // sessionp->nextReceiver(Receiver)
- //}
+ // receiver = next()
+ Receiver ^ Session::nextReceiver()
+ {
+ return nextReceiver(DurationConstants::FORVER);
+ }
- //bool Session::nextReceiver(Receiver, Duration timeout)
- //{
- // sessionp->nextReceiver();
- //}
+ Receiver ^ Session::nextReceiver(Duration ^ timeout)
+ {
+ System::Exception ^ newException = nullptr;
- //Receiver Session::nextReceiver(Duration timeout)
- //{
- //}
+ try
+ {
+ ::qpid::messaging::Duration dur(timeout->Milliseconds);
+ ::qpid::messaging::Receiver * rcvr = new ::qpid::messaging::Receiver;
+
+ *rcvr = sessionp->::qpid::messaging::Session::nextReceiver(dur);
+
+ Receiver ^ newRcvr = gcnew Receiver(rcvr, this);
+
+ return newRcvr;
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ if (errmsg = "No message to fetch")
+ {
+ // on timeout return null
+ return nullptr;
+ }
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Session::nextReceiver unknown error");
+
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sessionp != NULL)
+ {
+ delete sessionp;
+ }
+
+ throw newException;
+ }
+ }
+ return nullptr;
+ }
Sender ^ Session::createSender (System::String ^ address)
{
- // allocate a native sender
- ::qpid::messaging::Sender * senderp = new ::qpid::messaging::Sender;
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Sender * senderp = NULL;
+ Sender ^ newSender = nullptr;
+
+ try
+ {
+ // allocate a native sender
+ ::qpid::messaging::Sender * senderp = new ::qpid::messaging::Sender ;
- // create the sender
- *senderp = sessionp->::qpid::messaging::Session::createSender(QpidMarshal::ToNative(address));
+ // create the sender
+ *senderp = sessionp->::qpid::messaging::Session::createSender(QpidMarshal::ToNative(address));
- // create a managed sender
- Sender ^ newSender = gcnew Sender(senderp, this);
+ // create a managed sender
+ newSender = gcnew Sender(senderp, this);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Session::createSender unknown error");
+
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (senderp != NULL)
+ {
+ delete senderp;
+ }
+
+ throw newException;
+ }
+ }
return newSender;
}
Receiver ^ Session::createReceiver(System::String ^ address)
{
- // allocate a native receiver
- ::qpid::messaging::Receiver * receiverp = new ::qpid::messaging::Receiver;
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Receiver * receiverp = NULL;
+ Receiver ^ newReceiver = nullptr;
+
+ try
+ {
+ // allocate a native receiver
+ receiverp = new ::qpid::messaging::Receiver;
+
+ // create the receiver
+ *receiverp = sessionp->createReceiver(QpidMarshal::ToNative(address));
+
+ // create a managed receiver
+ newReceiver = gcnew Receiver(receiverp, this);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Session::createReceiver unknown error");
+
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sessionp != NULL)
+ {
+ delete sessionp;
+ }
+
+ throw newException;
+ }
+ }
+
+ return newReceiver;
+ }
+
+
+ Receiver ^ Session::createReceiver()
+ {
+ System::Exception ^ newException = nullptr;
+ ::qpid::messaging::Receiver * receiverp = NULL;
+ Receiver ^ newReceiver = nullptr;
- // create the receiver
- *receiverp = sessionp->createReceiver(QpidMarshal::ToNative(address));
+ try
+ {
+ // allocate a native receiver
+ receiverp = new ::qpid::messaging::Receiver;
- // create a managed receiver
- Receiver ^ newReceiver = gcnew Receiver(receiverp, this);
+ // create a managed receiver
+ newReceiver = gcnew Receiver(receiverp, this);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch (const std::exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+ catch ( ... )
+ {
+ newException = gcnew QpidException("Session::createReceiver unknown error");
+
+ }
+ finally
+ {
+ // Clean up and throw on caught exceptions
+ if (newException != nullptr)
+ {
+ if (sessionp != NULL)
+ {
+ delete sessionp;
+ }
+
+ throw newException;
+ }
+ }
return newReceiver;
}
- Connection ^ Session::getConnection()
+
+ Sender ^ Session::getSender(System::String ^ name)
{
- return parentConnectionp;
+ ::qpid::messaging::Sender * sender = new ::qpid::messaging::Sender;
+
+ *sender = sessionp->::qpid::messaging::Session::getSender(QpidMarshal::ToNative(name));
+
+ Sender ^ newSender = gcnew Sender(sender, this);
+
+ return newSender;
+ }
+
+
+
+ Receiver ^ Session::getReceiver(System::String ^ name)
+ {
+ ::qpid::messaging::Receiver * receiver = new ::qpid::messaging::Receiver;
+
+ *receiver = sessionp->::qpid::messaging::Session::getReceiver(QpidMarshal::ToNative(name));
+
+ Receiver ^ newReceiver = gcnew Receiver(receiver, this);
+
+ return newReceiver;
}
- bool Session::hasError()
+
+
+ Connection ^ Session::getConnection()
{
- return sessionp->hasError();
+ return parentConnectionp;
}
void Session::checkError()
diff --git a/cpp/bindings/qpid/dotnet/src/Session.h b/cpp/bindings/qpid/dotnet/src/Session.h
index 3d1230e0a6..3212f050c1 100644
--- a/cpp/bindings/qpid/dotnet/src/Session.h
+++ b/cpp/bindings/qpid/dotnet/src/Session.h
@@ -49,6 +49,7 @@ namespace messaging {
ref class Duration;
ref class Receiver;
ref class Sender;
+ ref class Message;
public ref class Session
{
@@ -74,20 +75,44 @@ namespace messaging {
void rollback();
void acknowledge();
void acknowledge(bool sync);
- //void reject(Message);
- //void release(Message);
+ void reject(Message ^);
+ void release(Message ^);
void sync();
void sync(bool block);
- System::UInt32 getReceivable();
- System::UInt32 getUnsettledAcks();
- //bool nextReceiver(Receiver);
- //bool nextReceiver(Receiver, Duration timeout);
- //Receiver nextReceiver(Duration timeout);
- //bool nextReceiver()
- Sender ^ createSender (System::String ^ address);
- Receiver ^ createReceiver(System::String ^ address);
+
+ property System::UInt32 Receivable
+ {
+ System::UInt32 get () { return sessionp->getReceivable(); }
+ }
+
+ property System::UInt32 UnsetledAcks
+ {
+ System::UInt32 get () { return sessionp->getUnsettledAcks(); }
+ }
+
+ // next(receiver)
+ bool nextReceiver(Receiver ^);
+ bool nextReceiver(Receiver ^, Duration ^ timeout);
+
+ // receiver = next()
+ Receiver ^ nextReceiver();
+ Receiver ^ nextReceiver(Duration ^ timeout);
+
+
+ Sender ^ createSender (System::String ^ address);
+ Receiver ^ createReceiver(System::String ^ address);
+ Receiver ^ createReceiver();
+
+ Sender ^ getSender(System::String ^ name);
+ Receiver ^ getReceiver(System::String ^ name);
+
Connection ^ getConnection();
- bool hasError();
+
+ property System::Boolean HasError
+ {
+ System::Boolean get () { return sessionp->hasError(); }
+ }
+
void checkError();
};
}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp b/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp
new file mode 100644
index 0000000000..3fbe1e204f
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp
@@ -0,0 +1,411 @@
+/*
+* 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.
+*/
+
+#include <windows.h>
+#include <msclr\lock.h>
+#include <oletx2xa.h>
+#include <typeinfo.h>
+#include <string>
+#include <limits>
+#include <iostream>
+
+#include "TypeTranslator.h"
+#include "QpidTypeCheck.h"
+#include "QpidMarshal.h"
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+ /// <summary>
+ /// Translate between managed and native types.
+ /// </summary>
+
+ //
+ // The given object is a Dictionary.
+ // Add its elements to the qpid map.
+ //
+ void TypeTranslator::ManagedToNative(::qpid::types::Variant::Map & theMapp,
+ QpidMap ^ theObjp)
+ {
+ // iterate the items, converting each to a variant and adding to the map
+ for each (System::Collections::Generic::KeyValuePair<System::String^, System::Object^> kvp in theObjp)
+ {
+ if (QpidTypeCheck::ObjectIsMap(kvp.Value))
+ {
+ // Recurse on inner map
+ // Allocate a map
+ ::qpid::types::Variant::Map newMap;
+
+ // Add the map variables to the map
+ ManagedToNative(newMap, (QpidMap ^)kvp.Value);
+
+ // Create a variant entry for the inner map
+ std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newMap));
+
+ // Get map's name
+ std::string entryName = QpidMarshal::ToNative(kvp.Key);
+
+ // Add inner map to outer map
+ theMapp.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, *newVariantp));
+ }
+ else if (QpidTypeCheck::ObjectIsList(kvp.Value))
+ {
+ // Recurse on inner list
+ // Allocate a list
+ ::qpid::types::Variant::List newList;
+
+ // Add the List variables to the list
+ ManagedToNative(newList, (QpidList ^)kvp.Value);
+
+ // Create a variant entry for the inner map
+ ::qpid::types::Variant::List newVariant(newList);
+
+ //std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newList));
+
+ // Get list's name
+ std::string entryName = QpidMarshal::ToNative(kvp.Key);
+
+ // Add inner list to outer map
+ theMapp.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, newVariant));
+ }
+ else
+ {
+ // Add a simple native type to map
+ ::qpid::types::Variant entryValue;
+ ManagedToNativeObject(kvp.Value, entryValue);
+ std::string entryName = QpidMarshal::ToNative(kvp.Key);
+ theMapp.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, entryValue));
+ }
+ }
+ }
+
+
+
+ //
+ // The given object is a List.
+ // Add its elements to the qpid list.
+ //
+ void TypeTranslator::ManagedToNative(::qpid::types::Variant::List & theListp,
+ QpidList ^ theObjp)
+ {
+ // iterate the items, converting each to a variant and adding to the map
+ for each (System::Object ^ listObj in theObjp)
+ {
+ if (QpidTypeCheck::ObjectIsMap(listObj))
+ {
+ // Recurse on inner map
+ // Allocate a map
+ ::qpid::types::Variant::Map newMap;
+
+ // Add the map variables to the map
+ ManagedToNative(newMap, (QpidMap ^)listObj);
+
+ // Create a variant entry for the inner map
+ std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newMap));
+
+ // Add inner map to outer list
+ theListp.push_back(*newVariantp);
+ }
+ else if (QpidTypeCheck::ObjectIsList(listObj))
+ {
+ // Recurse on inner list
+ // Allocate a list
+ ::qpid::types::Variant::List newList;
+
+ // Add the List variables to the list
+ ManagedToNative(newList, (QpidList ^)listObj);
+
+ // Create a variant entry for the inner list
+ std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newList));
+
+ // Add inner list to outer list
+ theListp.push_back(*newVariantp);
+ }
+ else
+ {
+ // Add a simple native type to list
+ ::qpid::types::Variant entryValue;
+ ManagedToNativeObject(listObj, entryValue);
+ theListp.push_back(entryValue);
+ }
+ }
+ }
+
+
+
+ //
+ // Returns a variant representing simple native type object.
+ // Not to be called for Map/List objects.
+ //
+ void TypeTranslator::ManagedToNativeObject(System::Object ^ theObjp,
+ ::qpid::types::Variant & targetp)
+ {
+ System::Type ^ typeP = (*theObjp).GetType();
+ System::TypeCode typeCode = System::Type::GetTypeCode( typeP );
+
+ switch (typeCode)
+ {
+ case System::TypeCode::Boolean :
+ targetp = System::Convert::ToBoolean(theObjp);
+ break;
+
+ case System::TypeCode::Byte :
+ targetp = System::Convert::ToByte(theObjp);
+ break;
+
+ case System::TypeCode::UInt16 :
+ targetp = System::Convert::ToUInt16(theObjp);
+ break;
+
+ case System::TypeCode::UInt32 :
+ targetp = System::Convert::ToUInt32(theObjp);
+ break;
+
+ case System::TypeCode::UInt64 :
+ targetp = System::Convert::ToUInt64(theObjp);
+ break;
+
+ case System::TypeCode::Char :
+ case System::TypeCode::SByte :
+ targetp = System::Convert::ToSByte(theObjp);
+ break;
+
+ case System::TypeCode::Int16 :
+ targetp = System::Convert::ToInt16(theObjp);
+ break;
+
+ case System::TypeCode::Int32 :
+ targetp = System::Convert::ToInt32(theObjp);
+ break;
+
+ case System::TypeCode::Int64 :
+ targetp = System::Convert::ToInt64(theObjp);
+ break;
+
+ case System::TypeCode::Single :
+ targetp = System::Convert::ToSingle(theObjp);
+ break;
+
+ case System::TypeCode::Double :
+ targetp = System::Convert::ToDouble(theObjp);
+ break;
+
+ case System::TypeCode::String :
+ {
+ std::string rString;
+ System::String ^ rpString;
+
+ rpString = System::Convert::ToString(theObjp);
+ rString = QpidMarshal::ToNative(rpString);
+ targetp = rString;
+ targetp.setEncoding(QpidMarshal::ToNative("utf8"));
+ }
+ break;
+
+
+ default:
+
+ throw gcnew System::NotImplementedException();
+
+ }
+ }
+
+
+ // Given a user Dictionary and a qpid map,
+ // extract the qpid elements and put them into the dictionary.
+ //
+ void TypeTranslator::NativeToManaged(QpidMap ^ dict, ::qpid::types::Variant::Map & map)
+ {
+ // For each object in the message map,
+ // create a .NET object and add it to the dictionary.
+ for (::qpid::types::Variant::Map::const_iterator i = map.begin(); i != map.end(); ++i) {
+ // Get the name
+ System::String ^ elementName = gcnew String(i->first.c_str());
+
+ ::qpid::types::Variant variant = i->second;
+ ::qpid::types::VariantType vType = variant.getType();
+
+ switch (vType)
+ {
+ case ::qpid::types::VAR_BOOL:
+ dict[elementName] = variant.asBool();
+ break;
+
+ case ::qpid::types::VAR_UINT8:
+ dict[elementName] = variant.asUint8();
+ break;
+
+ case ::qpid::types::VAR_UINT16:
+ dict[elementName] = variant.asUint16();
+ break;
+
+ case ::qpid::types::VAR_UINT32:
+ dict[elementName] = variant.asUint32();
+ break;
+
+ case ::qpid::types::VAR_UINT64:
+ dict[elementName] = variant.asUint64();
+ break;
+
+ case ::qpid::types::VAR_INT8:
+ dict[elementName] = variant.asInt8();
+ break;
+
+ case ::qpid::types::VAR_INT16:
+ dict[elementName] = variant.asInt16();
+ break;
+
+ case ::qpid::types::VAR_INT32:
+ dict[elementName] = variant.asInt32();
+ break;
+
+ case ::qpid::types::VAR_INT64:
+ dict[elementName] = variant.asInt64();
+ break;
+
+ case ::qpid::types::VAR_FLOAT:
+ dict[elementName] = variant.asFloat();
+ break;
+
+ case ::qpid::types::VAR_DOUBLE:
+ dict[elementName] = variant.asDouble();
+ break;
+
+ case ::qpid::types::VAR_STRING:
+ {
+ System::String ^ elementValue = gcnew System::String(variant.asString().c_str());
+ dict[elementName] = elementValue;
+ break;
+ }
+ case ::qpid::types::VAR_MAP:
+ {
+ QpidMap ^ newDict = gcnew QpidMap();
+
+ NativeToManaged(newDict, variant.asMap());
+
+ dict[elementName] = newDict;
+ break;
+ }
+
+ case ::qpid::types::VAR_LIST:
+ {
+ QpidList ^ newList = gcnew QpidList();
+
+ NativeToManaged(newList, variant.asList());
+
+ dict[elementName] = newList;
+ break;
+ }
+
+ case ::qpid::types::VAR_UUID:
+ break;
+ }
+ }
+ }
+
+
+ void TypeTranslator::NativeToManaged(QpidList ^ vList, ::qpid::types::Variant::List & qpidList)
+ {
+ // For each object in the message map,
+ // create a .NET object and add it to the dictionary.
+ for (::qpid::types::Variant::List::const_iterator i = qpidList.begin(); i != qpidList.end(); ++i)
+ {
+ ::qpid::types::Variant variant = *i;
+ ::qpid::types::VariantType vType = variant.getType();
+
+ switch (vType)
+ {
+ case ::qpid::types::VAR_BOOL:
+ (*vList).Add(variant.asBool());
+ break;
+
+ case ::qpid::types::VAR_UINT8:
+ (*vList).Add(variant.asUint8());
+ break;
+
+ case ::qpid::types::VAR_UINT16:
+ (*vList).Add(variant.asUint16());
+ break;
+
+ case ::qpid::types::VAR_UINT32:
+ (*vList).Add(variant.asUint32());
+ break;
+
+ case ::qpid::types::VAR_UINT64:
+ (*vList).Add(variant.asUint64());
+ break;
+
+ case ::qpid::types::VAR_INT8:
+ (*vList).Add(variant.asInt8());
+ break;
+
+ case ::qpid::types::VAR_INT16:
+ (*vList).Add(variant.asInt16());
+ break;
+
+ case ::qpid::types::VAR_INT32:
+ (*vList).Add(variant.asInt32());
+ break;
+
+ case ::qpid::types::VAR_INT64:
+ (*vList).Add(variant.asInt64());
+ break;
+
+ case ::qpid::types::VAR_FLOAT:
+ (*vList).Add(variant.asFloat());
+ break;
+
+ case ::qpid::types::VAR_DOUBLE:
+ (*vList).Add(variant.asDouble());
+ break;
+
+ case ::qpid::types::VAR_STRING:
+ {
+ System::String ^ elementValue = gcnew System::String(variant.asString().c_str());
+ (*vList).Add(elementValue);
+ break;
+ }
+ case ::qpid::types::VAR_MAP:
+ {
+ QpidMap ^ newDict = gcnew QpidMap();
+
+ NativeToManaged(newDict, variant.asMap());
+
+ (*vList).Add(newDict);
+ break;
+ }
+
+ case ::qpid::types::VAR_LIST:
+ {
+ QpidList ^ newList = gcnew QpidList();
+
+ NativeToManaged(newList, variant.asList());
+
+ (*vList).Add(newList);
+ break;
+ }
+
+ case ::qpid::types::VAR_UUID:
+ break;
+ }
+ }
+ }
+}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/TypeTranslator.h b/cpp/bindings/qpid/dotnet/src/TypeTranslator.h
new file mode 100644
index 0000000000..7ffba69614
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/TypeTranslator.h
@@ -0,0 +1,70 @@
+/*
+* 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.
+*/
+#pragma once
+
+#include <windows.h>
+#include <msclr\lock.h>
+#include <oletx2xa.h>
+#include <string>
+#include <limits>
+
+#include "qpid/types/Variant.h"
+
+#include "QpidTypeCheck.h"
+
+namespace org {
+namespace apache {
+namespace qpid {
+namespace messaging {
+
+ /// <summary>
+ /// TypeTranslator provides codec between .NET Dictionary/List and
+ /// qpid messaging Map/List.
+ /// </summary>
+
+ public ref class TypeTranslator
+ {
+
+ public:
+ // The given object is a Dictionary.
+ // Add its elements to the qpid map.
+ static void ManagedToNative(::qpid::types::Variant::Map & theMapp,
+ QpidMap ^ theObjp);
+
+ // The given object is a List.
+ // Add its elements to the qpid list.
+ static void ManagedToNative(::qpid::types::Variant::List & theListp,
+ QpidList ^ theObjp);
+
+ // The given object is a simple native type (not a Dictionary or List)
+ // Returns a variant representing simple native type object.
+ static void ManagedToNativeObject(System::Object ^ theObjp,
+ ::qpid::types::Variant & targetp);
+
+ // Given a Dictionary,
+ // Return its values in a Qpid map
+ static void NativeToManaged(QpidMap ^ dict,
+ ::qpid::types::Variant::Map & map);
+
+ // Given a List,
+ // Return its values in a Qpid list
+ static void NativeToManaged(QpidList ^ vList,
+ ::qpid::types::Variant::List & qpidList);
+ };
+}}}}
diff --git a/cpp/bindings/qpid/dotnet/src/app.rc b/cpp/bindings/qpid/dotnet/src/app.rc
index b3f0d67631..8c1d64009c 100644
--- a/cpp/bindings/qpid/dotnet/src/app.rc
+++ b/cpp/bindings/qpid/dotnet/src/app.rc
@@ -20,6 +20,7 @@
LANGUAGE 9, 1
#pragma code_page(1252)
+1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
diff --git a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc
new file mode 100644
index 0000000000..0e47baec7e
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc
@@ -0,0 +1,101 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource1.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource1.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,3,0,1
+ PRODUCTVERSION 1,3,0,1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "org"
+ VALUE "FileVersion", "1, 3, 0, 1"
+ VALUE "InternalName", "org"
+ VALUE "LegalCopyright", "Copyright (C) 2010"
+ VALUE "OriginalFilename", "org.apache.qpid.messaging"
+ VALUE "ProductName", "org"
+ VALUE "ProductVersion", "1, 3, 0, 1"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj
index e8e4bc695e..3f5861b7fe 100644
--- a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj
+++ b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj
@@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
AdditionalOptions=" /Zm1000 /wd4244 /wd4800 /wd4355"
Optimization="0"
- AdditionalIncludeDirectories="&quot;$(QPID_BUILD_ROOT)\include&quot;;&quot;$(QPID_BUILD_ROOT)\src&quot;"
+ AdditionalIncludeDirectories="&quot;$(ProjectDir)..\..\..\..\include&quot;;&quot;$(ProjectDir)..\..\..\..\src&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;WIN32_LEAN_AND_MEAN"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
@@ -63,12 +63,13 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions=" /STACK:10000000 /machine:I386"
- AdditionalDependencies="$(QPID_BUILD_ROOT)\src\Debug\qpidclientd.lib $(QPID_BUILD_ROOT)\src\Debug\qpidcommond.lib"
- OutputFile="$(OutDir)\org.apache.qpid.messagingd.dll"
+ AdditionalDependencies="$(ProjectDir)..\..\..\..\src\Debug\qpidclientd.lib $(ProjectDir)..\..\..\..\src\Debug\qpidcommond.lib $(ProjectDir)..\..\..\..\src\Debug\qpidmessagingd.lib"
+ OutputFile="$(ProjectDir)..\..\..\..\src\$(ConfigurationName)\org.apache.qpid.messagingd.dll"
LinkIncremental="1"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="1"
+ KeyFile="qpid.snk"
/>
<Tool
Name="VCALinkTool"
@@ -90,6 +91,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
+ CommandLine=""
/>
</Configuration>
<Configuration
@@ -188,15 +190,15 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
- RelativePath=".\AssemblyInfo.cpp"
+ RelativePath=".\Address.cpp"
>
</File>
<File
- RelativePath=".\Connection.cpp"
+ RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
- RelativePath=".\Duration.cpp"
+ RelativePath=".\Connection.cpp"
>
</File>
<File
@@ -215,6 +217,10 @@
RelativePath=".\Session.cpp"
>
</File>
+ <File
+ RelativePath=".\TypeTranslator.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
@@ -222,6 +228,10 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
+ RelativePath=".\Address.h"
+ >
+ </File>
+ <File
RelativePath=".\Connection.h"
>
</File>
@@ -238,6 +248,10 @@
>
</File>
<File
+ RelativePath=".\QpidTypeCheck.h"
+ >
+ </File>
+ <File
RelativePath=".\Receiver.h"
>
</File>
@@ -249,6 +263,10 @@
RelativePath=".\Session.h"
>
</File>
+ <File
+ RelativePath=".\TypeTranslator.h"
+ >
+ </File>
</Filter>
<Filter
Name="Resource Files"
@@ -260,11 +278,11 @@
>
</File>
<File
- RelativePath=".\app.rc"
+ RelativePath=".\org.apache.qpid.messaging.rc"
>
</File>
<File
- RelativePath=".\resource.h"
+ RelativePath=".\resource1.h"
>
</File>
</Filter>
diff --git a/cpp/bindings/qpid/dotnet/src/qpid.snk b/cpp/bindings/qpid/dotnet/src/qpid.snk
new file mode 100644
index 0000000000..9faafd8f8b
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/qpid.snk
Binary files differ
diff --git a/cpp/bindings/qpid/dotnet/src/resource1.h b/cpp/bindings/qpid/dotnet/src/resource1.h
new file mode 100644
index 0000000000..96a2cb7ead
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/resource1.h
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by org.apache.qpid.messaging.rc
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs b/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..57f83add20
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+/*
+* 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("org.apache.qpid.messaging.sessionreceiver")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("org.apache.qpid.messaging.sessionreceiver")]
+[assembly: AssemblyCopyright("Copyright © 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e18f363a-a9b0-4251-8f3c-de0e9d9d6827")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/cpp/bindings/qpid/dotnet/src/sessionreceiver/org.apache.qpid.messaging.sessionreceiver.csproj b/cpp/bindings/qpid/dotnet/src/sessionreceiver/org.apache.qpid.messaging.sessionreceiver.csproj
new file mode 100644
index 0000000000..0021a15908
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/sessionreceiver/org.apache.qpid.messaging.sessionreceiver.csproj
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{B0A51CEC-30A2-4C2E-90BE-AE95107EAA05}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>org.apache.qpid.messaging.sessionreceiver</RootNamespace>
+ <AssemblyName>org.apache.qpid.messaging.sessionreceiver</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="sessionreceiver.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
diff --git a/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs b/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs
new file mode 100644
index 0000000000..73956ecdef
--- /dev/null
+++ b/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs
@@ -0,0 +1,133 @@
+/*
+ *
+ * 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.Linq;
+using System.Text;
+using org.apache.qpid.messaging;
+
+namespace org.apache.qpid.messaging.sessionreceiver
+{
+ /// <summary>
+ /// ISessionReceiver interface defines the callback for users to supply.
+ /// Once established this callback will receive all messages for all
+ /// receivers defined by the current session.
+ /// Users are expected not to 'fetch' or 'get' messages by any other means.
+ /// Users must acknowledge() the Session's messages either in the callback
+ /// function or by some other scheme.
+ /// </summary>
+
+ public interface ISessionReceiver
+ {
+ void SessionReceiver(Receiver receiver, Message message);
+ }
+
+
+ /// <summary>
+ /// eventEngine - wait for messages from the underlying C++ code.
+ /// When available get them and deliver them via callback to our
+ /// client through the ISessionReceiver interface.
+ /// This class consumes the thread that calls the Run() function.
+ /// </summary>
+
+ internal class eventEngine
+ {
+ private Session session;
+ private ISessionReceiver callback;
+ private bool keepRunning;
+
+ public eventEngine(Session theSession, ISessionReceiver thecallback)
+ {
+ this.session = theSession;
+ this.callback = thecallback;
+ }
+
+ /// <summary>
+ /// Function to call Session's nextReceiver, discover messages,
+ /// and to deliver messages through the callback.
+ /// </summary>
+ public void open()
+ {
+ Receiver rcvr = session.createReceiver();
+ Message msg;
+
+ keepRunning = true;
+ while (keepRunning)
+ {
+ if (session.nextReceiver(rcvr, DurationConstants.SECOND))
+ {
+ if (keepRunning)
+ {
+ msg = rcvr.fetch(DurationConstants.SECOND);
+ this.callback.SessionReceiver(rcvr, msg);
+ }
+ }
+ //else
+ // receive timed out
+ // eventEngine exits the nextReceiver() function periodically
+ // in order to test the keepRunning flag
+ }
+ // Private thread is now exiting.
+ }
+
+ /// <summary>
+ /// Function to stop the eventEngine. Private thread will exit within
+ /// one second.
+ /// </summary>
+ public void close()
+ {
+ keepRunning = false;
+ }
+ }
+
+
+ /// <summary>
+ /// server is the class that users instantiate to connect a SessionReceiver
+ /// callback to the stream of received messages received on a Session.
+ /// </summary>
+ public class server
+ {
+ private eventEngine ee;
+
+ /// <summary>
+ /// Constructor for the server.
+ /// </summary>
+ /// <param name="session">The Session whose messages are collected.</param>
+ /// <param name="callback">The user function call with each message.</param>
+ ///
+ public server(Session session, ISessionReceiver callback)
+ {
+ ee = new eventEngine(session, callback);
+
+ new System.Threading.Thread(
+ new System.Threading.ThreadStart(ee.open)).Start();
+ }
+
+ /// <summary>
+ /// Function to stop the server.
+ /// </summary>
+ public void close()
+ {
+ ee.close();
+ }
+ }
+}
diff --git a/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs b/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs
index 63a85486d3..5d161728e5 100644
--- a/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs
+++ b/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs
@@ -12,27 +12,77 @@ namespace org.apache.qpid.messaging
{
//
// Duration test - stub until proper nunit tests are ready...
- //
+
Duration myDuration = new Duration(1234);
Console.WriteLine("Duration should be : 1234, is : {0}",
- myDuration.getMilliseconds());
+ myDuration.Milliseconds);
Console.WriteLine("Duration FOREVER should be : 1.8x10^19 (realbig), is : {0}",
- myDuration.FOREVER());
+ DurationConstants.FORVER.Milliseconds);
Console.WriteLine("Duration IMMEDIATE should be : 0, is : {0}",
- myDuration.IMMEDIATE());
+ DurationConstants.IMMEDIATE.Milliseconds);
Console.WriteLine("Duration SECOND should be : 1,000, is : {0}",
- myDuration.SECOND());
+ DurationConstants.SECOND.Milliseconds);
Console.WriteLine("Duration MINUTE should be : 60,000, is : {0}",
- myDuration.MINUTE());
+ DurationConstants.MINUTE.Milliseconds);
+
+ Duration isInfinite = new Duration();
+ Console.WriteLine("Duration() should be : realbig, is : {0}",
+ isInfinite.Milliseconds);
+
+ Duration fiveMinutes = new Duration(DurationConstants.MINUTE.Milliseconds * 5);
+ Console.WriteLine("Duration 5MINUTE should be : 300,000, is : {0}",
+ fiveMinutes.Milliseconds);
+
+ Duration fiveSec = DurationConstants.SECOND * 5;
+ Console.WriteLine("Duration 5SECOND should be : 5,000 is : {0}",
+ fiveSec.Milliseconds);
//
// and so on
//
+
+ Dictionary<string, object> dx = new Dictionary<string, object>();
+
+ Console.WriteLine("Dictionary.GetType() {0}", dx.GetType());
+
+ //
+ // Address test
+ //
+ Address aEmpty = new Address();
+ Address aStr = new Address("rare");
+
+ Dictionary<string, object> options = new Dictionary<string,object>();
+ options["one"] = 1;
+ options["two"] = "two";
+
+ Address aSubj = new Address("rare2", "subj", options);
+
+ Address aType = new Address ("check3", "subj", options, "hot");
+
+ Console.WriteLine("aEmpty : {0}", aEmpty.str());
+ Console.WriteLine("aStr : {0}", aStr.str());
+ Console.WriteLine("aSubj : {0}", aSubj.str());
+ Console.WriteLine("aType : {0}", aType.str());
+
+ //
+ // Raw message data retrieval
+ //
+
+ Message m2 = new Message("rarey");
+ UInt64 m2Size = m2.getContentSize();
+
+
+ byte[] myRaw = new byte [m2Size];
+
+ m2.getRaw(myRaw);
+ Console.WriteLine("Got raw array size {0}", m2Size);
+ for (UInt64 i = 0; i < m2Size; i++)
+ Console.Write("{0} ", myRaw[i].ToString());
}
}
}
diff --git a/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.csproj b/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.csproj
index 0c9d6af140..08c0147640 100644
--- a/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.csproj
+++ b/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.csproj
@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\..\..\..\..\src\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -31,10 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="org.apache.qpid.messagingd, Version=1.0.3779.23054, Culture=neutral, PublicKeyToken=679e1f50b62dbace, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\bin\Debug\org.apache.qpid.messagingd.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -52,6 +48,12 @@
<Compile Include="messaging.test.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\org.apache.qpid.messaging.vcproj">
+ <Project>{AA5A3B83-5F98-406D-A01C-5A921467A57D}</Project>
+ <Name>org.apache.qpid.messaging</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -60,4 +62,10 @@
<Target Name="AfterBuild">
</Target>
-->
+ <PropertyGroup>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ </PropertyGroup>
</Project>