From stonehenge-commits-return-434-apmail-incubator-stonehenge-commits-archive=incubator.apache.org@incubator.apache.org Wed Jul 29 02:24:23 2009 Return-Path: Delivered-To: apmail-incubator-stonehenge-commits-archive@minotaur.apache.org Received: (qmail 29337 invoked from network); 29 Jul 2009 02:24:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Jul 2009 02:24:23 -0000 Received: (qmail 46653 invoked by uid 500); 29 Jul 2009 02:24:23 -0000 Delivered-To: apmail-incubator-stonehenge-commits-archive@incubator.apache.org Received: (qmail 46619 invoked by uid 500); 29 Jul 2009 02:24:23 -0000 Mailing-List: contact stonehenge-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stonehenge-dev@incubator.apache.org Delivered-To: mailing list stonehenge-commits@incubator.apache.org Received: (qmail 46610 invoked by uid 99); 29 Jul 2009 02:24:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jul 2009 02:24:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jul 2009 02:24:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4D3E0238886C; Wed, 29 Jul 2009 02:24:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798753 - in /incubator/stonehenge/trunk/stocktrader/dotnet: business_service/BusinessServiceImplementation/ business_service/OrderProcessorASyncClient/ common/BasicClient/ trader_client/BusinessServiceClient/ Date: Wed, 29 Jul 2009 02:24:01 -0000 To: stonehenge-commits@incubator.apache.org From: bendewey@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090729022401.4D3E0238886C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bendewey Date: Wed Jul 29 02:24:00 2009 New Revision: 798753 URL: http://svn.apache.org/viewvc?rev=798753&view=rev Log: STONEHENGE-92 thanks Avantika Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs incubator/stonehenge/trunk/stocktrader/dotnet/common/BasicClient/BasicClient.cs incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/BusinessServiceClient/BusinessServiceClient.cs Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs?rev=798753&r1=798752&r2=798753&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs (original) +++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/BusinessServiceImplementation/TradeService.cs Wed Jul 29 02:24:00 2009 @@ -829,7 +829,7 @@ //This creates a new client with the orderMode specified using the config info //from the database. Specifically, the row containing "DOTNET_BS" in the table //BSTOOPS - TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPSName); + TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPSName, bsConfig.OPS); asyncclient.processOrderASync(order); @@ -874,7 +874,7 @@ //easily knowing where communication and proxy logic sits; and make changes to services //you might want to interface with vs. littering proxy calls throughout the //business tier itself. - TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPS); + TradeOrderServiceAsyncClient asyncclient = new TradeOrderServiceAsyncClient(bsConfig.OPSName, bsConfig.OPS); asyncclient.processOrderASync(order); dalOrder.CommitADOTransaction(); Modified: incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs?rev=798753&r1=798752&r2=798753&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs (original) +++ incubator/stonehenge/trunk/stocktrader/dotnet/business_service/OrderProcessorASyncClient/OrderProcessorAsyncClient.cs Wed Jul 29 02:24:00 2009 @@ -69,11 +69,11 @@ /// in the database BSTOPS table /// /// The order mode, determines what type of binding/remote interface is used for communication. - public TradeOrderServiceAsyncClient(string orderMode) + public TradeOrderServiceAsyncClient(string clientConfig, string url) { try { - opsclient = new Client.Client(typeof(IOrderProcessor), ConfigurationManager.AppSettings.Get(orderMode)); + opsclient = new Client.Client(typeof(IOrderProcessor), ConfigurationManager.AppSettings.Get(clientConfig), url); } catch { Modified: incubator/stonehenge/trunk/stocktrader/dotnet/common/BasicClient/BasicClient.cs URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/common/BasicClient/BasicClient.cs?rev=798753&r1=798752&r2=798753&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/dotnet/common/BasicClient/BasicClient.cs (original) +++ incubator/stonehenge/trunk/stocktrader/dotnet/common/BasicClient/BasicClient.cs Wed Jul 29 02:24:00 2009 @@ -46,6 +46,7 @@ public Connection _connection; private Type _type; private string _clientConfig; + private string _url; private string _userName; private string _password; @@ -74,6 +75,25 @@ _connection = new Connection(_type, null, _clientConfig, null,userName,password); } + public ClientList(Type clientContractType, string clientConfig, string url) + { + _clientConfig = clientConfig; + _type = clientContractType; + _url = url; + + _connection = new Connection(_type, null, _clientConfig, null, url); + } + + public ClientList(Type clientContractType, string clientConfig, string url, string userName, string password) + { + _clientConfig = clientConfig; + _type = clientContractType; + _url = url; + _userName = userName; + _password = password; + _connection = new Connection(_type, null, _clientConfig, null, url, userName, password); + } + public class Connection { private IChannel _channel; @@ -83,7 +103,7 @@ public Type _type; string _userName; string _password; - + string _url; /// /// Creates a new Connection instance, which stores all the information for a cached Channel instance @@ -101,6 +121,15 @@ _factory = factory; } + public Connection(Type type, IChannel channel, string clientConfig, ChannelFactory factory,string url) + { + _type = type; + _channel = channel; + _clientConfig = clientConfig; + _factory = factory; + _url = url; + } + public Connection(Type type, IChannel channel, string clientConfig, ChannelFactory factory, string userName, string password) { _type = type; @@ -111,6 +140,18 @@ _password = password; } + public Connection(Type type, IChannel channel, string clientConfig, ChannelFactory factory, string url, string userName, string password) + { + _type = type; + _channel = channel; + _clientConfig = clientConfig; + _factory = factory; + _url = url; + _userName = userName; + _password = password; + + } + /// /// Uses reflection to create a typed generic object. /// @@ -147,6 +188,27 @@ return channelFactory; } + /// + /// Returns a channel factory as an object type. The channel factory will be created as type "theType" + /// + /// The type representing the service contract type. + /// The name of the binding configuration to be used when creating the factory. + /// The endpoint address to be used when creating the channel factory. + /// object representing a channel factory + public static object createChannelFactory(Type theType, string clientConfiguration, string url, string userName, string password) + { + object channelFactory = CreateGeneric(typeof(ChannelFactory<>), theType, new object[] { clientConfiguration }); + ((ChannelFactory)channelFactory).Credentials.UserName.UserName = userName; + ((ChannelFactory)channelFactory).Credentials.UserName.Password = password; + if (!string.IsNullOrEmpty(url)) + { + var oldAddress = ((ChannelFactory)channelFactory).Endpoint.Address; + ((ChannelFactory)channelFactory).Endpoint.Address = new EndpointAddress(new Uri(url), oldAddress.Identity); + } + return channelFactory; + } + + public string ClientConfig { get @@ -159,6 +221,7 @@ } } + /// /// Returns a channel as an IChannel type. The channel will be created using a channel factory. /// @@ -193,7 +256,10 @@ { if (_factory == null) { - _factory = (ChannelFactory)createChannelFactory(_type, ClientConfig,_userName,_password); + if (_url == null) + _factory = (ChannelFactory)createChannelFactory(_type, ClientConfig, _userName, _password); + else + _factory = (ChannelFactory)createChannelFactory(_type, ClientConfig, _url, _userName, _password); } if (_channel == null) { @@ -250,6 +316,7 @@ public ClientList connection; private string _clientConfig; private Type _type; + private string _url; /// /// @@ -274,6 +341,25 @@ } } + public Client(Type clientContractType, string clientConfig, string url) + { + _type = clientContractType; + _clientConfig = clientConfig; + _url = url; + if (connectionDictionary == null) + connectionDictionary = new Dictionary(); + try + { + connection = connectionDictionary[_type.FullName]; + } + catch + { + //No entry! + connection = new ClientList(clientContractType, clientConfig, url); + connectionDictionary.Add(_type.FullName, connection); + } + } + /// /// /// @@ -297,6 +383,25 @@ } } + public Client(Type clientContractType, string clientConfig, string url, string userName, string password) + { + _type = clientContractType; + _clientConfig = clientConfig; + _url = url; + if (connectionDictionary == null) + connectionDictionary = new Dictionary(); + try + { + connection = connectionDictionary[_type.FullName]; + } + catch + { + //No entry! + connection = new ClientList(clientContractType, clientConfig, url, userName, password); + connectionDictionary.Add(_type.FullName, connection); + } + } + /// /// Property that is referenced in custom client code to get a channel from the connection list. Hence, when /// getting a channel via this property, load balancing and failover will occur. @@ -320,4 +425,3 @@ } } } - Modified: incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/BusinessServiceClient/BusinessServiceClient.cs URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/BusinessServiceClient/BusinessServiceClient.cs?rev=798753&r1=798752&r2=798753&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/BusinessServiceClient/BusinessServiceClient.cs (original) +++ incubator/stonehenge/trunk/stocktrader/dotnet/trader_client/BusinessServiceClient/BusinessServiceClient.cs Wed Jul 29 02:24:00 2009 @@ -87,11 +87,11 @@ { if (clientConfig.BSName.Equals(Settings.BS_LABEL)) { - bslclient = new Client.Client(typeof(ITradeServices), ConfigurationManager.AppSettings.Get(clientConfig.BSName)); + bslclient = new Client.Client(typeof(ITradeServices), ConfigurationManager.AppSettings.Get(clientConfig.BSName), clientConfig.BS); } else { - bslclient = new Client.Client(typeof(ITradeServices), ConfigurationManager.AppSettings.Get(clientConfig.BSName), Settings.BSL_USERID, Settings.BSL_PASSWORD); + bslclient = new Client.Client(typeof(ITradeServices), ConfigurationManager.AppSettings.Get(clientConfig.BSName), clientConfig.BS, Settings.BSL_USERID, Settings.BSL_PASSWORD); } } catch @@ -452,4 +452,4 @@ } } -} +} \ No newline at end of file