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
         /// </summary>
         /// <param name="orderMode">The order mode, determines what type of 
binding/remote interface is used for communication.</param>
-        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;
 
             /// <summary>
             /// 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;
+
+            }
+
             /// <summary>
             /// Uses reflection to create a typed generic object.
             /// </summary>
@@ -147,6 +188,27 @@
                 return channelFactory;
             }
 
+            /// <summary>
+            /// Returns a channel factory as an object type. The channel 
factory will be created as type "theType"
+            /// </summary>
+            /// <param name="theType">The type representing the service 
contract type.</param>
+            /// <param name="clientConfiguration">The name of the binding 
configuration to be used when creating the factory.</param>
+            /// <param name="url">The endpoint address to be used when 
creating the channel factory.</param>
+            /// <returns>object representing a channel factory</returns>
+            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 @@
                 }
             }
 
+
             /// <summary>
             /// Returns a channel as an IChannel type. The channel will be 
created using a channel factory.
             /// </summary>
@@ -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;
 
         /// <summary>
         /// 
@@ -274,6 +341,25 @@
             }
         }
 
+        public Client(Type clientContractType, string clientConfig, string url)
+        {
+            _type = clientContractType;
+            _clientConfig = clientConfig;
+            _url = url;
+            if (connectionDictionary == null)
+                connectionDictionary = new Dictionary<string, ClientList>();
+            try
+            {
+                connection = connectionDictionary[_type.FullName];
+            }
+            catch
+            {
+                //No entry!
+                connection = new ClientList(clientContractType, clientConfig, 
url);
+                connectionDictionary.Add(_type.FullName, connection);
+            }
+        }
+
         /// <summary>
         /// 
         /// </summary>
@@ -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<string, ClientList>();
+            try
+            {
+                connection = connectionDictionary[_type.FullName];
+            }
+            catch
+            {
+                //No entry!
+                connection = new ClientList(clientContractType, clientConfig, 
url, userName, password);
+                connectionDictionary.Add(_type.FullName, connection);
+            }
+        }
+
         /// <summary>
         /// 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


Reply via email to