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 index 7a3bcbc5..80bdcac2 100644 --- 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 @@ -21,7 +21,7 @@ - + @@ -46,10 +46,21 @@ - + + + + + + + + + + + + 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 index 16fe7817..e988ed5e 100644 --- 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 @@ -20,7 +20,7 @@ #endregion -using Spring.NmsQuickStart.Common.Bo; +using Spring.NmsQuickStart.Common.Data; namespace Spring.NmsQuickStart.Client.Gateways { 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 index 8c8643f3..ebeaf821 100644 --- 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 @@ -3,7 +3,7 @@ using Apache.NMS; using Spring.Messaging.Nms.Core; -using Spring.NmsQuickStart.Common.Bo; +using Spring.NmsQuickStart.Common.Data; using Spring.Objects.Factory; namespace Spring.NmsQuickStart.Client.Gateways 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 index 18ae4536..efd32623 100644 --- 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 @@ -3,7 +3,7 @@ using System.Collections; using Common.Logging; using Spring.NmsQuickStart.Client.UI; -using Spring.NmsQuickStart.Common.Bo; +using Spring.NmsQuickStart.Common.Data; namespace Spring.NmsQuickStart.Client.Handlers { @@ -24,7 +24,7 @@ namespace Spring.NmsQuickStart.Client.Handlers set { stockController = value; } } - public void HandleObject(IDictionary data) + public void Handle(Hashtable data) { log.Info(string.Format("Received market data. Ticker = {0}, Price = {1}", data["TICKER"], data["PRICE"])); 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 index d6af97a7..57cf3507 100644 --- 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 @@ -2,7 +2,7 @@ using System.Collections; using Spring.NmsQuickStart.Client.Gateways; -using Spring.NmsQuickStart.Common.Bo; +using Spring.NmsQuickStart.Common.Data; namespace Spring.NmsQuickStart.Client.UI { @@ -33,7 +33,7 @@ namespace Spring.NmsQuickStart.Client.UI tradeRequest.BuyRequest = true; tradeRequest.OrderType = "MARKET"; tradeRequest.Quantity = 314000000; - tradeRequest.RequestId = "REQ-1"; + tradeRequest.RequestID = "REQ-1"; tradeRequest.Ticker = "CSCO"; tradeRequest.UserName = "Joe Trader"; 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 index 899a2a36..42daf5d2 100644 --- 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 @@ -3,7 +3,7 @@ using System.Collections; using System.Windows.Forms; using Common.Logging; using Spring.Context.Support; -using Spring.NmsQuickStart.Common.Bo; +using Spring.NmsQuickStart.Common.Data; namespace Spring.NmsQuickStart.Client.UI { diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/ITypeMapper.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/ITypeMapper.cs new file mode 100644 index 00000000..6194902a --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/ITypeMapper.cs @@ -0,0 +1,42 @@ + + +#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; + +namespace Spring.NmsQuickStart.Common.Converters +{ + /// + /// Provides a layer of indirection when adding the 'type' of the object as a message property. + /// + /// Mark Pollack + public interface ITypeMapper + { + string TypeIdFieldName + { + get; + } + + string FromType(Type typeOfObjectToConvert); + + Type ToType(string typeId); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TypeMapper.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TypeMapper.cs new file mode 100644 index 00000000..8bbbd8fc --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/TypeMapper.cs @@ -0,0 +1,144 @@ + + +using System; +using System.Collections; +using Spring.Core.TypeResolution; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public class TypeMapper : ITypeMapper + { + private string defaultNamespace; + private string defaultAssemblyName; + + //Generics not used to support both 1.1 and 2.0 + private IDictionary idTypeMapping; + private IDictionary typeIdMapping; + + + //TODO generalize? + private string defaultHashtableTypeId = "Hashtable"; + + private Type defaultHashtableClass = typeof(Hashtable); + + public TypeMapper() + { + idTypeMapping = new Hashtable(); + typeIdMapping = new Hashtable(); + } + + + public IDictionary IdTypeMapping + { + get { return idTypeMapping; } + set { idTypeMapping = value; } + } + + public string TypeIdFieldName + { + get { return "__TypeId__"; } + } + + + public Type DefaultHashtableClass + { + set { defaultHashtableClass = value; } + } + + public string FromType(Type typeOfObjectToConvert) + { + + if (typeIdMapping.Contains(typeOfObjectToConvert)) + { + return typeIdMapping[typeOfObjectToConvert] as string; + } + else + { + if ( typeof (IDictionary).IsAssignableFrom(typeOfObjectToConvert)) + { + return defaultHashtableTypeId; + } + return typeOfObjectToConvert.Name; + } + } + + public Type ToType(string typeId) + { + if (idTypeMapping.Contains(typeId)) + { + return idTypeMapping[typeId] as Type; + } + else + { + if (typeId.Equals(defaultHashtableTypeId)) + { + return defaultHashtableClass; + } + string fullyQualifiedTypeName = defaultNamespace + "." + + typeId + ", " + + DefaultAssemblyName; + return TypeResolutionUtils.ResolveType(fullyQualifiedTypeName); + } + + } + + public string DefaultNamespace + { + get + { + return defaultNamespace; + } + set + { + defaultNamespace = value; + } + + } + + public string DefaultAssemblyName + { + get + { + return defaultAssemblyName; + } + set + { + defaultAssemblyName = value; + } + } + + public void AfterPropertiesSet() + { + ValidateIdTypeMapping(); + if (DefaultAssemblyName != null && DefaultNamespace == null) + { + throw new ArgumentException("Default Namespace required when DefaultAssemblyName is set."); + } + if (DefaultNamespace != null && DefaultAssemblyName == null) + { + throw new ArgumentException("Default Assembly Name required when DefaultNamespace is set."); + } + } + + + private void ValidateIdTypeMapping() + { + IDictionary finalIdTypeMapping = new Hashtable(); + foreach (DictionaryEntry entry in idTypeMapping) + { + string id = entry.Key.ToString(); + Type t = entry.Value as Type; + if (t == null) + { + //convert from string value. + string typeName = entry.Value.ToString(); + t = TypeResolutionUtils.ResolveType(typeName); + } + finalIdTypeMapping.Add(id,t); + typeIdMapping.Add(t,id); + + } + idTypeMapping = finalIdTypeMapping; + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/XmlMessageConverter.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/XmlMessageConverter.cs new file mode 100644 index 00000000..28d4f38f --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Converters/XmlMessageConverter.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections; +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Serialization; +using Apache.NMS; +using Spring.Messaging.Nms.Support.Converter; + +namespace Spring.NmsQuickStart.Common.Converters +{ + public class XmlMessageConverter : IMessageConverter + { + private IMessageConverter defaultMessageConverter = new SimpleMessageConverter(); + + + private ITypeMapper typeMapper; + + + public ITypeMapper TypeMapper + { + set { typeMapper = value; } + } + + public IMessage ToMessage(object objectToConvert, ISession session) + { + if (objectToConvert == null) + { + throw new MessageConversionException("Can't convert null object"); + } + try + { + if (objectToConvert.GetType().Equals(typeof (string)) || + typeof (IDictionary).IsAssignableFrom(objectToConvert.GetType()) || + objectToConvert.GetType().Equals(typeof (Byte[]))) + { + return defaultMessageConverter.ToMessage(objectToConvert, session); + } + else + { + string xmlString = GetXmlString(objectToConvert); + IMessage msg = session.CreateTextMessage(xmlString); + msg.Properties.SetString(typeMapper.TypeIdFieldName, typeMapper.FromType(objectToConvert.GetType())); + return msg; + } + } catch (Exception e) + { + throw new MessageConversionException("Can't convert object of type " + objectToConvert.GetType(), e); + } + } + + private string GetXmlString(object objectToConvert) + { + string xmlString; + XmlTextWriter xmlTextWriter = null; + MemoryStream memoryStream = null; + try + { + memoryStream = new MemoryStream(); + xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); + XmlSerializer xs = new XmlSerializer(objectToConvert.GetType()); + xs.Serialize(xmlTextWriter, objectToConvert); + xmlString = UTF8ByteArrayToString(((MemoryStream) xmlTextWriter.BaseStream).ToArray()); + } catch (Exception e) + { + throw new MessageConversionException("Can't convert object of type " + objectToConvert.GetType(), e); + } finally + { + if (memoryStream != null) memoryStream.Close(); + if (xmlTextWriter != null) xmlTextWriter.Close(); + } + return xmlString; + } + + public object FromMessage(IMessage messageToConvert) + { + if (messageToConvert == null) + { + throw new MessageConversionException("Can't convert null message"); + } + try + { + string converterId = messageToConvert.Properties.GetString(typeMapper.TypeIdFieldName); + if (converterId == null) + { + return defaultMessageConverter.FromMessage(messageToConvert); + } + else + { + ITextMessage textMessage = messageToConvert as ITextMessage; + if (textMessage == null) + { + throw new MessageConversionException("Can't convert message of type " + + messageToConvert.GetType()); + } + + using (MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(textMessage.Text))) + { + + XmlSerializer xs = new XmlSerializer(GetTargetType(textMessage)); + XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); + return xs.Deserialize(memoryStream); + } + } + } catch (Exception e) + { + throw new MessageConversionException("Can't convert message of type " + messageToConvert.GetType(), e); + } + } + + private Type GetTargetType(ITextMessage message) + { + return typeMapper.ToType(message.Properties.GetString(typeMapper.TypeIdFieldName)); + } + + + private String UTF8ByteArrayToString(Byte[] characters) + { + UTF8Encoding encoding = new UTF8Encoding(); + + String constructedString = encoding.GetString(characters); + + return (constructedString); + } + + + private Byte[] StringToUTF8ByteArray(String pXmlString) + { + UTF8Encoding encoding = new UTF8Encoding(); + + Byte[] byteArray = encoding.GetBytes(pXmlString); + + return byteArray; + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/Trade.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/Trade.cs new file mode 100644 index 00000000..ee8568f1 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/Trade.cs @@ -0,0 +1,76 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by xsd, Version=2.0.50727.42. +// +namespace Spring.NmsQuickStart.Common.Data { + using System.Xml.Serialization; + + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.springframework.net/nms/common/2008-08-05")] + [System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.springframework.net/nms/common/2008-08-05", IsNullable=false)] + public partial class Trade { + + private string tickerField; + + private string quantityField; + + private decimal priceField; + + private string orderTypeField; + + /// + public string Ticker { + get { + return this.tickerField; + } + set { + this.tickerField = value; + } + } + + /// + [System.Xml.Serialization.XmlElementAttribute(DataType="integer")] + public string Quantity { + get { + return this.quantityField; + } + set { + this.quantityField = value; + } + } + + /// + public decimal Price { + get { + return this.priceField; + } + set { + this.priceField = value; + } + } + + /// + public string OrderType { + get { + return this.orderTypeField; + } + set { + this.orderTypeField = value; + } + } + } +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/Trade.xsd b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/Trade.xsd new file mode 100644 index 00000000..4b486191 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/Trade.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/TradeRequest.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/TradeRequest.cs new file mode 100644 index 00000000..bda96e37 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/TradeRequest.cs @@ -0,0 +1,123 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by xsd, Version=2.0.50727.42. +// +namespace Spring.NmsQuickStart.Common.Data { + using System.Xml.Serialization; + + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.springframework.net/nms/common/2008-08-05")] + [System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.springframework.net/nms/common/2008-08-05", IsNullable=false)] + public partial class TradeRequest { + + private string tickerField; + + private long quantityField; + + private decimal priceField; + + private string orderTypeField; + + private string accountNameField; + + private bool buyRequestField; + + private string userNameField; + + private string requestIDField; + + /// + public string Ticker { + get { + return this.tickerField; + } + set { + this.tickerField = value; + } + } + + /// + public long Quantity { + get { + return this.quantityField; + } + set { + this.quantityField = value; + } + } + + /// + public decimal Price { + get { + return this.priceField; + } + set { + this.priceField = value; + } + } + + /// + public string OrderType { + get { + return this.orderTypeField; + } + set { + this.orderTypeField = value; + } + } + + /// + public string AccountName { + get { + return this.accountNameField; + } + set { + this.accountNameField = value; + } + } + + /// + public bool BuyRequest { + get { + return this.buyRequestField; + } + set { + this.buyRequestField = value; + } + } + + /// + public string UserName { + get { + return this.userNameField; + } + set { + this.userNameField = value; + } + } + + /// + public string RequestID { + get { + return this.requestIDField; + } + set { + this.requestIDField = value; + } + } + } +} diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/TradeRequest.xsd b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/TradeRequest.xsd new file mode 100644 index 00000000..c5e5573a --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/TradeRequest.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/generate-classes.bat b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/generate-classes.bat new file mode 100644 index 00000000..3a327f9d --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Common/Data/generate-classes.bat @@ -0,0 +1,2 @@ +xsd.exe -c -l:c# -n:Spring.NmsQuickStart.Common.Data Trade.xsd +xsd.exe -c -l:c# -n:Spring.NmsQuickStart.Common.Data TradeRequest.xsd \ No newline at end of file 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 index f42d221a..7f01d947 100644 --- 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 @@ -41,13 +41,15 @@ - - - - - - - + + + + + Trade.xsd + + + TradeRequest.xsd + @@ -68,6 +70,14 @@ Spring.Messaging.Nms.2005 + + + Designer + + + Designer + + @@ -19,9 +32,21 @@ - + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataGateway.cs b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataGateway.cs new file mode 100644 index 00000000..b8baf871 --- /dev/null +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Gateways/MarketDataGateway.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections; +using System.Threading; +using Common.Logging; +using Spring.Messaging.Nms.Core; + +namespace Spring.NmsQuickStart.Server.Gateways +{ + public class MarketDataGateway : NmsGatewaySupport + { + private static readonly ILog log = LogManager.GetLogger(typeof (MarketDataGateway)); + + private readonly Random random; + private int sleepTimeInSeconds = 2; + + + public MarketDataGateway() + { + random = new Random(); + } + + public int SleepTimeInSeconds + { + set { sleepTimeInSeconds = value; } + } + + public void SendMarketData() + { + while (true) + { + IDictionary data = GenerateFakeMarketData(); + log.Info("Sending market data."); + NmsTemplate.ConvertAndSend(data); + log.Info("Sleeping " + sleepTimeInSeconds + " seconds before sending more market data."); + Thread.Sleep(sleepTimeInSeconds*1000); + } + } + + private IDictionary GenerateFakeMarketData() + { + IDictionary md = new Hashtable(); + md.Add("TICKER", "CSCO"); + md.Add("PRICE", "22" + string.Format("{0:#.###}", Math.Abs(Gaussian()))); + return md; + } + + private double Gaussian() + { + double x1, x2, w; + + do + { + x1 = 2.0*random.NextDouble() - 1.0; + x2 = 2.0*random.NextDouble() - 1.0; + w = x1*x1 + x2*x2; + } while (w >= 1.0); + + w = Math.Sqrt(-2.0*Math.Log(w)/w); + + // two Gaussian random numbers are generated + return x1*w; + //y2 = x2 * w; + } + } +} \ 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 index 9bdfb10f..828e16a0 100644 --- 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 @@ -1,7 +1,7 @@ using Common.Logging; -using Spring.NmsQuickStart.Common.Bo; +using Spring.NmsQuickStart.Common.Data; namespace Spring.NmsQuickStart.Server.Handlers { 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 index 2542e642..fbc00233 100644 --- a/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Program.cs +++ b/examples/Spring/Spring.NmsQuickStart/src/Spring/Spring.NmsQuickStart.Server/Program.cs @@ -1,5 +1,7 @@ using System; +using System.Threading; using Spring.Context.Support; +using Spring.NmsQuickStart.Server.Gateways; namespace Spring.NmsQuickStart.Server { @@ -12,6 +14,11 @@ namespace Spring.NmsQuickStart.Server // Using Spring's IoC container ContextRegistry.GetContext(); // Force Spring to load configuration Console.Out.WriteLine("Server listening..."); + MarketDataGateway marketDataGateway = + ContextRegistry.GetContext().GetObject("MarketDataGateway") as MarketDataGateway; + ThreadStart job = new ThreadStart(marketDataGateway.SendMarketData); + Thread thread = new Thread(job); + thread.Start(); Console.Out.WriteLine("--- Press to quit ---"); Console.ReadLine(); } 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 index 82ec047c..c4d1fc6e 100644 --- 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 @@ -45,6 +45,7 @@ + @@ -82,10 +83,6 @@ Always - - - -