From 44f216bac3eee821849d1bdcc97026ff3ec699a6 Mon Sep 17 00:00:00 2001 From: markpollack Date: Tue, 5 Aug 2008 07:58:27 +0000 Subject: [PATCH] Add initial NMS QuickStart application. Minor bug fix in NMS listener 'VisualSVN' add-in updated files excludes on Spring Core, Aop, Data. --- .../Spring.NmsQuickStart.Client/App.config | 44 ++++++ .../Config/Application.xml | 15 +++ .../Config/Messaging.xml | 68 ++++++++++ .../Gateways/IStockServiceGateway.cs | 31 +++++ .../Gateways/NmsStockServiceGateway.cs | 43 ++++++ .../Handlers/StockAppHandler.cs | 48 +++++++ .../Spring.NmsQuickStart.Client/Program.cs | 46 +++++++ .../Properties/AssemblyInfo.cs | 33 +++++ .../Properties/Resources.Designer.cs | 71 ++++++++++ .../Properties/Resources.resx | 117 ++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Properties/Settings.settings | 7 + .../Spring.NmsQuickStart.Client.csproj | 125 +++++++++++++++++ .../UI/StockController.cs | 55 ++++++++ .../UI/StockForm.cs | 61 +++++++++ .../UI/StockForm.designer.cs | 126 ++++++++++++++++++ .../UI/StockForm.resx | 120 +++++++++++++++++ .../Spring.NmsQuickStart.Common/Bo/Trade.cs | 40 ++++++ .../Bo/TradeRequest.cs | 97 ++++++++++++++ .../AbstractNamedMessageConverter.cs | 30 +++++ .../Converters/INamedMessageConverter.cs | 34 +++++ .../Converters/MultiMessageConverter.cs | 110 +++++++++++++++ .../Converters/TradeConverter.cs | 61 +++++++++ .../Converters/TradeRequestConverter.cs | 69 ++++++++++ .../Properties/AssemblyInfo.cs | 35 +++++ .../Spring.NmsQuickStart.Common.csproj | 79 +++++++++++ .../Spring.NmsQuickStart.Server/App.config | 44 ++++++ .../Config/Messaging.xml | 39 ++++++ .../Config/Services.xml | 8 ++ .../Handlers/StockAppHandler.cs | 20 +++ .../Spring.NmsQuickStart.Server/Program.cs | 26 ++++ .../Properties/AssemblyInfo.cs | 33 +++++ .../Spring.NmsQuickStart.Server.csproj | 97 ++++++++++++++ ...msQuickStart.Integration.Tests.2005.csproj | 41 ++++++ .../Spring.NmsQuickStart.Tests.2005.csproj | 41 ++++++ .../Messaging/Nms/Core/NmsGatewaySupport.cs | 2 +- .../Adapter/MessageListenerAdapter.cs | 2 +- .../Support/Converter/IMessageConverter.cs | 4 +- .../Converter/SimpleMessageConverter.cs | 48 +++---- 39 files changed, 1972 insertions(+), 28 deletions(-) create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/App.config create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Application.xml create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Messaging.xml create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/IStockServiceGateway.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/NmsStockServiceGateway.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/AssemblyInfo.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.Designer.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.resx create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.Designer.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.settings create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockController.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.designer.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.resx create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/Trade.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/TradeRequest.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/AbstractNamedMessageConverter.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/INamedMessageConverter.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/MultiMessageConverter.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeConverter.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeRequestConverter.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Properties/AssemblyInfo.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/App.config create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Messaging.xml create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Services.xml create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/StockAppHandler.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Program.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Properties/AssemblyInfo.cs create mode 100644 examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj create mode 100644 examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Integration.Tests/Spring.NmsQuickStart.Integration.Tests.2005.csproj create mode 100644 examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Tests/Spring.NmsQuickStart.Tests.2005.csproj diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/App.config b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/App.config new file mode 100644 index 00000000..e555b49b --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/App.config @@ -0,0 +1,44 @@ + + + + + + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Application.xml b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Application.xml new file mode 100644 index 00000000..d5673437 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Application.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Messaging.xml b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Messaging.xml new file mode 100644 index 00000000..7a3bcbc5 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Config/Messaging.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/IStockServiceGateway.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/IStockServiceGateway.cs new file mode 100644 index 00000000..16fe7817 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/IStockServiceGateway.cs @@ -0,0 +1,31 @@ + + +#region License + +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed 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. + */ + +#endregion + +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Client.Gateways +{ + public interface IStockServiceGateway + { + void Send(TradeRequest tradeRequest); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/NmsStockServiceGateway.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/NmsStockServiceGateway.cs new file mode 100644 index 00000000..8c8643f3 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Gateways/NmsStockServiceGateway.cs @@ -0,0 +1,43 @@ + + + +using Apache.NMS; +using Spring.Messaging.Nms.Core; +using Spring.NmsQuickStart.Common.Bo; +using Spring.Objects.Factory; + +namespace Spring.NmsQuickStart.Client.Gateways +{ + public class NmsStockServiceGateway : NmsGatewaySupport, IStockServiceGateway, IInitializingObject + { + private IDestination defaultReplyToQueue; + + public IDestination DefaultReplyToQueue + { + set { defaultReplyToQueue = value; } + } + + public void Send(TradeRequest tradeRequest) + { + NmsTemplate.ConvertAndSend(tradeRequest, new ReplyToPostProcessor(defaultReplyToQueue)); + } + + + public class ReplyToPostProcessor : IMessagePostProcessor + { + private IDestination replyToDestination; + + public ReplyToPostProcessor(IDestination replyToDestination) + { + this.replyToDestination = replyToDestination; + } + + public IMessage PostProcessMessage(IMessage message) + { + message.NMSReplyTo = replyToDestination; + return message; + } + } + + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs new file mode 100644 index 00000000..18ae4536 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Handlers/StockAppHandler.cs @@ -0,0 +1,48 @@ + + +using System.Collections; +using Common.Logging; +using Spring.NmsQuickStart.Client.UI; +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Client.Handlers +{ + public class StockAppHandler + { + #region Logging Definition + + private readonly ILog log = LogManager.GetLogger(typeof(StockAppHandler)); + + #endregion + + private StockController stockController; + + + public StockController StockController + { + get { return stockController; } + set { stockController = value; } + } + + public void HandleObject(IDictionary data) + { + log.Info(string.Format("Received market data. Ticker = {0}, Price = {1}", data["TICKER"], data["PRICE"])); + + // forward to controller to update view + stockController.UpdateMarketData(data); + + } + + + public void Handle(Trade trade) + { + log.Info(string.Format("Received trade. Ticker = {0}, Price = {1}", trade.Ticker, trade.Price)); + stockController.UpdateTrade(trade); + } + + public void Handle(object catchAllObject) + { + log.Error("could not handle object of type = " + catchAllObject.GetType()); + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs new file mode 100644 index 00000000..48e5e208 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Program.cs @@ -0,0 +1,46 @@ +using System; +using System.Threading; +using System.Windows.Forms; +using Common.Logging; +using Spring.Context; +using Spring.Context.Support; +using Spring.NmsQuickStart.Client.UI; + +namespace Spring.NmsQuickStart.Client +{ + static class Program + { + + private static readonly ILog log = LogManager.GetLogger(typeof(Program)); + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + try + { + log.Info("Running...."); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + using (IApplicationContext ctx = ContextRegistry.GetContext()) + { + StockForm stockForm = new StockForm(); + Application.ThreadException += ThreadException; + Application.Run(stockForm); + } + } + catch (Exception e) + { + log.Error("Spring.NmsQuickStart.Client is broken.", e); + } + } + + private static void ThreadException(object sender, ThreadExceptionEventArgs e) + { + log.Error("Uncaught application exception.", e.Exception); + Application.Exit(); + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/AssemblyInfo.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..86613eb5 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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("Spring.NmsQuickStart.Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Spring.NmsQuickStart.Client")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[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("aff1d9ab-7818-4748-8234-8a78e5631899")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.Designer.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.Designer.cs new file mode 100644 index 00000000..6008ff55 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Spring.NmsQuickStart.Client.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Spring.NmsQuickStart.Client.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.resx b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.resx new file mode 100644 index 00000000..ffecec85 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.Designer.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.Designer.cs new file mode 100644 index 00000000..fbeb6f7c --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1433 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Spring.NmsQuickStart.Client.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.settings b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.settings new file mode 100644 index 00000000..abf36c5d --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj new file mode 100644 index 00000000..f4f47d6c --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/Spring.NmsQuickStart.Client.csproj @@ -0,0 +1,125 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {87D0B725-A652-4A6B-A95F-197F7155769F} + WinExe + Properties + Spring.NmsQuickStart.Client + Spring.NmsQuickStart.Client + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\..\lib\Net\2.0\Apache.NMS.dll + + + False + ..\..\..\..\..\..\lib\Net\2.0\Apache.NMS.ActiveMQ.dll + + + False + ..\..\..\..\..\..\lib\Net\2.0\Common.Logging.dll + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + StockForm.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + Form + + + StockForm.cs + + + + + {3A3A4E65-45A6-4B20-B460-0BEDC302C02C} + Spring.Aop.2005 + + + {710961A3-0DF4-49E4-A26E-F5B9C044AC84} + Spring.Core.2005 + + + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40} + Spring.Data.2005 + + + {AEB1578C-9018-4D49-B440-789F38DD2F29} + Spring.Messaging.Nms.2005 + + + {AC5A3035-75DD-48E5-ABCA-38FBC8193F22} + Spring.NmsQuickStart.Common + + + + + Always + + + Always + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockController.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockController.cs new file mode 100644 index 00000000..d6af97a7 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockController.cs @@ -0,0 +1,55 @@ + + +using System.Collections; +using Spring.NmsQuickStart.Client.Gateways; +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Client.UI +{ + public class StockController + { + private StockForm stockForm; + + private IStockServiceGateway stockServiceGateway; + + + + public StockForm StockForm + { + get { return stockForm; } + set { stockForm = value; } + } + + public IStockServiceGateway StockServiceGateway + { + get { return stockServiceGateway; } + set { stockServiceGateway = value; } + } + + public void SendTradeRequest() + { + TradeRequest tradeRequest = new TradeRequest(); + tradeRequest.AccountName = "ACCT-123"; + tradeRequest.BuyRequest = true; + tradeRequest.OrderType = "MARKET"; + tradeRequest.Quantity = 314000000; + tradeRequest.RequestId = "REQ-1"; + tradeRequest.Ticker = "CSCO"; + tradeRequest.UserName = "Joe Trader"; + + stockServiceGateway.Send(tradeRequest); + } + + + public void UpdateMarketData(IDictionary marketDataDict) + { + stockForm.UpdateMarketData(marketDataDict); + } + + public void UpdateTrade(Trade trade) + { + stockForm.UpdateTrade(trade); + } + + } +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs new file mode 100644 index 00000000..899a2a36 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections; +using System.Windows.Forms; +using Common.Logging; +using Spring.Context.Support; +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Client.UI +{ + public partial class StockForm : Form + { + #region Logging Definition + + private static readonly ILog log = LogManager.GetLogger(typeof (StockForm)); + + #endregion + + private StockController stockController; + + public StockForm() + { + InitializeComponent(); + stockController = ContextRegistry.GetContext()["StockController"] as StockController; + stockController.StockForm = this; + } + + public StockController Controller + { + set { stockController = value; } + } + + private void OnSendTradeRequest(object sender, EventArgs e) + { + //In this simple example no data is collected from the view. + //Instead a hardcoded trade request is created in the controller. + tradeRequestStatusTextBox.Text = "Request Pending..."; + stockController.SendTradeRequest(); + log.Info("Sent trade request."); + } + + public void UpdateTrade(Trade trade) + { + Invoke(new MethodInvoker( + delegate + { + tradeRequestStatusTextBox.Text = "Confirmed. " + trade.Ticker + " " + trade.Price; + })); + } + + public void UpdateMarketData(IDictionary marketDataDict) + { + Invoke(new MethodInvoker( + delegate + { + marketDataListBox.Items.Add(marketDataDict["TICKER"] + " " + marketDataDict["PRICE"]); + })); + } + + + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.designer.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.designer.cs new file mode 100644 index 00000000..79a2960e --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.designer.cs @@ -0,0 +1,126 @@ +namespace Spring.NmsQuickStart.Client.UI +{ + partial class StockForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tradeRequestButton = new System.Windows.Forms.Button(); + this.tradeRequestStatusTextBox = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.portfolioListBox = new System.Windows.Forms.ListBox(); + this.marketDataListBox = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // tradeRequestButton + // + this.tradeRequestButton.Location = new System.Drawing.Point(12, 12); + this.tradeRequestButton.Name = "tradeRequestButton"; + this.tradeRequestButton.Size = new System.Drawing.Size(135, 23); + this.tradeRequestButton.TabIndex = 0; + this.tradeRequestButton.Text = "Send Trade Request"; + this.tradeRequestButton.UseVisualStyleBackColor = true; + this.tradeRequestButton.Click += new System.EventHandler(this.OnSendTradeRequest); + // + // tradeRequestStatusTextBox + // + this.tradeRequestStatusTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tradeRequestStatusTextBox.Location = new System.Drawing.Point(154, 13); + this.tradeRequestStatusTextBox.Name = "tradeRequestStatusTextBox"; + this.tradeRequestStatusTextBox.Size = new System.Drawing.Size(340, 20); + this.tradeRequestStatusTextBox.TabIndex = 1; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(12, 41); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(135, 23); + this.button1.TabIndex = 2; + this.button1.Text = "Get Portfolio"; + this.button1.UseVisualStyleBackColor = true; + // + // portfolioListBox + // + this.portfolioListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.portfolioListBox.FormattingEnabled = true; + this.portfolioListBox.Location = new System.Drawing.Point(154, 41); + this.portfolioListBox.Name = "portfolioListBox"; + this.portfolioListBox.Size = new System.Drawing.Size(340, 108); + this.portfolioListBox.TabIndex = 3; + // + // marketDataListBox + // + this.marketDataListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.marketDataListBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); + this.marketDataListBox.FormattingEnabled = true; + this.marketDataListBox.ItemHeight = 14; + this.marketDataListBox.Location = new System.Drawing.Point(90, 155); + this.marketDataListBox.Name = "marketDataListBox"; + this.marketDataListBox.Size = new System.Drawing.Size(404, 102); + this.marketDataListBox.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 155); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(72, 13); + this.label1.TabIndex = 5; + this.label1.Text = "Market Data :"; + // + // StockForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(506, 269); + this.Controls.Add(this.label1); + this.Controls.Add(this.marketDataListBox); + this.Controls.Add(this.portfolioListBox); + this.Controls.Add(this.button1); + this.Controls.Add(this.tradeRequestStatusTextBox); + this.Controls.Add(this.tradeRequestButton); + this.Name = "StockForm"; + this.Text = "TradeForm"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button tradeRequestButton; + private System.Windows.Forms.TextBox tradeRequestStatusTextBox; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ListBox portfolioListBox; + private System.Windows.Forms.ListBox marketDataListBox; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.resx b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.resx new file mode 100644 index 00000000..ff31a6db --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Client/UI/StockForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/Trade.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/Trade.cs new file mode 100644 index 00000000..7bb740c0 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/Trade.cs @@ -0,0 +1,40 @@ + + +namespace Spring.NmsQuickStart.Common.Bo +{ + public class Trade + { + private string ticker; + + private long quantity; + + private double price; + + private string orderType; + + + public string Ticker + { + get { return ticker; } + set { ticker = value; } + } + + public long Quantity + { + get { return quantity; } + set { quantity = value; } + } + + public double Price + { + get { return price; } + set { price = value; } + } + + public string OrderType + { + get { return orderType; } + set { orderType = value; } + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/TradeRequest.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/TradeRequest.cs new file mode 100644 index 00000000..d0011ac4 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Bo/TradeRequest.cs @@ -0,0 +1,97 @@ + + +using System.Collections; + +namespace Spring.NmsQuickStart.Common.Bo +{ + public class TradeRequest + { + private string ticker; + + private long quantity; + + private double price; + + private string orderType; + + private string accountName; + + private bool buyRequest; + + private string userName; + + private string requestId; + + + public string Ticker + { + get { return ticker; } + set { ticker = value; } + } + + public long Quantity + { + get { return quantity; } + set { quantity = value; } + } + + public double Price + { + get { return price; } + set { price = value; } + } + + public string OrderType + { + get { return orderType; } + set { orderType = value; } + } + + public string AccountName + { + get { return accountName; } + set { accountName = value; } + } + + public bool BuyRequest + { + get { return buyRequest; } + set { buyRequest = value; } + } + + public string UserName + { + get { return userName; } + set { userName = value; } + } + + public string RequestId + { + get { return requestId; } + set { requestId = value; } + } + + public bool Validate(IList validationErrors) + { + // Not intended to be an example best practices for validation + // The intention is to include some simple behavior in the class + + if (userName == null) + { + validationErrors.Add("User name not specified"); + } + if (requestId == null || requestId.Length == 0) + { + validationErrors.Add("Request Id not specified"); + } + if (!orderType.Equals("MARKET")) + { + if (price <= 0) + { + validationErrors.Add("Market order must have a price"); + } + } + return validationErrors.Count > 0; + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/AbstractNamedMessageConverter.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/AbstractNamedMessageConverter.cs new file mode 100644 index 00000000..b827cbf4 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/AbstractNamedMessageConverter.cs @@ -0,0 +1,30 @@ + + +using System; +using Apache.NMS; +using Spring.Objects.Factory; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public abstract class AbstractNamedMessageConverter : INamedMessageConverter, IObjectNameAware + { + private string objectName; + + + public string Name + { + get { return objectName; } + set { objectName = value; } + } + + public abstract Type TargetType { get; } + + public string ObjectName + { + set { objectName = value; } + } + + public abstract IMessage ToMessage(object objectToConvert, ISession session); + public abstract object FromMessage(IMessage messageToConvert); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/INamedMessageConverter.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/INamedMessageConverter.cs new file mode 100644 index 00000000..554acc01 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/INamedMessageConverter.cs @@ -0,0 +1,34 @@ + + +#region License + +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed 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. + */ + +#endregion + +using System; +using Spring.Messaging.Nms.Support.Converter; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public interface INamedMessageConverter : IMessageConverter + { + string Name { get; set; } + + Type TargetType { get; } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/MultiMessageConverter.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/MultiMessageConverter.cs new file mode 100644 index 00000000..c9fd8685 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/MultiMessageConverter.cs @@ -0,0 +1,110 @@ + + +using System; +using System.Collections; +using Apache.NMS; +using Spring.Messaging.Nms.Support.Converter; +using Spring.Objects.Factory; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public class MultiMessageConverter : IMessageConverter, IInitializingObject + { + private IMessageConverter defaultMessageConverter = new SimpleMessageConverter(); + + private IDictionary typeConverterMapping = new Hashtable(); + + private IDictionary nameConverterMapping = new Hashtable(); + + private IList namedMessageConverters = new ArrayList(); + + + public MultiMessageConverter() + { + + } + + + public IList NamedMessageConverters + { + set { namedMessageConverters = value; } + } + + private string converterIdFieldName = "__ConverterId__"; + + public IMessage ToMessage(object objectToConvert, ISession session) + { + if (objectToConvert == null) + { + throw new MessageConversionException("Can't convert null object"); + } + if (objectToConvert.GetType().Equals(typeof(string)) || + typeof(IDictionary).IsAssignableFrom(objectToConvert.GetType()) || + objectToConvert.GetType().Equals(typeof(Byte[]))) + { + return defaultMessageConverter.ToMessage(objectToConvert, session); + } + else + { + INamedMessageConverter converter = GetConverterForType(objectToConvert.GetType()); + if (converter != null) + { + IMessage msg = converter.ToMessage(objectToConvert, session); + msg.Properties.SetString(converterIdFieldName, converter.Name); + return msg; + } + throw new MessageConversionException("Can't convert object of type " + objectToConvert.GetType()); + } + } + + private INamedMessageConverter GetConverterForType(Type typeOfObjectToConvert) + { + if (typeConverterMapping.Contains(typeOfObjectToConvert)) + { + return typeConverterMapping[typeOfObjectToConvert] as INamedMessageConverter; + } + return null; + } + + public object FromMessage(IMessage messageToConvert) + { + if (messageToConvert == null) + { + throw new MessageConversionException("Can't convert null message"); + } + string converterId = messageToConvert.Properties.GetString(converterIdFieldName); + if (converterId == null) + { + return defaultMessageConverter.FromMessage(messageToConvert); + } + else + { + IMessageConverter converter = GetConverterForId(converterId); + if (converter != null) + { + return converter.FromMessage(messageToConvert); + } + throw new MessageConversionException("Can't convert message with ConverterId = " + converterId + ". Message = " + messageToConvert); + + } + } + + private IMessageConverter GetConverterForId(string converterName) + { + if (nameConverterMapping.Contains(converterName)) + { + return nameConverterMapping[converterName] as IMessageConverter; + } + return null; + } + + public void AfterPropertiesSet() + { + foreach (INamedMessageConverter namedMessageConverter in namedMessageConverters) + { + nameConverterMapping.Add(namedMessageConverter.Name, namedMessageConverter); + typeConverterMapping.Add(namedMessageConverter.TargetType, namedMessageConverter); + } + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeConverter.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeConverter.cs new file mode 100644 index 00000000..b3021110 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeConverter.cs @@ -0,0 +1,61 @@ + + +using System; +using Apache.NMS; +using Spring.Messaging.Nms.Support.Converter; +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public class TradeConverter : AbstractNamedMessageConverter + { + public override Type TargetType + { + get { return typeof (Trade); } + } + + public override IMessage ToMessage(object objectToConvert, ISession session) + { + Trade trade = objectToConvert as Trade; + if (trade == null) + { + throw new MessageConversionException("TradeConverter can not convert object of type " + + objectToConvert.GetType()); + } + try + { + IMapMessage mm = session.CreateMapMessage(); + + mm.Body.SetString("orderType", trade.OrderType); + mm.Body.SetDouble("price", trade.Price); + mm.Body.SetLong("quantity", trade.Quantity); + mm.Body.SetString("ticker", trade.Ticker); + + return mm; + + } + catch (Exception e) + { + throw new MessageConversionException("Could not convert TradeRequest to message", e); + } + } + + public override object FromMessage(IMessage messageToConvert) + { + IMapMessage mm = messageToConvert as IMapMessage; + if (mm != null) + { + Trade trade = new Trade(); + trade.OrderType = mm.Body.GetString("orderType"); + trade.Price = mm.Body.GetDouble("price"); + trade.Quantity = mm.Body.GetLong("quantity"); + trade.Ticker = mm.Body.GetString("ticker"); + return trade; + } + else + { + throw new MessageConversionException("Not of expected type MapMessage. Message = " + messageToConvert); + } + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeRequestConverter.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeRequestConverter.cs new file mode 100644 index 00000000..0f1e14f5 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TradeRequestConverter.cs @@ -0,0 +1,69 @@ +using System; +using Apache.NMS; +using Spring.Messaging.Nms.Support.Converter; +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public class TradeRequestConverter : AbstractNamedMessageConverter + { + public override IMessage ToMessage(object objectToConvert, ISession session) + { + TradeRequest tradeRequest = objectToConvert as TradeRequest; + if (tradeRequest == null) + { + throw new MessageConversionException("TradeRequestConverter can not convert object of type " + + objectToConvert.GetType()); + } + + try + { + IMapMessage mm = session.CreateMapMessage(); + + + mm.Body.SetString("accountName", tradeRequest.AccountName); + mm.Body.SetBool("buyRequest", tradeRequest.BuyRequest); + mm.Body.SetString("orderType", tradeRequest.OrderType); + mm.Body.SetDouble("price", tradeRequest.Price); + mm.Body.SetLong("quantity", tradeRequest.Quantity); + mm.Body.SetString("requestId", tradeRequest.RequestId); + mm.Body.SetString("ticker", tradeRequest.Ticker); + mm.Body.SetString("username", tradeRequest.UserName); + + return mm; + + } catch (Exception e) + { + throw new MessageConversionException("Could not convert TradeRequest to message", e); + } + } + + public override object FromMessage(IMessage messageToConvert) + { + IMapMessage mm = messageToConvert as IMapMessage; + if (mm != null) + { + TradeRequest tradeRequest = new TradeRequest(); + tradeRequest.AccountName = mm.Body.GetString("accountName"); + tradeRequest.BuyRequest = mm.Body.GetBool("buyRequest"); + tradeRequest.OrderType = mm.Body.GetString("orderType"); + tradeRequest.Price = mm.Body.GetDouble("price"); + tradeRequest.Quantity = mm.Body.GetLong("quantity"); + tradeRequest.RequestId = mm.Body.GetString("requestId"); + tradeRequest.Ticker = mm.Body.GetString("ticker"); + tradeRequest.UserName = mm.Body.GetString("username"); + + return tradeRequest; + } + else + { + throw new MessageConversionException("Not of expected type MapMessage. Message = " + messageToConvert); + } + } + + public override Type TargetType + { + get { return typeof (TradeRequest); } + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Properties/AssemblyInfo.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a0b210e0 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +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("Spring.NmsQuickStart.Common")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Spring.NmsQuickStart.Common")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[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("0d2c3d0f-af2f-47aa-9441-c3bd966f94f7")] + +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj new file mode 100644 index 00000000..f42d221a --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Spring.NmsQuickStart.Common.csproj @@ -0,0 +1,79 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AC5A3035-75DD-48E5-ABCA-38FBC8193F22} + Library + Properties + Spring.NmsQuickStart.Common + Spring.NmsQuickStart.Common + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\..\lib\Net\2.0\Apache.NMS.dll + + + False + ..\..\..\..\..\..\lib\Net\2.0\Apache.NMS.ActiveMQ.dll + + + + + + + + + + + + + + + + + + {3A3A4E65-45A6-4B20-B460-0BEDC302C02C} + Spring.Aop.2005 + + + {710961A3-0DF4-49E4-A26E-F5B9C044AC84} + Spring.Core.2005 + + + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40} + Spring.Data.2005 + + + {AEB1578C-9018-4D49-B440-789F38DD2F29} + Spring.Messaging.Nms.2005 + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/App.config b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/App.config new file mode 100644 index 00000000..9f32148d --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/App.config @@ -0,0 +1,44 @@ + + + + + + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Messaging.xml b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Messaging.xml new file mode 100644 index 00000000..a1be77be --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Messaging.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Services.xml b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Services.xml new file mode 100644 index 00000000..69b30e5b --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Config/Services.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/StockAppHandler.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/StockAppHandler.cs new file mode 100644 index 00000000..9bdfb10f --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Handlers/StockAppHandler.cs @@ -0,0 +1,20 @@ + + +using Common.Logging; +using Spring.NmsQuickStart.Common.Bo; + +namespace Spring.NmsQuickStart.Server.Handlers +{ + public class StockAppHandler + { + + private static readonly ILog log = LogManager.GetLogger(typeof(StockAppHandler)); + + + public Trade Handle(TradeRequest tradeRequest) + { + log.Info("Received TradeRequest"); + return new Trade(); + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Program.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Program.cs new file mode 100644 index 00000000..2542e642 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Program.cs @@ -0,0 +1,26 @@ +using System; +using Spring.Context.Support; + +namespace Spring.NmsQuickStart.Server +{ + public class Program + { + static void Main(string[] args) + { + try + { + // Using Spring's IoC container + ContextRegistry.GetContext(); // Force Spring to load configuration + Console.Out.WriteLine("Server listening..."); + Console.Out.WriteLine("--- Press to quit ---"); + Console.ReadLine(); + } + catch (Exception e) + { + Console.Out.WriteLine(e); + Console.Out.WriteLine("--- Press to quit ---"); + Console.ReadLine(); + } + } + } +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Properties/AssemblyInfo.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7326a5d5 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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("Spring.NmsQuickStart.Server")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Spring.NmsQuickStart.Server")] +[assembly: AssemblyCopyright("Copyright © 2008")] +[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("3e4b803d-86c9-4634-9b38-e29d70a083e0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj new file mode 100644 index 00000000..82ec047c --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Spring.NmsQuickStart.Server.csproj @@ -0,0 +1,97 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {85E7B947-8153-45E4-B572-BEDB191F1FB2} + Exe + Properties + Spring.NmsQuickStart.Server + Spring.NmsQuickStart.Server + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\..\lib\Net\2.0\Apache.NMS.dll + + + False + ..\..\..\..\..\..\lib\Net\2.0\Apache.NMS.ActiveMQ.dll + + + False + ..\..\..\..\..\..\lib\Net\2.0\Common.Logging.dll + + + + + + + + + + + + + + + + {3A3A4E65-45A6-4B20-B460-0BEDC302C02C} + Spring.Aop.2005 + + + {710961A3-0DF4-49E4-A26E-F5B9C044AC84} + Spring.Core.2005 + + + {AE00E5AB-C39A-436F-86D2-33BFE33E2E40} + Spring.Data.2005 + + + {AEB1578C-9018-4D49-B440-789F38DD2F29} + Spring.Messaging.Nms.2005 + + + {AC5A3035-75DD-48E5-ABCA-38FBC8193F22} + Spring.NmsQuickStart.Common + + + + + Always + + + Always + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Integration.Tests/Spring.NmsQuickStart.Integration.Tests.2005.csproj b/examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Integration.Tests/Spring.NmsQuickStart.Integration.Tests.2005.csproj new file mode 100644 index 00000000..7205d68d --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Integration.Tests/Spring.NmsQuickStart.Integration.Tests.2005.csproj @@ -0,0 +1,41 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E641F51F-1B51-4B94-B419-F902EABCE4D4} + Library + Properties + Spring + Spring.NmsQuickStart.Integration.Tests + + + true + full + false + ..\..\..\build\VS.NET.2005\Spring.NmsQuickStart.Integration.Tests\Debug\ + TRACE;DEBUG;NET_2_0 + prompt + 4 + + + pdbonly + true + ..\..\..\build\VS.NET.2005\Spring.NmsQuickStart.Integration.Tests\Release\ + TRACE;NET_2_0 + prompt + 4 + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Tests/Spring.NmsQuickStart.Tests.2005.csproj b/examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Tests/Spring.NmsQuickStart.Tests.2005.csproj new file mode 100644 index 00000000..6f33d696 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/test/Spring/Spring.NmsQuickStart.Tests/Spring.NmsQuickStart.Tests.2005.csproj @@ -0,0 +1,41 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048} + Library + Properties + Spring + Spring.NmsQuickStart.Tests + + + true + full + false + ..\..\..\build\VS.NET.2005\Spring.NmsQuickStart.Tests\Debug\ + TRACE;DEBUG;NET_2_0 + prompt + 4 + + + pdbonly + true + ..\..\..\build\VS.NET.2005\Spring.NmsQuickStart.Tests\Release\ + TRACE;NET_2_0 + prompt + 4 + + + + + + + \ No newline at end of file diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsGatewaySupport.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsGatewaySupport.cs index 858481f7..1c9141be 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsGatewaySupport.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Core/NmsGatewaySupport.cs @@ -91,7 +91,7 @@ namespace Spring.Messaging.Nms.Core /// /// Ensures that the JmsTemplate is specified and calls . /// - public void AfterPropertiesSet() + public virtual void AfterPropertiesSet() { if (jmsTemplate == null) { diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs index 95675705..63f99ac2 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/Adapter/MessageListenerAdapter.cs @@ -68,7 +68,7 @@ namespace Spring.Messaging.Nms.Listener.Adapter /// /// Juergen Hoeller /// Mark Pollack (.NET) - public class MessageListenerAdapter : IMessageListener + public class MessageListenerAdapter : IMessageListener, ISessionAwareMessageListener { #region Logging diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/IMessageConverter.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/IMessageConverter.cs index 23368542..f63bee78 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/IMessageConverter.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/IMessageConverter.cs @@ -45,11 +45,11 @@ namespace Spring.Messaging.Nms.Support.Converter IMessage ToMessage(object objectToConvert, ISession session); /// Convert from a NMS Message to a .NET object. - /// the message to convert + /// the message to convert /// /// the converted .NET object /// /// MessageConversionException in case of conversion failure - object FromMessage(IMessage message); + object FromMessage(IMessage messageToConvert); } } diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/SimpleMessageConverter.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/SimpleMessageConverter.cs index 5af6c746..2e270542 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/SimpleMessageConverter.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Converter/SimpleMessageConverter.cs @@ -42,7 +42,7 @@ namespace Spring.Messaging.Nms.Support.Converter /// Convert a .NET object to a NMS Message using the supplied session /// to create the message object. /// - /// the object to convert + /// the object to convert /// /// the Session to use for creating a NMS Message /// @@ -50,62 +50,62 @@ namespace Spring.Messaging.Nms.Support.Converter /// /// NMSException if thrown by NMS API methods /// MessageConversionException in case of conversion failure - public IMessage ToMessage(object objectToConvert, ISession session) + public IMessage ToMessage(object @object, ISession session) { - if (objectToConvert is IMessage) + if (@object is IMessage) { - return (IMessage) objectToConvert; + return (IMessage) @object; } - else if (objectToConvert is string) + else if (@object is string) { - return CreateMessageForString((string) objectToConvert, session); + return CreateMessageForString((string) @object, session); } - else if (objectToConvert is sbyte[]) + else if (@object is sbyte[]) { - return CreateMessageForByteArray((byte[]) objectToConvert, session); + return CreateMessageForByteArray((byte[]) @object, session); } - else if (objectToConvert is IDictionary) + else if (@object is IDictionary) { - return CreateMessageForMap((IDictionary) objectToConvert, session); + return CreateMessageForMap((IDictionary) @object, session); } - else if (objectToConvert is ISerializable) + else if (@object is ISerializable) { return - CreateMessageForSerializable(((ISerializable) objectToConvert), session); + CreateMessageForSerializable(((ISerializable) @object), session); } else { - throw new MessageConversionException("Cannot convert object [" + objectToConvert + "] to NMS message"); + throw new MessageConversionException("Cannot convert object [" + @object + "] to NMS message"); } } /// Convert from a NMS Message to a .NET object. - /// the message to convert + /// the message to convert /// /// the converted .NET object /// /// MessageConversionException in case of conversion failure - public object FromMessage(IMessage message) + public object FromMessage(IMessage messageToConvert) { - if (message is ITextMessage) + if (messageToConvert is ITextMessage) { - return ExtractStringFromMessage((ITextMessage) message); + return ExtractStringFromMessage((ITextMessage) messageToConvert); } - else if (message is IBytesMessage) + else if (messageToConvert is IBytesMessage) { - return ExtractByteArrayFromMessage((IBytesMessage) message); + return ExtractByteArrayFromMessage((IBytesMessage) messageToConvert); } - else if (message is IMapMessage) + else if (messageToConvert is IMapMessage) { - return ExtractMapFromMessage((IMapMessage) message); + return ExtractMapFromMessage((IMapMessage) messageToConvert); } - else if (message is IObjectMessage) + else if (messageToConvert is IObjectMessage) { - return ExtractSerializableFromMessage((IObjectMessage) message); + return ExtractSerializableFromMessage((IObjectMessage) messageToConvert); } else { - return message; + return messageToConvert; } }