diff options
-rw-r--r-- | TAO/examples/Simple/bank/AccountManager_i.cpp | 8 | ||||
-rw-r--r-- | TAO/examples/Simple/bank/Account_i.cpp | 6 | ||||
-rw-r--r-- | TAO/examples/Simple/bank/Client_i.cpp | 26 | ||||
-rw-r--r-- | TAO/examples/Simple/bank/README | 24 | ||||
-rw-r--r-- | TAO/examples/Simple/bank/Server_i.cpp | 10 | ||||
-rw-r--r-- | TAO/examples/Simple/bank/client.cpp | 2 | ||||
-rw-r--r-- | TAO/examples/Simple/bank/server.cpp | 2 |
7 files changed, 48 insertions, 30 deletions
diff --git a/TAO/examples/Simple/bank/AccountManager_i.cpp b/TAO/examples/Simple/bank/AccountManager_i.cpp index 6a28b463130..a8ac022b373 100644 --- a/TAO/examples/Simple/bank/AccountManager_i.cpp +++ b/TAO/examples/Simple/bank/AccountManager_i.cpp @@ -55,7 +55,7 @@ AccountManager_i::open (const char *name, if (hash_map_.find (name, result) != 0) { ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Opening a new Account for %s with balance %f\n", + "[SERVER] Process/Thread Id : (%P/%t) Opening Account (%s,%8.2f)\n", name, initial_balance)); @@ -80,7 +80,7 @@ AccountManager_i::open (const char *name, else if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, - "\nAccount already exists for %s\n", + "[SERVER] Process/Thread Id : (%P/%t) Account already exists for %s\n", name)); // Generate an IOR for the result object and register it with // the POA. In case the object already exists then the @@ -117,7 +117,7 @@ AccountManager_i::close (Bank::Account_ptr account, } else if (TAO_debug_level > 0) ACE_DEBUG((LM_DEBUG, - "Closing Account for %s\n", + "[SERVER] Process/Thread Id : (%P/%t) Closing Account for %s\n", (char *) name)); } @@ -132,7 +132,7 @@ void AccountManager_i::shutdown (CORBA::Environment &) { ACE_DEBUG ((LM_DEBUG, - "%s\n", + "\n[SERVER] Process/Thread Id : (%P/%t) %s\n", "AccountManager_i is shutting down")); // Instruct the ORB to shutdown. diff --git a/TAO/examples/Simple/bank/Account_i.cpp b/TAO/examples/Simple/bank/Account_i.cpp index b35ed2ad370..7c5a3d5f21a 100644 --- a/TAO/examples/Simple/bank/Account_i.cpp +++ b/TAO/examples/Simple/bank/Account_i.cpp @@ -14,8 +14,8 @@ Account_i::Account_i (void) Account_i::Account_i (const char *name, CORBA::Float balance) - : name_ (CORBA::string_dup (name)), - balance_ (balance) + : balance_ (balance), + name_ (CORBA::string_dup (name)) { } @@ -56,7 +56,7 @@ Account_i::withdraw (CORBA::Float withdrawl, if (balance_ >= withdrawl) balance_ -= withdrawl; else - env.exception (new Bank::Account::Overdraft("Exception from server::Overdraft")); + env.exception (new Bank::Account::Overdraft("Exception::Overdraft\n")); } char * diff --git a/TAO/examples/Simple/bank/Client_i.cpp b/TAO/examples/Simple/bank/Client_i.cpp index 355017ff26a..7add8b64c14 100644 --- a/TAO/examples/Simple/bank/Client_i.cpp +++ b/TAO/examples/Simple/bank/Client_i.cpp @@ -27,7 +27,7 @@ Client_i::read_ior (char *filename) if (f_handle == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, - "Unable to open %s for writing: %p\n", + "[CLIENT] Process/Thread Id : (%P/%t) Unable to open %s for writing: %p\n", filename), -1); @@ -36,7 +36,7 @@ Client_i::read_ior (char *filename) if (data == 0) ACE_ERROR_RETURN ((LM_ERROR, - "Unable to read ior: %p\n"), + "[CLIENT] Process/Thread Id : (%P/%t) Unable to read ior: %p\n"), -1); this->ior_ = ACE_OS::strdup (data); @@ -69,8 +69,6 @@ Client_i::parse_args (void) break; case 'b': // initial balance this->initial_balance_ = (float) ACE_OS::atoi (get_opts.optarg); - ACE_DEBUG((LM_DEBUG,"bal = %f", - initial_balance_)); break; case 'y': // Name of one account holder. this->account_holder_name1_ = ACE_OS::strdup (get_opts.optarg); @@ -85,7 +83,7 @@ Client_i::parse_args (void) result = this->read_ior (get_opts.optarg); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR, - "Unable to read ior from %s : %p\n", + "[CLIENT] Process/Thread Id : (%P/%t) Unable to read ior from %s : %p\n", get_opts.optarg), -1); break; @@ -139,7 +137,7 @@ Client_i::withdraw (Bank::Account_ptr server, (TAO_TRY_ENV.exception ()); ACE_DEBUG ((LM_DEBUG, - "Exception : %s", + "[CLIENT] Process/Thread Id : (%P/%t) %s", (char *) except->reason)); } TAO_ENDTRY; @@ -227,10 +225,18 @@ Client_i::check_accounts (void) { TAO_TRY { + ACE_DEBUG((LM_DEBUG, + "\n[CLIENT] Process/Thread Id : (%P/%t):Test for Accounts with same name\n")); this->test_for_same_name (this->env_); TAO_CHECK_ENV; + + ACE_DEBUG((LM_DEBUG, + "\n[CLIENT] Process/Thread Id : (%P/%t):Test for Accounts with different name\n")); this->test_for_different_name (this->env_); TAO_CHECK_ENV; + + ACE_DEBUG((LM_DEBUG, + "\n[CLIENT] Process/Thread Id : (%P/%t):Test for Overdraft Exception\n")); this->test_for_overdraft (this->env_); TAO_CHECK_ENV; } @@ -262,7 +268,7 @@ Client_i::run (void) TAO_CATCHANY { ACE_DEBUG ((LM_DEBUG, - "Unable to shut down the server\n")); + "[CLIENT] Process/Thread Id : (%P/%t) Unable to shut down the server\n")); } TAO_ENDTRY; @@ -283,7 +289,7 @@ Client_i::obtain_initial_references (void) // Initialize the naming services. if (my_name_client_.init (orb_.in ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to initialize " + "[CLIENT] Process/Thread Id : (%P/%t) Unable to initialize " "the TAO_Naming_Client. \n"), -1); @@ -355,13 +361,13 @@ Client_i::init (int argc, char **argv) TAO_TRY_ENV); ACE_DEBUG ((LM_DEBUG, - "Using the IOR provided\n")); + "[CLIENT] Process/Thread Id : (%P/%t) Using the IOR provided\n")); TAO_CHECK_ENV; } else { // No IOR specified. Use the Naming Service ACE_DEBUG((LM_DEBUG, - "Using the Naming Service\n")); + "[CLIENT] Process/Thread Id : (%P/%t) Using the Naming Service\n")); this->obtain_initial_references (); TAO_CHECK_ENV; diff --git a/TAO/examples/Simple/bank/README b/TAO/examples/Simple/bank/README index 8df6a587d9e..048a0cb9b21 100644 --- a/TAO/examples/Simple/bank/README +++ b/TAO/examples/Simple/bank/README @@ -1,11 +1,19 @@ $Id$ This is a simple CORBA example that has a module Bank with two -interfaces Account and AccountManager. The Account interface has a -method to return the balance in that account. The AccountManager -interface has a method to create a new Account and return the IOR of -this to the client. The two interfaces also have methods to shutdown -the server. +interfaces Account and AccountManager. + +The Account interface has operations for balance, deposit and withdraw. It has a readonly attribute for the Account Holder's name. It also has a user defined exception which is raised for withdrawing more moneythen the current balance. + +The AccountManager interface has methods to create and close Accounts. +It also has a method to shutdown the server. + +run_test.pl : This is a perl script to run the server and client as : + + server + client -x -b 100 -y Vishal -z Kachroo + + There are other command line options available for the server and client which are explained as below. server: ------- @@ -45,4 +53,10 @@ Options: -k Read IOR from the command line -f Read IOR from the specified file +The client executes the following tests : + +1. Creating accounts with the same name to make sure the Account is created only once and he gets back the same object reference each time. This is confirmed by the server printing the message for Creation of an account only once. + +2. Creating accounts with different name to make sure a different Account is created and a different IOR returned each time. +3. Creating an Account with some initial balance and then withdrawing more than the current balance. The server throws an exception which is passed to the client and the client displays the reason for the exception. diff --git a/TAO/examples/Simple/bank/Server_i.cpp b/TAO/examples/Simple/bank/Server_i.cpp index 03b976d5aef..74752f93664 100644 --- a/TAO/examples/Simple/bank/Server_i.cpp +++ b/TAO/examples/Simple/bank/Server_i.cpp @@ -40,12 +40,13 @@ Server_i::parse_args (void) if (this->ior_output_file_ == 0) ACE_ERROR_RETURN ((LM_ERROR, - "Unable to open %s for writing: %p\n", + "[SERVER] Process/Thread Id : (%P/%t)Unable to open %s for writing: %p\n", get_opts.optarg), -1); break; case '?': // display help for use of the server. default: ACE_ERROR_RETURN ((LM_ERROR, + "[SERVER] Process/Thread Id : (%P/%t)" "usage: %s" " [-d]" " [-o] <ior_output_file>" @@ -76,9 +77,6 @@ Server_i::init_naming_service (CORBA::Environment& env) child_poa); if (result == -1) { - ACE_DEBUG ((LM_DEBUG, - "Result=%d", - result)); return result; } @@ -111,7 +109,7 @@ Server_i::init_naming_service (CORBA::Environment& env) // Print the Account Manager IOR on the console. ACE_DEBUG ((LM_DEBUG, - "The IOR is: <%s>\n", + "[SERVER] Process/Thread Id : (%P/%t) The IOR is: <%s>\n", (const char *) objref)); // Print the Account Manager IOR to a file. @@ -177,7 +175,7 @@ Server_i::run (CORBA::Environment &env) // Run the main event loop for the ORB. if (this->orb_manager_.run (env) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "Server_i::run"), + "[SERVER] Process/Thread Id : (%P/%t) Server_i::run"), -1); return 0; } diff --git a/TAO/examples/Simple/bank/client.cpp b/TAO/examples/Simple/bank/client.cpp index 3686f8a8654..eddf8018816 100644 --- a/TAO/examples/Simple/bank/client.cpp +++ b/TAO/examples/Simple/bank/client.cpp @@ -12,7 +12,7 @@ main (int argc, char *argv[]) Client_i client; ACE_DEBUG ((LM_DEBUG, - "\n\tBank client\n\n")); + "[CLIENT] Process/Thread Id : (%P/%t) Bank client\n")); if (client.init (argc, argv) == -1) return -1; diff --git a/TAO/examples/Simple/bank/server.cpp b/TAO/examples/Simple/bank/server.cpp index e18704205a3..473441fc8d9 100644 --- a/TAO/examples/Simple/bank/server.cpp +++ b/TAO/examples/Simple/bank/server.cpp @@ -12,7 +12,7 @@ main (int argc, char *argv[]) Server_i server; ACE_DEBUG ((LM_DEBUG, - "\n\tBank server\n\n")); + "[SERVER] Process/Thread Id : (%P/%t) Bank server\n")); TAO_TRY { |