summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog57
-rw-r--r--TAO/examples/Simple/Simple_util.cpp256
-rw-r--r--TAO/examples/Simple/Simple_util.h57
-rw-r--r--TAO/examples/Simple/bank/AccountManager_i.cpp44
-rw-r--r--TAO/examples/Simple/bank/AccountManager_i.h8
-rw-r--r--TAO/examples/Simple/bank/Account_i.cpp5
-rw-r--r--TAO/examples/Simple/bank/Account_i.h3
-rw-r--r--TAO/examples/Simple/bank/Bank_Client_i.cpp55
-rw-r--r--TAO/examples/Simple/bank/Bank_Client_i.h10
-rw-r--r--TAO/examples/Simple/bank/client.cpp9
-rw-r--r--TAO/examples/Simple/bank/server.cpp5
-rw-r--r--TAO/examples/Simple/chat/Broadcaster_i.cpp3
-rw-r--r--TAO/examples/Simple/chat/Broadcaster_i.h4
-rw-r--r--TAO/examples/Simple/chat/Client_i.cpp118
-rw-r--r--TAO/examples/Simple/chat/Client_i.h13
-rw-r--r--TAO/examples/Simple/chat/Receiver_i.cpp2
-rw-r--r--TAO/examples/Simple/chat/Receiver_i.h2
-rw-r--r--TAO/examples/Simple/chat/Server_i.cpp36
-rw-r--r--TAO/examples/Simple/chat/Server_i.h20
-rw-r--r--TAO/examples/Simple/chat/server.cpp5
-rw-r--r--TAO/examples/Simple/echo/Echo_Client_i.cpp18
-rw-r--r--TAO/examples/Simple/echo/Echo_Client_i.h10
-rw-r--r--TAO/examples/Simple/echo/Echo_i.cpp3
-rw-r--r--TAO/examples/Simple/echo/Echo_i.h4
-rw-r--r--TAO/examples/Simple/echo/client.cpp6
-rw-r--r--TAO/examples/Simple/echo/server.cpp5
-rw-r--r--TAO/examples/Simple/grid/Grid.idl2
-rw-r--r--TAO/examples/Simple/grid/Grid_Client_i.cpp85
-rw-r--r--TAO/examples/Simple/grid/Grid_Client_i.h10
-rw-r--r--TAO/examples/Simple/grid/Grid_i.cpp125
-rw-r--r--TAO/examples/Simple/grid/Grid_i.h20
-rw-r--r--TAO/examples/Simple/grid/client.cpp6
-rw-r--r--TAO/examples/Simple/grid/server.cpp4
-rw-r--r--TAO/examples/Simple/time-date/Time_Date.cpp85
-rw-r--r--TAO/examples/Simple/time-date/Time_Date.h13
-rw-r--r--TAO/examples/Simple/time-date/Time_Date.idl3
-rw-r--r--TAO/examples/Simple/time-date/Time_Date_Client_i.cpp9
-rw-r--r--TAO/examples/Simple/time-date/Time_Date_Client_i.h2
-rw-r--r--TAO/examples/Simple/time-date/Time_Date_i.cpp18
-rw-r--r--TAO/examples/Simple/time-date/Time_Date_i.h4
-rw-r--r--TAO/examples/Simple/time-date/client.cpp2
-rwxr-xr-xTAO/examples/Simple/time-date/run_test.pl9
-rw-r--r--TAO/examples/Simple/time/Time_Client_i.cpp25
-rw-r--r--TAO/examples/Simple/time/Time_Client_i.h9
-rw-r--r--TAO/examples/Simple/time/Time_i.cpp9
-rw-r--r--TAO/examples/Simple/time/Time_i.h3
-rw-r--r--TAO/examples/Simple/time/client.cpp7
-rw-r--r--TAO/examples/Simple/time/server.cpp5
-rw-r--r--TAO/tao/HTTP_Parser.cpp8
49 files changed, 654 insertions, 567 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index c52ee8f9536..04845eefce6 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,60 @@
+Mon Oct 20 09:42:14 UTC 2008 Vladimir Zykov <vzykov@prismtech.com>
+
+ * tao/HTTP_Parser.cpp:
+
+ Fixed incorrect use of ACE_TEXT_CHAR_TO_TCHAR.
+
+ * examples/Simple/chat/Broadcaster_i.cpp:
+ * examples/Simple/chat/server.cpp:
+ * examples/Simple/chat/Broadcaster_i.h:
+ * examples/Simple/chat/Receiver_i.cpp:
+ * examples/Simple/chat/Server_i.cpp:
+ * examples/Simple/chat/Receiver_i.h:
+ * examples/Simple/chat/Server_i.h:
+ * examples/Simple/chat/Client_i.cpp:
+ * examples/Simple/chat/Client_i.h:
+ * examples/Simple/grid/client.cpp:
+ * examples/Simple/grid/Grid_Client_i.h:
+ * examples/Simple/grid/Grid_i.h:
+ * examples/Simple/grid/server.cpp:
+ * examples/Simple/grid/Grid.idl:
+ * examples/Simple/grid/Grid_Client_i.cpp:
+ * examples/Simple/grid/Grid_i.cpp:
+ * examples/Simple/Simple_util.cpp:
+ * examples/Simple/time-date/Time_Date.h:
+ * examples/Simple/time-date/Time_Date_Client_i.cpp:
+ * examples/Simple/time-date/Time_Date_i.cpp:
+ * examples/Simple/time-date/Time_Date_Client_i.h:
+ * examples/Simple/time-date/Time_Date_i.h:
+ * examples/Simple/time-date/client.cpp:
+ * examples/Simple/time-date/Time_Date.idl:
+ * examples/Simple/time-date/Time_Date.cpp:
+ * examples/Simple/time-date/run_test.pl:
+ * examples/Simple/bank/client.cpp:
+ * examples/Simple/bank/AccountManager_i.cpp:
+ * examples/Simple/bank/Bank_Client_i.cpp:
+ * examples/Simple/bank/AccountManager_i.h:
+ * examples/Simple/bank/Account_i.cpp:
+ * examples/Simple/bank/Bank_Client_i.h:
+ * examples/Simple/bank/server.cpp:
+ * examples/Simple/bank/Account_i.h:
+ * examples/Simple/Simple_util.h:
+ * examples/Simple/echo/client.cpp:
+ * examples/Simple/echo/Echo_Client_i.cpp:
+ * examples/Simple/echo/Echo_i.cpp:
+ * examples/Simple/echo/server.cpp:
+ * examples/Simple/echo/Echo_Client_i.h:
+ * examples/Simple/echo/Echo_i.h:
+ * examples/Simple/time/client.cpp:
+ * examples/Simple/time/Time_Client_i.cpp:
+ * examples/Simple/time/Time_i.cpp:
+ * examples/Simple/time/server.cpp:
+ * examples/Simple/time/Time_Client_i.h:
+ * examples/Simple/time/Time_i.h:
+
+ Fixed bugs and memory leaks in these examples. Refactored some
+ of the code to make it more readable and more in TAO spirit.
+
Sun Oct 19 05:51:00 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
* orbsvcs/orbsvcs/Naming/Flat_File_Persistence.cpp:
diff --git a/TAO/examples/Simple/Simple_util.cpp b/TAO/examples/Simple/Simple_util.cpp
index 66afb322063..dc289b3bbb1 100644
--- a/TAO/examples/Simple/Simple_util.cpp
+++ b/TAO/examples/Simple/Simple_util.cpp
@@ -12,29 +12,33 @@
#include "ace/OS_NS_fcntl.h"
// Constructor.
-
template <class Servant>
Server<Servant>::Server (void)
- : ior_output_file_ (0),
- naming_ (0),
- ins_ (0)
+ : servant_ (0)
+ , ior_output_file_ (0)
+ , naming_ (0)
+ , ins_ (0)
{
- // no-op.
+ Servant *tmp = 0;
+ ACE_NEW_THROW_EX (tmp,
+ Servant (),
+ CORBA::NO_MEMORY ());
+ this->servant_ = tmp;
}
// Destructor.
-
template <class Servant>
Server<Servant>::~Server (void)
{
}
// Parse the command-line arguments and set options.
-
template <class Servant> int
Server<Servant>::parse_args (void)
{
- ACE_Get_Opt get_opts (this->argc_, this->argv_, ACE_TEXT("do:ni:"));
+ ACE_Get_Opt get_opts (this->argc_, this->argv_,
+ ACE_TEXT ("do:ni:"), 1, 0,
+ ACE_Get_Opt::REQUIRE_ORDER);
int c = 0;
while ((c = get_opts ()) != -1)
@@ -44,29 +48,24 @@ Server<Servant>::parse_args (void)
TAO_debug_level++;
break;
case 'o': // output the IOR to a file.
- this->ior_output_file_ = ACE_OS::fopen (get_opts.opt_arg (), "w");
- if (this->ior_output_file_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to open %s for writing: %p\n",
- get_opts.opt_arg ()), -1);
+ this->ior_output_file_ = get_opts.opt_arg ();
break;
-
case 'n': //Use naming service
this->naming_ = 1;
break;
case 'i': // For Testing the InterOperable Naming Service.
- this->ins_ = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ()));
+ this->ins_ = get_opts.opt_arg ();
break;
case 'h': // display help for use of the server.
default:
ACE_ERROR_RETURN ((LM_ERROR,
- "usage: %s"
- " [-d (debug)]"
- " [-o] <ior_output_file>"
- " [-n (use naming service)]"
- " [-i] <InterOperable Naming Service simple object key>"
- " [-h (help)]"
- "\n",
+ ACE_TEXT ("usage: %s")
+ ACE_TEXT (" [-d (debug)]")
+ ACE_TEXT (" [-o] <ior_output_file>")
+ ACE_TEXT (" [-n (use naming service)]")
+ ACE_TEXT (" [-i] <InterOperable Naming Service simple object key>")
+ ACE_TEXT (" [-h (help)]")
+ ACE_TEXT ("\n"),
this->argv_ [0]),
-1);
}
@@ -78,18 +77,16 @@ Server<Servant>::parse_args (void)
// Add the ObjectID:IOR mapping to the IOR table of
// the ORB. Ignore this method if you are not testing for
// the InterOperable Naming Service.
-
template <class Servant> int
-Server<Servant>::test_for_ins (CORBA::String_var ior)
+Server<Servant>::test_for_ins (const char *ior)
{
CORBA::ORB_var orb = this->orb_manager_.orb ();
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "Adding (KEY:IOR) %C:%C\n",
+ ACE_TEXT ("Adding (KEY:IOR) %s:%C\n"),
this->ins_,
- ior.in ()));
-
+ ior));
try
{
@@ -100,13 +97,17 @@ Server<Servant>::test_for_ins (CORBA::String_var ior)
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
- ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Nil IORTable\n")),
+ -1);
}
- adapter->bind (this->ins_, ior.in ());
+ adapter->bind (ACE_TEXT_ALWAYS_CHAR (this->ins_), ior);
}
- catch (const CORBA::Exception&)
+ catch (const CORBA::Exception& ex)
{
+ ex._tao_print_exception ("ERROR: test_for_ins failed\n");
+ return -1;
}
return 0;
@@ -124,11 +125,10 @@ Server<Servant>::init (const char *servant_name,
argv,
"child_poa") == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "init_child_poa"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("init_child_poa")),
-1);
-
this->argc_ = argc;
this->argv_ = argv;
@@ -140,55 +140,53 @@ Server<Servant>::init (const char *servant_name,
CORBA::ORB_var orb = this->orb_manager_.orb ();
// Stash our ORB pointer for later reference.
- this->servant_.orb (orb.in ());
+ this->servant_->orb (orb.in ());
if (this->naming_ == 1)
{
-
- // Save name in case we use TAO Naming Service.
- name = servant_name;
-
// Call naming service
- if (this->register_name () == -1)
+ if (this->register_name (servant_name) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "\n Naming Service\n"),-1);
+ ACE_TEXT ("\n Naming Service\n")),
+ -1);
return 0;
}
// Activate the servant in its own child POA.
- // Make sure that you check for failures here via the ACE_TRY
- // macros?!
+ // Make sure that you check for failures here via the try?!
try
{
CORBA::String_var str =
this->orb_manager_.activate_under_child_poa (servant_name,
- &this->servant_);
+ this->servant_.in ());
ACE_DEBUG ((LM_DEBUG,
- "The IOR is: <%C>\n",
+ ACE_TEXT ("The IOR is: <%C>\n"),
str.in ()));
- if (this->ins_)
- if (this->test_for_ins (str) != 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "test_for_ins (): failed\n"),
- -1);
+ if (this->ins_ && this->test_for_ins (str) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("test_for_ins (): failed\n")),
+ -1);
if (this->ior_output_file_)
{
- ACE_OS::fprintf (this->ior_output_file_,
- "%s",
- str.in ());
- ACE_OS::fclose (this->ior_output_file_);
+ FILE *fh = ACE_OS::fopen (this->ior_output_file_, "w");
+ if (fh == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unable to open %s for writing (%p)\n"),
+ this->ior_output_file_,
+ ACE_TEXT ("fopen")),
+ -1);
+ ACE_OS::fprintf (fh, "%s", str.in ());
+ ACE_OS::fclose (fh);
}
-
}
catch (const CORBA::Exception& ex)
{
- ex._tao_print_exception (
- "\tException in activation of POA");
+ ex._tao_print_exception ("\tException in activation of POA");
return -1;
}
@@ -201,16 +199,14 @@ Server<Servant>::run (void)
// Run the main event loop for the ORB.
if (this->orb_manager_.run () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "Server_i::run"),
+ ACE_TEXT ("Server_i::run")),
-1);
- this->orb_manager_.fini ();
-
return 0;
}
template <class Servant> int
-Server<Servant>::register_name (void)
+Server<Servant>::register_name (const char *name)
{
CORBA::ORB_var orb = this->orb_manager_.orb ();
@@ -222,11 +218,10 @@ Server<Servant>::register_name (void)
bindName.length (1);
bindName[0].id = CORBA::string_dup (name);
-
// (re)Bind the object.
try
{
- CORBA::Object_var object = servant_._this ();
+ CORBA::Object_var object = servant_->_this ();
this->orb_manager_.activate_poa_manager ();
@@ -240,14 +235,14 @@ Server<Servant>::register_name (void)
orb->object_to_string (object.in ());
if (this->test_for_ins (ior.in ()) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "test_for_ins (): failed\n"),
+ ACE_TEXT ("test_for_ins (): failed\n")),
-1);
}
}
catch (const CosNaming::NamingContext::AlreadyBound&)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to bind %C\n",
+ ACE_TEXT ("Unable to bind %C \n"),
name),
-1);
}
@@ -256,27 +251,26 @@ Server<Servant>::register_name (void)
}
// Constructor.
-
-template <class INTERFACE_OBJECT, class Var>
-Client<INTERFACE_OBJECT, Var>::Client (void)
- : ior_ (0),
- shutdown_ (0)
+template <class ServerInterface>
+Client<ServerInterface>::Client (void)
+ : ior_ ("")
+ , do_shutdown_ (0)
{
//no-op
}
// Reads the Server ior from a file
-
-template <class INTERFACE_OBJECT, class Var> int
-Client<INTERFACE_OBJECT, Var>::read_ior (ACE_TCHAR *filename)
+template <class ServerInterface> int
+Client<ServerInterface>::read_ior (ACE_TCHAR *filename)
{
// Open the file for reading.
ACE_HANDLE f_handle = ACE_OS::open (filename, 0);
if (f_handle == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to open %s for writing: %p\n",
- filename),
+ ACE_TEXT ("Unable to open %s for writing (%p)\n"),
+ filename,
+ ACE_TEXT ("open")),
-1);
ACE_Read_Buffer ior_buffer (f_handle);
@@ -284,10 +278,11 @@ Client<INTERFACE_OBJECT, Var>::read_ior (ACE_TCHAR *filename)
if (data == 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to read ior: %p\n"),
+ ACE_TEXT ("Unable to read ior (%p)\n"),
+ ACE_TEXT ("read")),
-1);
- this->ior_ = ACE_OS::strdup (data);
+ this->ior_ = data;
ior_buffer.alloc ()->free (data);
ACE_OS::close (f_handle);
@@ -296,11 +291,12 @@ Client<INTERFACE_OBJECT, Var>::read_ior (ACE_TCHAR *filename)
}
// Parses the command line arguments and returns an error status.
-
-template <class INTERFACE_OBJECT, class Var> int
-Client<INTERFACE_OBJECT, Var>::parse_args (void)
+template <class ServerInterface> int
+Client<ServerInterface>::parse_args (void)
{
- ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("df:nk:x"));
+ ACE_Get_Opt get_opts (argc_, argv_,
+ ACE_TEXT ("df:nk:x"), 1, 0,
+ ACE_Get_Opt::REQUIRE_ORDER);
int c = 0;
int result = 0;
@@ -311,7 +307,7 @@ Client<INTERFACE_OBJECT, Var>::parse_args (void)
TAO_debug_level++;
break;
case 'k': // ior provide on command line
- this->ior_ = ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ()));
+ this->ior_ = ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ());
break;
case 'n': // Use naming service
this->naming_ = 1;
@@ -320,23 +316,24 @@ Client<INTERFACE_OBJECT, Var>::parse_args (void)
result = this->read_ior (get_opts.opt_arg ());
if (result < 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to read ior from %s : %p\n",
- get_opts.opt_arg ()),
+ ACE_TEXT ("Unable to read ior from %s (%p)\n"),
+ get_opts.opt_arg (),
+ ACE_TEXT ("read_ior")),
-1);
break;
case 'x': // read the flag for shutting down
- this->shutdown_ = 1;
+ this->do_shutdown_ = 1;
break;
case 'h': // display help for use of the client.
ACE_ERROR_RETURN ((LM_ERROR,
- "usage: %s"
- " [-d (debug)]"
- " [-k] <ior>"
- " [-f] <ior_output_file>"
- " [-n (use naming service)]"
- " [-x (shutdown server)]"
- " [-h (help)]"
- "\n",
+ ACE_TEXT ("usage: %s")
+ ACE_TEXT (" [-d (debug)]")
+ ACE_TEXT (" [-k] <ior>")
+ ACE_TEXT (" [-f] <ior_output_file>")
+ ACE_TEXT (" [-n (use naming service)]")
+ ACE_TEXT (" [-x (shutdown server)]")
+ ACE_TEXT (" [-h (help)]")
+ ACE_TEXT ("\n"),
this->argv_ [0]),
-1);
}
@@ -345,18 +342,16 @@ Client<INTERFACE_OBJECT, Var>::parse_args (void)
return 0;
}
-template <class INTERFACE_OBJECT, class Var>
-Client<INTERFACE_OBJECT, Var>::~Client (void)
+template <class ServerInterface>
+Client<ServerInterface>::~Client (void)
{
- ACE_OS::free (this->ior_);
-
this->orb_->destroy ();
}
-template <class INTERFACE_OBJECT, class Var> int
-Client<INTERFACE_OBJECT, Var>::init (const char *name,
- int argc,
- ACE_TCHAR **argv)
+template <class ServerInterface> int
+Client<ServerInterface>::init (const char *name,
+ int argc,
+ ACE_TCHAR **argv)
{
this->argc_ = argc;
this->argv_ = argv;
@@ -370,32 +365,36 @@ Client<INTERFACE_OBJECT, Var>::init (const char *name,
if (this->parse_args () == -1)
return -1;
- if(this->ior_ != 0)
+ if (this->ior_.length () != 0)
{
CORBA::Object_var server_object =
- this->orb_->string_to_object (this->ior_);
-
+ this->orb_->string_to_object (this->ior_.c_str ());
if (CORBA::is_nil (server_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
- "invalid ior <%C>\n",
- this->ior_),
+ ACE_TEXT ("invalid ior <%C>\n"),
+ this->ior_.c_str ()),
-1);
- this->server_ = INTERFACE_OBJECT::_narrow (server_object.in ());
+ this->server_ = ServerInterface::_narrow (server_object.in ());
+ if (CORBA::is_nil (this->server_.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Nil Server\n")),
+ -1);
+ }
}
else if (this->naming_ == 1)
{
// No IOR specified. Use the Naming Service
ACE_DEBUG((LM_DEBUG,
- "Using the Naming Service \n"));
- this->name_ = const_cast<char *> (name);
- int retv = this->obtain_initial_references ();
+ ACE_TEXT ("Using the Naming Service \n")));
+ int retv = this->obtain_initial_references (name);
if (retv ==-1)
return -1;
}
else
ACE_ERROR_RETURN ((LM_ERROR,
- "no ior or naming options specified\n"),
+ ACE_TEXT ("no ior or naming options specified\n")),
-1);
@@ -406,56 +405,57 @@ Client<INTERFACE_OBJECT, Var>::init (const char *name,
return -1;
}
-
return 0;
}
-
-template <class INTERFACE_OBJECT, class Var> int
-Client<INTERFACE_OBJECT, Var>::obtain_initial_references (void)
+template <class ServerInterface> int
+Client<ServerInterface>::obtain_initial_references (const char *name)
{
-
try
{
// Initialize the naming services.
if (naming_client_.init (orb_.in ()) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "[CLIENT] Process/Thread Id : (%P/%t) Unable to initialize "
- "the TAO_Naming_Client. \n"),
+ ACE_TEXT ("[CLIENT] Process/Thread Id : (%P/%t) Unable to initialize ")
+ ACE_TEXT ("the TAO_Naming_Client. \n")),
-1);
-
CosNaming::Name server_name (1);
server_name.length (1);
server_name[0].id =
- CORBA::string_dup (this->name_);
+ CORBA::string_dup (name);
CORBA::Object_var obj =
naming_client_->resolve (server_name);
- this->server_ = INTERFACE_OBJECT::_narrow (obj.in ());
+ this->server_ = ServerInterface::_narrow (obj.in ());
+ if (CORBA::is_nil (this->server_.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Nil Server\n")),
+ -1);
+ }
}
catch (const CORBA::Exception& ex)
{
- ex._tao_print_exception (
- "Client::obtain_initial_references");
+ ex._tao_print_exception ("Client::obtain_initial_references");
return -1;
}
return 0;
}
-template <class INTERFACE_OBJECT, class Var> int
-Client<INTERFACE_OBJECT, Var>::shutdown (void)
+template <class ServerInterface> int
+Client<ServerInterface>::do_shutdown (void)
{
// Returns the shutdwon flag
- return shutdown_;
+ return this->do_shutdown_;
}
-template <class INTERFACE_OBJECT, class Var> void
-Client<INTERFACE_OBJECT, Var>::shutdown (int flag)
+template <class ServerInterface> void
+Client<ServerInterface>::do_shutdown (int flag)
{
// Fills the flag
- shutdown_ = flag;
+ this->do_shutdown_ = flag;
}
#endif /* SIMPLE_UTIL_C */
diff --git a/TAO/examples/Simple/Simple_util.h b/TAO/examples/Simple/Simple_util.h
index 00e3d9213f2..9808d1e1a19 100644
--- a/TAO/examples/Simple/Simple_util.h
+++ b/TAO/examples/Simple/Simple_util.h
@@ -23,6 +23,7 @@
#include "orbsvcs/Naming/Naming_Client.h"
#include "ace/Get_Opt.h"
#include "ace/Read_Buffer.h"
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
template <class Servant>
class Server
@@ -51,27 +52,25 @@ public:
// Initialize the Server state - parsing arguments and waiting.
// interface_name is the name used to register the Servant.
- int register_name (void);
+ int register_name (const char *name);
// After calling <init>, this method will register the server with
- // the TAO Naming Service using the servant_name passed to <init>.
+ // the TAO Naming Service using the name passed to this method.
int run (void);
// Run the orb.
- int test_for_ins (CORBA::String_var ior);
+ int test_for_ins (const char *ior);
// Ignore this method if you are not testing the InterOperable
// Naming Service.
-protected:
- Servant servant_;
- // Servant class
-
- const char *name;
- // name of the servant to be used for TAO Naming Service
-
+private:
int parse_args (void);
// Parses the commandline arguments.
+ typedef TAO_Intrusive_Ref_Count_Handle<Servant> Servant_var;
+ Servant_var servant_;
+ // A holder of the servant that does ref counting for him.
+
TAO_ORB_Manager orb_manager_;
// The ORB manager - a helper class for accessing the POA and
// registering objects.
@@ -79,13 +78,13 @@ protected:
TAO_Naming_Client naming_client_;
// helper class for getting access to Naming Service.
- FILE *ior_output_file_;
+ ACE_TCHAR *ior_output_file_;
// File where the IOR of the server object is stored.
int naming_;
// Flag to indicate whether naming service could be used
- char *ins_;
+ ACE_TCHAR *ins_;
// Used test the INS.
int argc_;
@@ -95,7 +94,7 @@ protected:
// The command line arguments.
};
-template <class INTERFACE_OBJECT, class Var>
+template <class ServerInterface>
class Client
{
// = TITLE
@@ -114,32 +113,36 @@ public:
~Client (void);
// Destructor.
- int init (const char *name,int argc, ACE_TCHAR *argv[]);
+ int init (const char *name, int argc, ACE_TCHAR *argv[]);
// Initialize the client communication endpoint with server.
- INTERFACE_OBJECT *operator-> () { return server_.in ();};
+ ServerInterface *operator-> () { return server_.in (); }
// Return the interface object pointer.
- int shutdown (void );
+ int do_shutdown (void);
// Returns the shutdown flag.
- void shutdown (int);
+ void do_shutdown (int);
// Fills in the shutdwon flag.
- int obtain_initial_references (void);
+ int obtain_initial_references (const char *name);
// Initialize naming service
- CORBA::ORB_ptr orb (void) {return this->orb_.in ();}
-protected:
- CORBA::ORB_var orb_;
- // Remember our orb.
+ CORBA::ORB_ptr orb (void)
+ {
+ return CORBA::ORB::_duplicate (this->orb_.in ());
+ }
+private:
int read_ior (ACE_TCHAR *filename);
// Function to read the server IOR from a file.
int parse_args (void);
// Parses the arguments passed on the command line.
+ CORBA::ORB_var orb_;
+ // Remember our orb.
+
TAO_Naming_Client naming_client_;
// helper class for getting access to Naming Service.
@@ -149,19 +152,17 @@ protected:
ACE_TCHAR **argv_;
// arguments from command line.
- char *ior_;
+ ACE_CString ior_;
// IOR of the obj ref of the server.
- char *name_;
- // Name to be usred for the naming service
-
- Var server_;
+ typedef TAO_Intrusive_Ref_Count_Handle<ServerInterface> ServerInterface_var;
+ ServerInterface_var server_;
// Server object
int naming_;
// Flag to use the naming service
- int shutdown_;
+ int do_shutdown_;
// Flag for shutting down the server
};
diff --git a/TAO/examples/Simple/bank/AccountManager_i.cpp b/TAO/examples/Simple/bank/AccountManager_i.cpp
index b306eb2bddd..1388f51b02b 100644
--- a/TAO/examples/Simple/bank/AccountManager_i.cpp
+++ b/TAO/examples/Simple/bank/AccountManager_i.cpp
@@ -8,26 +8,17 @@
ACE_RCSID(AccountManager, AccountManager_i, "$Id$")
// Constructor
-
AccountManager_i::AccountManager_i (void)
{
// no-op
}
// Destructor
-
AccountManager_i::~AccountManager_i (void)
{
- for (MAP_MANAGER_TYPE::ITERATOR iter = this->hash_map_.begin ();
- iter != this->hash_map_.end ();
- ++iter)
- {
- delete (*iter).int_id_;
- }
}
// Set the ORB pointer
-
void
AccountManager_i::orb (CORBA::ORB_ptr o)
{
@@ -37,7 +28,7 @@ AccountManager_i::orb (CORBA::ORB_ptr o)
void
AccountManager_i::poa (PortableServer::POA_ptr poa)
{
- this->poa_ = poa;
+ this->poa_ = PortableServer::POA::_duplicate (poa);
}
void
@@ -52,22 +43,22 @@ Bank::Account_ptr
AccountManager_i::open (const char *name,
CORBA::Float initial_balance)
{
- Account_i *result = 0;
-
// If name is already in the map, <find> will assign <result> to the
// appropriate value.
-
+ Account_i_var result;
if (hash_map_.find (name, result) != 0)
{
ACE_DEBUG ((LM_DEBUG,
- "[SERVER] Process/Thread Id : (%P/%t) Opening Account (%s,%8.2f)\n",
+ ACE_TEXT ("[SERVER] Process/Thread Id : (%P/%t) Opening Account (%C,%8.2f)\n"),
name,
initial_balance));
- ACE_NEW_THROW_EX (result,
+ Account_i *tmp = 0;
+ ACE_NEW_THROW_EX (tmp,
Account_i (name,
initial_balance),
CORBA::NO_MEMORY ());
+ result = tmp;
// Enter the new Account in the hash map. If the <bind> fails
// throw an UNKNOWN exception. <result> may be valid but since
@@ -76,13 +67,13 @@ AccountManager_i::open (const char *name,
if (hash_map_.bind (name, result) == -1)
{
- delete result;
throw CORBA::UNKNOWN ();
}
}
- else if (TAO_debug_level > 0)
+
+ if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "[SERVER] Process/Thread Id : (%P/%t) Account already exists for %s\n",
+ ACE_TEXT ("[SERVER] Process/Thread Id : (%P/%t) Account already exists for %C\n"),
name));
// Generate an IOR for the result object and register it with the
// POA. In case the object already exists then the previously
@@ -92,7 +83,6 @@ AccountManager_i::open (const char *name,
}
// Shutdown.
-
void
AccountManager_i::close (Bank::Account_ptr account)
{
@@ -101,26 +91,24 @@ AccountManager_i::close (Bank::Account_ptr account)
CORBA::String_var name = account->name ();
ACE_DEBUG((LM_DEBUG,
- "[SERVER] Process/Thread Id : (%P/%t) Closing Account for %s\n",
+ ACE_TEXT ("[SERVER] Process/Thread Id : (%P/%t) Closing Account for %C\n"),
name.in ()));
- Account_i *account = 0;
+ Account_i_var account;
if (hash_map_.unbind (name.in (), account) == -1)
{
if (TAO_debug_level > 0)
ACE_DEBUG((LM_DEBUG,
- "Unable to close account\n"));
+ ACE_TEXT ("Unable to close account\n")));
}
- if (account)
+ if (account.is_nil ())
{
PortableServer::POA_var poa = account->_default_POA ();
- PortableServer::ObjectId_var id = poa->servant_to_id (account);
+ PortableServer::ObjectId_var id = poa->servant_to_id (account.in ());
poa->deactivate_object (id.in ());
-
- delete account;
}
}
catch (const CORBA::Exception& ex)
@@ -133,10 +121,8 @@ void
AccountManager_i::shutdown (void)
{
ACE_DEBUG ((LM_DEBUG,
- "\n[SERVER] Process/Thread Id : (%P/%t) %s\n",
- "AccountManager_i is shutting down"));
+ ACE_TEXT ("\n[SERVER] Process/Thread Id : (%P/%t) AccountManager_i is shutting down\n")));
// Instruct the ORB to shutdown.
this->orb_->shutdown ();
}
-
diff --git a/TAO/examples/Simple/bank/AccountManager_i.h b/TAO/examples/Simple/bank/AccountManager_i.h
index 2764a9d0941..9e502bc6e72 100644
--- a/TAO/examples/Simple/bank/AccountManager_i.h
+++ b/TAO/examples/Simple/bank/AccountManager_i.h
@@ -33,6 +33,7 @@
#include "ace/ACE.h"
#include "ace/SString.h"
#include "ace/Null_Mutex.h"
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
class TAO_ORB_Manager;
@@ -52,7 +53,7 @@ public:
AccountManager_i (void);
// Constructor.
- ~AccountManager_i (void);
+ virtual ~AccountManager_i (void);
// Destructor.
virtual Bank::Account_ptr open (const char *name,
@@ -82,11 +83,12 @@ private:
CORBA::ORB_var orb_;
// ORB pointer.
- PortableServer::POA_ptr poa_;
+ PortableServer::POA_var poa_;
// POA pointer.
+ typedef TAO_Intrusive_Ref_Count_Handle<Account_i> Account_i_var;
typedef ACE_Hash_Map_Manager<ACE_CString,
- Account_i *,
+ Account_i_var,
ACE_Null_Mutex> MAP_MANAGER_TYPE;
MAP_MANAGER_TYPE hash_map_;
diff --git a/TAO/examples/Simple/bank/Account_i.cpp b/TAO/examples/Simple/bank/Account_i.cpp
index 8f7ea9a9c00..5919b86be8a 100644
--- a/TAO/examples/Simple/bank/Account_i.cpp
+++ b/TAO/examples/Simple/bank/Account_i.cpp
@@ -5,7 +5,6 @@
ACE_RCSID(Bank, Account_i, "$Id$")
// Constructor
-
Account_i::Account_i (void)
{
// no-op
@@ -13,20 +12,17 @@ Account_i::Account_i (void)
Account_i::Account_i (const char *name,
CORBA::Float balance)
-
: balance_ (balance),
name_ (CORBA::string_dup (name))
{
}
// Destructor
-
Account_i::~Account_i (void)
{
}
// Set the ORB pointer.
-
void
Account_i::orb (CORBA::ORB_ptr o)
{
@@ -34,7 +30,6 @@ Account_i::orb (CORBA::ORB_ptr o)
}
// Return the current balance on the server.
-
CORBA::Float
Account_i::balance (void)
{
diff --git a/TAO/examples/Simple/bank/Account_i.h b/TAO/examples/Simple/bank/Account_i.h
index 77d8c2a20e5..68562fc7cc1 100644
--- a/TAO/examples/Simple/bank/Account_i.h
+++ b/TAO/examples/Simple/bank/Account_i.h
@@ -39,11 +39,10 @@ public:
Account_i (const char *, CORBA::Float);
// Constructor.
- ~Account_i (void);
+ virtual ~Account_i (void);
// Destructor.
virtual CORBA::Float balance (void);
-
// Get the current balance in the account.
virtual char *name (void);
diff --git a/TAO/examples/Simple/bank/Bank_Client_i.cpp b/TAO/examples/Simple/bank/Bank_Client_i.cpp
index 9d4f7b4e56e..144374151d6 100644
--- a/TAO/examples/Simple/bank/Bank_Client_i.cpp
+++ b/TAO/examples/Simple/bank/Bank_Client_i.cpp
@@ -19,59 +19,57 @@ Bank_Client_i::~Bank_Client_i (void)
//no-op
}
-
int
Bank_Client_i::run (const char *name,
int argc,
ACE_TCHAR *argv[])
{
// Initialize the client.
- if (client.init (name,argc, argv) == -1)
+ if (client_.init (name, argc, argv) == -1)
return -1;
try
{
this->check_accounts ();
- if (client.shutdown () == 1)
- client->shutdown ();
+ if (client_.do_shutdown () == 1)
+ client_->shutdown ();
}
catch (const CORBA::Exception&)
{
ACE_DEBUG ((LM_DEBUG,
- "\nException caught in run\n"));
+ ACE_TEXT ("\nException caught in run\n")));
}
return 0;
}
int
-Bank_Client_i::check_accounts (void )
+Bank_Client_i::check_accounts (void)
{
try
{
ACE_DEBUG ((LM_DEBUG,
- "\nTests for account with same name\n"));
+ ACE_TEXT ("\nTests for account with same name\n")));
this->test_for_same_name ();
ACE_DEBUG ((LM_DEBUG,
- "\nTests for account with different names\n"));
+ ACE_TEXT ("\nTests for account with different names\n")));
this->test_for_different_name ();
ACE_DEBUG ((LM_DEBUG,
- "\nTests for overdrafts\n"));
+ ACE_TEXT ("\nTests for overdrafts\n")));
this->test_for_overdraft ();
}
catch (const CORBA::Exception&)
{
ACE_DEBUG ((LM_DEBUG,
- "From Bank_Client_i::check_accounts()"));
+ ACE_TEXT ("From Bank_Client_i::check_accounts()")));
}
return 0;
}
// This method tests whether an account with a
// a same name can be opened
-
void
Bank_Client_i::test_for_same_name (void)
{
@@ -79,19 +77,18 @@ Bank_Client_i::test_for_same_name (void)
const char *name = "Name";
CORBA::Float initial_bal = 0.00;
- Bank::Account_var acct_id1 = client->open (name,
- initial_bal);
+ Bank::Account_var acct_id1 = client_->open (name,
+ initial_bal);
- Bank::Account_var acct_id2 = client->open (name,
- initial_bal);
+ Bank::Account_var acct_id2 = client_->open (name,
+ initial_bal);
- ACE_ASSERT (acct_id1->_is_equivalent ((CORBA::Object *) acct_id2.in ()) != 0);
+ ACE_ASSERT (acct_id1->_is_equivalent (acct_id2.in ()) != 0);
- client->close (acct_id1.in ());
+ client_->close (acct_id1.in ());
}
// This method tests whether an account with different names can be opened
-
void
Bank_Client_i::test_for_different_name (void)
{
@@ -100,26 +97,25 @@ Bank_Client_i::test_for_different_name (void)
CORBA::Float initial_bal = 0.0;
- Bank::Account_var acct_id1 = client->open (name1,
- initial_bal);
+ Bank::Account_var acct_id1 = client_->open (name1,
+ initial_bal);
- Bank::Account_var acct_id2 = client->open (name2,
- initial_bal);
- ACE_ASSERT (acct_id1->_is_equivalent ((CORBA::Object *)acct_id2.in ()) == 0);
+ Bank::Account_var acct_id2 = client_->open (name2,
+ initial_bal);
+ ACE_ASSERT (acct_id1->_is_equivalent (acct_id2.in ()) == 0);
- client->close (acct_id1.in ());
+ client_->close (acct_id1.in ());
- client->close (acct_id2.in ());
+ client_->close (acct_id2.in ());
}
// This method tests the Overdraft exception.
-
void
Bank_Client_i::test_for_overdraft (void)
{
CORBA::Float initial_bal = 100.0;
const char *name = "Name";
- Bank::Account_var acct_id = client->open (name, initial_bal);
+ Bank::Account_var acct_id = client_->open (name, initial_bal);
acct_id->deposit (100.00);
CORBA::Float bal = acct_id->balance ();
@@ -131,9 +127,8 @@ Bank_Client_i::test_for_overdraft (void)
catch (Bank::Account::Overdraft &)
{
ACE_DEBUG ((LM_DEBUG,
- "Overdraft caught.\n"));
+ ACE_TEXT ("Overdraft caught.\n")));
}
- client->close (acct_id.in ());
+ client_->close (acct_id.in ());
}
-
diff --git a/TAO/examples/Simple/bank/Bank_Client_i.h b/TAO/examples/Simple/bank/Bank_Client_i.h
index c202e0e1d24..0a3a0c25c10 100644
--- a/TAO/examples/Simple/bank/Bank_Client_i.h
+++ b/TAO/examples/Simple/bank/Bank_Client_i.h
@@ -37,16 +37,13 @@ public:
Bank_Client_i (void);
// Constructor
- virtual ~Bank_Client_i (void);
+ ~Bank_Client_i (void);
// Destructor
- virtual int run (const char *, int, ACE_TCHAR *[]);
+ int run (const char *, int, ACE_TCHAR *[]);
// Execute the methods.
private:
- Client<Bank::AccountManager, Bank::AccountManager_var> client;
- // Instantiate the client object.
-
int check_accounts (void);
// Method that calls all the test functions
@@ -61,6 +58,9 @@ private:
void test_for_overdraft (void);
// Tests for the Overdraft Exception when the client tries to
// withdraw more money than the current balance.
+
+ Client<Bank::AccountManager> client_;
+ // Instantiate the client object.
};
#endif /* TIME_CLIENT_I_H */
diff --git a/TAO/examples/Simple/bank/client.cpp b/TAO/examples/Simple/bank/client.cpp
index 80bac229fe8..297d3e5527f 100644
--- a/TAO/examples/Simple/bank/client.cpp
+++ b/TAO/examples/Simple/bank/client.cpp
@@ -3,21 +3,16 @@
# include "Bank_Client_i.h"
// The client program for the application.
-
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Bank_Client_i client;
-
ACE_DEBUG ((LM_DEBUG,
- "\nBank client\n\n"));
+ ACE_TEXT ("\nBank client\n\n")));
- if (client.run ("Bank",argc, argv) == -1)
+ if (client.run ("Bank", argc, argv) == -1)
return -1;
else
return 0;
-
}
-
-
diff --git a/TAO/examples/Simple/bank/server.cpp b/TAO/examples/Simple/bank/server.cpp
index 48391dd6a60..a1c4987a0dc 100644
--- a/TAO/examples/Simple/bank/server.cpp
+++ b/TAO/examples/Simple/bank/server.cpp
@@ -3,14 +3,13 @@
#include "AccountManager_i.h"
// This is the main driver program for the time and date server.
-
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Server<AccountManager_i> server;
ACE_DEBUG ((LM_DEBUG,
- "\n\tBank server\n\n"));
+ ACE_TEXT ("\n\tBank server\n\n")));
try
{
@@ -34,7 +33,5 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
return -1;
}
-
return 0;
}
-
diff --git a/TAO/examples/Simple/chat/Broadcaster_i.cpp b/TAO/examples/Simple/chat/Broadcaster_i.cpp
index 66d570eac15..3a89e85a703 100644
--- a/TAO/examples/Simple/chat/Broadcaster_i.cpp
+++ b/TAO/examples/Simple/chat/Broadcaster_i.cpp
@@ -154,8 +154,7 @@ Broadcaster_i::broadcast (const char *text)
}
catch (const CORBA::Exception& ex)
{
- ex._tao_print_exception (
- "Failed to send a message\n");
+ ex._tao_print_exception ("Failed to send a message\n");
}
}
}
diff --git a/TAO/examples/Simple/chat/Broadcaster_i.h b/TAO/examples/Simple/chat/Broadcaster_i.h
index e893d69adab..764bd6e808a 100644
--- a/TAO/examples/Simple/chat/Broadcaster_i.h
+++ b/TAO/examples/Simple/chat/Broadcaster_i.h
@@ -41,7 +41,7 @@ public:
Broadcaster_i (void);
// Constructor.
- ~Broadcaster_i (void);
+ virtual ~Broadcaster_i (void);
// Destructor.
virtual void add (Receiver_ptr receiver,
@@ -78,7 +78,7 @@ public:
ACE_CString nickname_;
// Stores the client nickname.
- };
+ };
typedef ACE_Unbounded_Set<Receiver_Data>
RECEIVER_SET;
diff --git a/TAO/examples/Simple/chat/Client_i.cpp b/TAO/examples/Simple/chat/Client_i.cpp
index 0702293f830..863a4dc66c4 100644
--- a/TAO/examples/Simple/chat/Client_i.cpp
+++ b/TAO/examples/Simple/chat/Client_i.cpp
@@ -26,26 +26,21 @@
#include "ace/OS_NS_unistd.h"
Client_i::Client_i ()
- : ior_file_name_ (ACE_TEXT("chat.ior")),
- nickname_ ("noname")
+ : ior_ ("")
+ , ior_file_name_ (ACE_TEXT ("chat.ior"))
+ , nickname_ ("noname")
{
-}
-
-Client_i::~Client_i (void)
-{
- // Make sure to cleanup the STDIN handler.
- if (ACE_Event_Handler::remove_stdin_handler
- (TAO_ORB_Core_instance ()->reactor (),
- TAO_ORB_Core_instance ()->thr_mgr ()) == -1)
- ACE_ERROR ((LM_ERROR,
- "%p\n",
- "remove_stdin_handler"));
+ Receiver_i *tmp = 0;
+ ACE_NEW_THROW_EX (tmp,
+ Receiver_i (),
+ CORBA::NO_MEMORY ());
+ this->receiver_i_ = tmp;
}
int
Client_i::parse_args (int argc, ACE_TCHAR *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("n:f:"));
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("n:f:"));
int c;
while ((c = get_opts ()) != -1)
@@ -62,17 +57,17 @@ Client_i::parse_args (int argc, ACE_TCHAR *argv[])
default: // display help for use of the serve
case '?': // display help for use of the server.
ACE_ERROR_RETURN ((LM_ERROR,
- "usage: %s"
- " [-n <your_nick_name>]"
- " [-f <ior_input_file>]"
- "\n",
+ ACE_TEXT ("usage: %s")
+ ACE_TEXT (" [-n <your_nick_name>]")
+ ACE_TEXT (" [-f <ior_input_file>]")
+ ACE_TEXT ("\n"),
argv [0]),
-1);
}
ACE_DEBUG ((LM_DEBUG,
- "\nusing nickname = %s, filename = %s\n",
- this->nickname_,
+ ACE_TEXT ("\nusing nickname = %C, filename = %s\n"),
+ this->nickname_.c_str (),
this->ior_file_name_));
return 0;
}
@@ -80,10 +75,6 @@ Client_i::parse_args (int argc, ACE_TCHAR *argv[])
int
Client_i::init (int argc, ACE_TCHAR *argv[])
{
- // Check if the command line arguments are ok.
- if (this->parse_args (argc, argv) == -1)
- return -1;
-
try
{
// Retrieve the ORB.
@@ -93,26 +84,36 @@ Client_i::init (int argc, ACE_TCHAR *argv[])
CORBA::ORB_var orb = this->orb_manager_.orb ();
+ // Check if the command line arguments are ok.
+ if (this->parse_args (argc, argv) == -1)
+ return -1;
+
// set the orb in the receiver_i_ object.
- this->receiver_i_.orb (orb.in ());
+ this->receiver_i_->orb (orb.in ());
// read the ior from file
if (this->read_ior (this->ior_file_name_) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "could not read the ior from the file: <%s>\n",
+ ACE_TEXT ("could not read the ior from the file: <%s>\n"),
this->ior_file_name_),
-1);
CORBA::Object_var server_object =
- orb->string_to_object (this->ior_);
+ orb->string_to_object (this->ior_.c_str ());
if (CORBA::is_nil (server_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
- "invalid ior <%s>\n",
- this->ior_),
+ ACE_TEXT ("invalid ior <%C>\n"),
+ this->ior_.c_str ()),
-1);
this->server_ = Broadcaster::_narrow (server_object.in ());
+ if (CORBA::is_nil (this->server_.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Nil Server\n")),
+ -1);
+ }
}
catch (const CORBA::Exception& ex)
{
@@ -120,17 +121,6 @@ Client_i::init (int argc, ACE_TCHAR *argv[])
return -1;
}
- // Register our <Input_Handler> to handle STDIN events, which will
- // trigger the <handle_input> method to process these events.
-
- if (ACE_Event_Handler::register_stdin_handler
- (this,
- TAO_ORB_Core_instance ()->reactor (),
- TAO_ORB_Core_instance ()->thr_mgr ()) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "register_stdin_handler"),
- -1);
return 0;
}
@@ -138,8 +128,8 @@ int
Client_i::run (void)
{
ACE_DEBUG ((LM_DEBUG,
- "\n============= Simple Chat =================\n"
- "========== type 'quit' to exit ===========\n"));
+ ACE_TEXT ("\n============= Simple Chat =================\n")
+ ACE_TEXT ("========== type 'quit' to exit ===========\n")));
try
{
@@ -148,11 +138,22 @@ Client_i::run (void)
poa_manager->activate ();
this->receiver_var_ =
- this->receiver_i_._this ();
+ this->receiver_i_->_this ();
// Register ourselves with the server.
server_->add (this->receiver_var_.in (),
- this->nickname_);
+ this->nickname_.c_str ());
+
+ // Register our <Input_Handler> to handle STDIN events, which will
+ // trigger the <handle_input> method to process these events.
+ if (ACE_Event_Handler::register_stdin_handler
+ (this,
+ TAO_ORB_Core_instance ()->reactor (),
+ TAO_ORB_Core_instance ()->thr_mgr ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("register_stdin_handler")),
+ -1);
// Run the ORB.
this->orb_manager_.run ();
@@ -182,10 +183,17 @@ Client_i::handle_input (ACE_HANDLE)
ACE_OS::strlen (QUIT_STRING)) == 0)
{
// Remove ourselves from the server.
- this->server_->remove (this->receiver_var_.in ());
- this->receiver_i_.shutdown ();
-
- return 0;
+ try
+ {
+ this->server_->remove (this->receiver_var_.in ());
+ }
+ catch (const CORBA::Exception &)
+ {
+ // we don't care about problems
+ }
+ this->receiver_i_->shutdown ();
+
+ return -1;
}
// Call the server function <say> to pass the string typed by
@@ -210,9 +218,9 @@ Client_i::read_ior (const ACE_TCHAR *filename)
if (f_handle == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to open %s for writing: %p\n",
+ ACE_TEXT ("Unable to open %s for writing (%p)\n"),
filename,
- "invalid handle"),
+ ACE_TEXT ("open")),
-1);
ACE_Read_Buffer ior_buffer (f_handle);
@@ -220,18 +228,18 @@ Client_i::read_ior (const ACE_TCHAR *filename)
if (data == 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to read ior: %p\n"),
+ ACE_TEXT ("Unable to read ior (%p)\n"),
+ ACE_TEXT ("read")),
-1);
- this->ior_ = ACE_OS::strdup (data);
+ this->ior_ = data;
ior_buffer.alloc ()->free (data);
ACE_OS::close (f_handle);
- if (this->ior_ == 0)
+ if (this->ior_.length () == 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "failed to read ior from file\n",
- ""),
+ ACE_TEXT ("failed to read ior from file\n")),
-1);
return 0;
}
diff --git a/TAO/examples/Simple/chat/Client_i.h b/TAO/examples/Simple/chat/Client_i.h
index cede2a2957d..7f7fd3bda93 100644
--- a/TAO/examples/Simple/chat/Client_i.h
+++ b/TAO/examples/Simple/chat/Client_i.h
@@ -32,6 +32,7 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/Utils/ORB_Manager.h"
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
class Client_i : public ACE_Event_Handler
{
@@ -47,9 +48,6 @@ public:
Client_i (void);
// Constructor.
- ~Client_i (void);
- // Destructor.
-
int init (int argc, ACE_TCHAR *argv[]);
// Initialize the client communication with the server.
@@ -59,7 +57,7 @@ public:
virtual int handle_input (ACE_HANDLE);
// Handle the user input.
- private:
+private:
int parse_args (int argc, ACE_TCHAR *argv[]);
// Parse the command line arguments.
// Returns 0 on success, -1 on error.
@@ -67,13 +65,13 @@ public:
int read_ior (const ACE_TCHAR *filename);
// Function to read the server ior from a file.
- char *ior_;
+ ACE_CString ior_;
// IOR of the obj ref of the server.
const ACE_TCHAR* ior_file_name_;
// The filename that stores the ior of the server
- const char* nickname_;
+ ACE_CString nickname_;
// Nickname of the user chatting.
TAO_ORB_Manager orb_manager_;
@@ -82,7 +80,8 @@ public:
Broadcaster_var server_;
// Server object ptr.
- Receiver_i receiver_i_;
+ typedef TAO_Intrusive_Ref_Count_Handle<Receiver_i> Receiver_i_var;
+ Receiver_i_var receiver_i_;
// The receiver object.
Receiver_var receiver_var_;
diff --git a/TAO/examples/Simple/chat/Receiver_i.cpp b/TAO/examples/Simple/chat/Receiver_i.cpp
index acbb73f7f3d..4156bd8dd78 100644
--- a/TAO/examples/Simple/chat/Receiver_i.cpp
+++ b/TAO/examples/Simple/chat/Receiver_i.cpp
@@ -31,7 +31,7 @@ void
Receiver_i::message (const char *msg)
{
ACE_DEBUG ((LM_DEBUG,
- ": %s\n",
+ ACE_TEXT (": %C\n"),
msg));
}
diff --git a/TAO/examples/Simple/chat/Receiver_i.h b/TAO/examples/Simple/chat/Receiver_i.h
index d1e5a900706..5b07f53e877 100644
--- a/TAO/examples/Simple/chat/Receiver_i.h
+++ b/TAO/examples/Simple/chat/Receiver_i.h
@@ -34,7 +34,7 @@ public:
Receiver_i (void);
// Constructor.
- ~Receiver_i (void);
+ virtual ~Receiver_i (void);
// Destructor.
virtual void message (const char *msg);
diff --git a/TAO/examples/Simple/chat/Server_i.cpp b/TAO/examples/Simple/chat/Server_i.cpp
index 324eecbcb6f..53bca0ca320 100644
--- a/TAO/examples/Simple/chat/Server_i.cpp
+++ b/TAO/examples/Simple/chat/Server_i.cpp
@@ -22,9 +22,13 @@
#include "ace/OS_NS_stdio.h"
Server_i::Server_i ()
- : ior_file_name_ (ACE_TEXT("chat.ior"))
+ : ior_file_name_ (ACE_TEXT ("chat.ior"))
{
- // No Op.
+ Broadcaster_i *tmp = 0;
+ ACE_NEW_THROW_EX (tmp,
+ Broadcaster_i (),
+ CORBA::NO_MEMORY ());
+ this->broadcaster_i_ = tmp;
}
Server_i::~Server_i (void)
@@ -35,22 +39,22 @@ Server_i::~Server_i (void)
int
Server_i::parse_args (int argc, ACE_TCHAR *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("o:"));
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'o': // get the file name to write to
- this->ior_file_name_ = get_opts.opt_arg ();
- break;
+ this->ior_file_name_ = get_opts.opt_arg ();
+ break;
case '?': // display help for use of the server.
default:
ACE_ERROR_RETURN ((LM_ERROR,
- "usage: %s"
- " [-o] <ior_output_file>"
- "\n",
+ ACE_TEXT ("usage: %s")
+ ACE_TEXT (" [-o] <ior_output_file>")
+ ACE_TEXT ("\n"),
argv [0]),
-1);
}
@@ -63,21 +67,21 @@ Server_i::init (int argc,
ACE_TCHAR *argv[])
{
// Parse the command line options.
- if (this-> parse_args(argc, argv) == -1)
+ if (this->parse_args(argc, argv) == -1)
return -1;
if (this->orb_manager_.init (argc,
argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
- "orb manager init failed\n"),
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("orb manager init failed")),
-1);
CORBA::ORB_var orb = this->orb_manager_.orb ();
// Activate the servant.
CORBA::String_var str =
- this->orb_manager_.activate (&this->broadcaster_i_);
+ this->orb_manager_.activate (this->broadcaster_i_.in ());
// Write the IOR to a file.
this->write_IOR (str.in ());
@@ -88,19 +92,19 @@ int
Server_i::run (void)
{
ACE_DEBUG ((LM_DEBUG,
- "Running chat server...\n"));
+ ACE_TEXT ("Running chat server...\n")));
// Run the main event loop for the ORB.
int ret = this->orb_manager_.run ();
if (ret == -1)
ACE_ERROR_RETURN ((LM_ERROR,
- "Server_i::run"),
+ ACE_TEXT ("Server_i::run")),
-1);
return 0;
}
int
-Server_i::write_IOR(const char* ior)
+Server_i::write_IOR (const char* ior)
{
FILE* ior_output_file_ =
ACE_OS::fopen (this->ior_file_name_, "w");
@@ -108,7 +112,7 @@ Server_i::write_IOR(const char* ior)
if (ior_output_file_)
{
ACE_OS::fprintf (ior_output_file_,
- "%s",
+ ACE_TEXT ("%s"),
ior);
ACE_OS::fclose (ior_output_file_);
}
diff --git a/TAO/examples/Simple/chat/Server_i.h b/TAO/examples/Simple/chat/Server_i.h
index fcb410ed4b4..ee16b3dec7b 100644
--- a/TAO/examples/Simple/chat/Server_i.h
+++ b/TAO/examples/Simple/chat/Server_i.h
@@ -23,6 +23,7 @@
#include "Broadcaster_i.h"
#include "tao/Utils/ORB_Manager.h"
+#include "tao/Intrusive_Ref_Count_Handle_T.h"
class Server_i
{
@@ -32,18 +33,18 @@ class Server_i
public:
// = Initialization and termination methods.
- Server_i (void);
- // Constructor.
+ Server_i (void);
+ // Constructor.
- ~Server_i (void);
- // Destructor.
+ ~Server_i (void);
+ // Destructor.
- int init (int argc,
+ int init (int argc,
ACE_TCHAR *argv[]);
- // Initialize the server.
+ // Initialize the server.
- int run (void);
- // Run the ORB.
+ int run (void);
+ // Run the ORB.
private:
int parse_args (int argc, ACE_TCHAR *argv[]);
@@ -59,7 +60,8 @@ private:
TAO_ORB_Manager orb_manager_;
// The tao orb manager object.
- Broadcaster_i broadcaster_i_;
+ typedef TAO_Intrusive_Ref_Count_Handle<Broadcaster_i> Broadcaster_i_var;
+ Broadcaster_i_var broadcaster_i_;
// The servant object registered with the orb.
};
diff --git a/TAO/examples/Simple/chat/server.cpp b/TAO/examples/Simple/chat/server.cpp
index cfc742e5c9f..e8913f11f21 100644
--- a/TAO/examples/Simple/chat/server.cpp
+++ b/TAO/examples/Simple/chat/server.cpp
@@ -22,7 +22,6 @@
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
-
try
{
Server_i server_i;
@@ -30,12 +29,12 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
int ret = server_i.init (argc, argv);
if (ret != 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "\n error in init.\n"),
+ ACE_TEXT ("\n error in init.\n")),
1);
ret = server_i.run ();
if (ret != 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "\n error in run.\n"),
+ ACE_TEXT ("\n error in run.\n")),
1);
}
catch (const CORBA::Exception& ex)
diff --git a/TAO/examples/Simple/echo/Echo_Client_i.cpp b/TAO/examples/Simple/echo/Echo_Client_i.cpp
index 18e860d8acd..b70765c6c83 100644
--- a/TAO/examples/Simple/echo/Echo_Client_i.cpp
+++ b/TAO/examples/Simple/echo/Echo_Client_i.cpp
@@ -25,10 +25,9 @@ Echo_Client_i::run (const char *name,
ACE_TCHAR *argv[])
{
// Initialize the client.
- if (client.init (name,argc, argv) == -1)
+ if (client_.init (name, argc, argv) == -1)
return -1;
-
try
{
while (1)
@@ -37,22 +36,20 @@ Echo_Client_i::run (const char *name,
// Get the input message which has to be displayed.
ACE_DEBUG ((LM_DEBUG,
- "ECHO? "));
+ ACE_TEXT ("ECHO? ")));
- if (ACE_OS::fgets (buf,sizeof buf, stdin) == 0)
+ if (ACE_OS::fgets (buf, sizeof buf, stdin) == 0)
break;
- CORBA::String_var s = client->echo_string (buf);
+ CORBA::String_var s = client_->echo_string (buf);
ACE_DEBUG ((LM_DEBUG,
- "\nString echoed by client \n%s\n",
+ ACE_TEXT ("\nString echoed by client \n%C\n"),
s.in ()));
}
- if (client.shutdown () == 1)
- client->shutdown ();
-
-
+ if (client_.do_shutdown () == 1)
+ client_->shutdown ();
}
catch (const CORBA::Exception& ex)
{
@@ -62,4 +59,3 @@ Echo_Client_i::run (const char *name,
return 0;
}
-
diff --git a/TAO/examples/Simple/echo/Echo_Client_i.h b/TAO/examples/Simple/echo/Echo_Client_i.h
index 24475cfcc7e..d09df364357 100644
--- a/TAO/examples/Simple/echo/Echo_Client_i.h
+++ b/TAO/examples/Simple/echo/Echo_Client_i.h
@@ -13,9 +13,9 @@
// This class implements the interface calls for RMI.
//
// = AUTHOR
-//
+//
// Balachandran Natarajan <bala@cs.wustl.edu>
-//
+//
// ============================================================================
#ifndef ECHO_CLIENT_I_H
@@ -37,14 +37,14 @@ public:
Echo_Client_i (void);
// Constructor
- virtual ~Echo_Client_i (void);
+ ~Echo_Client_i (void);
// Destructor
- virtual int run (const char *, int, ACE_TCHAR **);
+ int run (const char *, int, ACE_TCHAR **);
// Execute the methods
private:
- Client<Echo, Echo_var> client;
+ Client<Echo> client_;
// Instantiate the client object.
};
diff --git a/TAO/examples/Simple/echo/Echo_i.cpp b/TAO/examples/Simple/echo/Echo_i.cpp
index f74fbf70e90..9bb628c8707 100644
--- a/TAO/examples/Simple/echo/Echo_i.cpp
+++ b/TAO/examples/Simple/echo/Echo_i.cpp
@@ -87,8 +87,7 @@ void
Echo_i::shutdown (void)
{
ACE_DEBUG ((LM_DEBUG,
- "\n%s\n",
- "The echo server is shutting down"));
+ ACE_TEXT ("\nThe echo server is shutting down\n")));
// Instruct the ORB to shutdown.
this->orb_->shutdown ();
diff --git a/TAO/examples/Simple/echo/Echo_i.h b/TAO/examples/Simple/echo/Echo_i.h
index 2ec327e5f8d..b048eeb8357 100644
--- a/TAO/examples/Simple/echo/Echo_i.h
+++ b/TAO/examples/Simple/echo/Echo_i.h
@@ -37,7 +37,7 @@ public:
Echo_i (void);
// Constructor.
- ~Echo_i (void);
+ virtual ~Echo_i (void);
// Destructor.
virtual Echo::List *echo_list (const char *mesg);
@@ -46,7 +46,7 @@ public:
virtual char *echo_string (const char *mesg);
// Return the mesg string back from the server.
- virtual void shutdown (void);
+ virtual void shutdown (void);
// Shutdown the server.
void orb (CORBA::ORB_ptr o);
diff --git a/TAO/examples/Simple/echo/client.cpp b/TAO/examples/Simple/echo/client.cpp
index 8b639076371..41f99b1df94 100644
--- a/TAO/examples/Simple/echo/client.cpp
+++ b/TAO/examples/Simple/echo/client.cpp
@@ -9,9 +9,8 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Echo_Client_i client;
-
ACE_DEBUG ((LM_DEBUG,
- "\nEcho client\n\n"));
+ ACE_TEXT ("\nEcho client\n\n")));
if (client.run ("Echo",
argc,
@@ -19,7 +18,4 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
return -1;
else
return 0;
-
}
-
-
diff --git a/TAO/examples/Simple/echo/server.cpp b/TAO/examples/Simple/echo/server.cpp
index a3bea500c57..2b8786e5cc2 100644
--- a/TAO/examples/Simple/echo/server.cpp
+++ b/TAO/examples/Simple/echo/server.cpp
@@ -10,8 +10,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
Server<Echo_i> server;
ACE_DEBUG ((LM_DEBUG,
- "\n\tEcho server\n\n"));
-
+ ACE_TEXT ("\n\tEcho server\n\n")));
try
{
@@ -35,7 +34,5 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
return -1;
}
-
return 0;
}
-
diff --git a/TAO/examples/Simple/grid/Grid.idl b/TAO/examples/Simple/grid/Grid.idl
index e857b7f9238..07c7c8b10a0 100644
--- a/TAO/examples/Simple/grid/Grid.idl
+++ b/TAO/examples/Simple/grid/Grid.idl
@@ -47,6 +47,6 @@ interface Grid_Factory
Grid make_grid (in short height, in short width);
// Returns a new <Grid> instance.
- void shutdown ();
+ oneway void shutdown ();
// Shutdown the application.
};
diff --git a/TAO/examples/Simple/grid/Grid_Client_i.cpp b/TAO/examples/Simple/grid/Grid_Client_i.cpp
index 64e23c37ca5..48fc1c5ebd4 100644
--- a/TAO/examples/Simple/grid/Grid_Client_i.cpp
+++ b/TAO/examples/Simple/grid/Grid_Client_i.cpp
@@ -31,7 +31,7 @@ Grid_Client_i::parse_args (int argc,
ACE_TCHAR *argv[])
{
// Parses some of the options that are specific to this example
- ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("df:nk:xw:h:p:q:v:"));
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("df:nk:xw:h:p:q:v:"));
int c = 0;
while ((c = get_opts ()) != -1)
@@ -39,28 +39,28 @@ Grid_Client_i::parse_args (int argc,
{
case 'p': // A horizontal position of the grid where
// the value is stored
- setx_ = (u_int) ACE_OS::atoi (get_opts.opt_arg ());
+ setx_ = (CORBA::UShort) ACE_OS::atoi (get_opts.opt_arg ());
break;
case 'q': // A vertical position of the grid where a
// value is stored
- sety_ = (u_int) ACE_OS::atoi (get_opts.opt_arg ());
+ sety_ = (CORBA::UShort) ACE_OS::atoi (get_opts.opt_arg ());
break;
case 'w':
- width_ = (u_int) ACE_OS::atoi (get_opts.opt_arg ());
+ width_ = (CORBA::UShort) ACE_OS::atoi (get_opts.opt_arg ());
break;
case 'h':
- height_ = (u_int) ACE_OS::atoi (get_opts.opt_arg ());
+ height_ = (CORBA::UShort) ACE_OS::atoi (get_opts.opt_arg ());
break;
case 'v':
- value_ = (u_int) ACE_OS::atoi (get_opts.opt_arg ());
+ value_ = (CORBA::UShort) ACE_OS::atoi (get_opts.opt_arg ());
break;
}
- if (setx_ == 0 )
+ if (setx_ == 0)
setx_ = Grid::DEFAULT_LOCATION;
- if (sety_ == 0 )
+ if (sety_ == 0)
sety_ = Grid::DEFAULT_LOCATION;
- if (value_ == 0 )
+ if (value_ == 0)
value_ = Grid::DEFAULT_VALUE;
return 0;
}
@@ -71,22 +71,20 @@ Grid_Client_i::run (const char *name,
ACE_TCHAR *argv[])
{
// Initialize the client.
- if (client.init (name, argc, argv) == -1)
+ if (client_.init (name, argc, argv) == -1)
return -1;
if (this->parse_args (argc, argv) == -1)
return -1;
-
try
{
// Make the Grid.
-
- Grid_var grid = client->make_grid (width_,
- height_);
+ Grid_var grid = client_->make_grid (width_,
+ height_);
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) Made the grid succesfully\n"));
+ ACE_TEXT ("(%P|%t) Made the grid succesfully\n")));
// Set a value on the grid
grid->set (setx_,
@@ -94,30 +92,63 @@ Grid_Client_i::run (const char *name,
value_);
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) Setting a value for the grid\n"));
+ ACE_TEXT ("(%P|%t) Setting a value for the grid\n")));
CORBA::Long ret_val = grid->get (setx_,
sety_);
ACE_ASSERT (ret_val == value_);
- if (client.shutdown () == 1) {
- client->shutdown ();
- }
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Changing grid's width from %i to 5\n"),
+ width_));
+
+ grid->width (5);
+
+ ret_val = grid->get (setx_,
+ sety_);
+
+ ACE_ASSERT (ret_val == value_);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Changing grid's height from %d to 5\n"),
+ height_));
+
+ grid->height (5);
+
+ ret_val = grid->get (setx_,
+ sety_);
+
+ ACE_ASSERT (ret_val == value_);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Destroing the grid\n")));
+
+ grid->destroy ();
+
+ try
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Accessing the grid out of range\n")));
+
+ grid->get (setx_,
+ sety_);
+ }
+ catch (const Grid::RANGE_ERROR &)
+ {
+ // It's ok.
+ }
+
+ if (client_.do_shutdown () == 1)
+ client_->shutdown ();
ACE_UNUSED_ARG (ret_val);
}
- catch (const CORBA::UserException& range_ex)
- {
- range_ex._tao_print_exception ("\tFrom get and set grid");
- return -1;
- }
- catch (const CORBA::SystemException& memex)
+ catch (const CORBA::Exception& ex)
{
- memex._tao_print_exception ("Cannot make grid as Memory exhausted");
+ ex._tao_print_exception ("Exception in Grid_Client_i::run:");
return -1;
}
return 0;
}
-
diff --git a/TAO/examples/Simple/grid/Grid_Client_i.h b/TAO/examples/Simple/grid/Grid_Client_i.h
index 013914eebc3..5caab3550ac 100644
--- a/TAO/examples/Simple/grid/Grid_Client_i.h
+++ b/TAO/examples/Simple/grid/Grid_Client_i.h
@@ -14,7 +14,7 @@
//
// = AUTHOR
// Balachandran Natarajan <bala@cs.wustl.edu>
-//
+//
// ============================================================================
#ifndef GRID_CLIENT_I_H
@@ -36,17 +36,17 @@ public:
Grid_Client_i (void);
// Constructor
- virtual ~Grid_Client_i (void);
+ ~Grid_Client_i (void);
// Destructor
- virtual int run (const char *, int, ACE_TCHAR *[]);
+ int run (const char *, int, ACE_TCHAR *[]);
// Execute the methods.
- virtual int parse_args (int argc, ACE_TCHAR *argv[]);
+ int parse_args (int argc, ACE_TCHAR *argv[]);
// Parses the command line arguments.
private:
- Client<Grid_Factory, Grid_Factory_var> client;
+ Client<Grid_Factory> client_;
// Instantiate the client object.
CORBA::Short height_;
diff --git a/TAO/examples/Simple/grid/Grid_i.cpp b/TAO/examples/Simple/grid/Grid_i.cpp
index bafc25964aa..4802ef189fd 100644
--- a/TAO/examples/Simple/grid/Grid_i.cpp
+++ b/TAO/examples/Simple/grid/Grid_i.cpp
@@ -2,9 +2,16 @@
// $Id$
#include "Grid_i.h"
+#include "ace/Auto_Ptr.h"
-// Default constructor.
+// Solaris and some Windows compilers don't have min in std namespaces
+CORBA::UShort
+Grid_i::min (CORBA::UShort a, CORBA::UShort b)
+{
+ return a > b ? b : a;
+}
+// Default constructor.
Grid_i::Grid_i (void)
: width_ (0),
height_ (0),
@@ -14,41 +21,20 @@ Grid_i::Grid_i (void)
}
// Constructor.
-
Grid_i::Grid_i (CORBA::Short x,
CORBA::Short y)
: width_ (x),
- height_ (y)
+ height_ (y),
+ array_ (0)
{
- ACE_NEW_THROW_EX (this->array_,
- CORBA::Long *[y],
- CORBA::NO_MEMORY ());
-
- // Allocate memory for the matrix.
-
- for (int ctr = 0; ctr < y; ctr++)
- {
- ACE_NEW_THROW_EX (this->array_[ctr],
- CORBA::Long[x],
- CORBA::NO_MEMORY ());
- }
-
}
// Default destructor.
-
Grid_i::~Grid_i (void)
{
- for (int ctr = 0; ctr < this->height_; ctr++)
- {
- delete [] this->array_[ctr];
- }
-
- delete [] this->array_;
}
// Set a value in the grid.
-
void
Grid_i::set (CORBA::Short x,
CORBA::Short y,
@@ -56,30 +42,36 @@ Grid_i::set (CORBA::Short x,
{
if (x < 0
|| y < 0
- || x >= width_
- || y >= height_)
+ || x >= this->width_
+ || y >= this->height_)
throw Grid::RANGE_ERROR ();
else
- array_[x][y] = value;
+ {
+ if (this->array_.get () == 0)
+ this->array_.reset (allocate_array (this->width_, this->height_));
+ *(this->array_.get () + this->width_ * y + x) = value;
+ }
}
// Get a value from the grid.
-
CORBA::Long
Grid_i::get (CORBA::Short x,
CORBA::Short y)
{
if (x < 0
|| y < 0
- || x >= width_
- || y >= height_)
+ || x >= this->width_
+ || y >= this->height_)
throw Grid::RANGE_ERROR ();
else
- return array_[x][y];
+ {
+ if (this->array_.get () == 0)
+ this->array_.reset (allocate_array (this->width_, this->height_));
+ return *(this->array_.get () + this->width_ * y + x);
+ }
}
// Access methods.
-
CORBA::Short
Grid_i::width (void)
{
@@ -95,34 +87,63 @@ Grid_i::height (void)
void
Grid_i::width (CORBA::Short x)
{
- this->width_ = x;
+ if (x > 0 && x != this->width_)
+ {
+ GridArray array (allocate_array (x, this->height_));
+ for (CORBA::Short ctr = 0; ctr < this->height_; ++ctr)
+ {
+ ACE_OS::memcpy (array.get () + x * ctr, this->array_.get () + this->width_ * ctr,
+ Grid_i::min (this->width_, x) * sizeof (CORBA::Long));
+ }
+ this->array_ = array;
+ array.release ();
+ this->width_ = x;
+ }
}
void
Grid_i::height (CORBA::Short y)
{
- this->height_ = y;
+ if (y > 0 && y != this->height_)
+ {
+ GridArray array (allocate_array (this->width_, y));
+ for (CORBA::Short ctr = 0; ctr < Grid_i::min (this->height_, y); ++ctr)
+ {
+ ACE_OS::memcpy (array.get () + this->width_ * ctr, this->array_.get () + this->width_ * ctr,
+ this->width_ * sizeof (CORBA::Long));
+ }
+ this->array_ = array;
+ array.release ();
+ this->height_ = y;
+ }
}
// Destroy the grid
-
void
Grid_i::destroy (void)
{
// Delete the array.
+ ACE_Auto_Array_Ptr<CORBA::Long> tmp (this->array_.release ());
+ this->width_ = 0;
+ this->height_ = 0;
- for (int i = 0; i < height_; i++)
- delete [] array_[i];
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) Grid has been destroyed\n")));
+}
- delete [] array_;
+// Allocates a new array; even if NO_MEMORY is thrown there should be no memory leak
+CORBA::Long *
+Grid_i::allocate_array (CORBA::Short x, CORBA::Short y)
+{
+ CORBA::Long *array = 0;
+ ACE_NEW_THROW_EX (array,
+ CORBA::Long[x * y],
+ CORBA::NO_MEMORY ());
- ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) %s\n",
- "Grid has been destroyed"));
+ return array;
}
// Set the ORB pointer.
-
void
Grid_Factory_i::orb (CORBA::ORB_ptr o)
{
@@ -130,41 +151,34 @@ Grid_Factory_i::orb (CORBA::ORB_ptr o)
}
// Shutdown.
-
void
Grid_Factory_i::shutdown (void)
{
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) %s\n",
- "Grid Factory is shutting down"));
+ ACE_TEXT ("(%P|%t) Grid Factory is shutting down\n")));
// Instruct the ORB to shutdown.
this->orb_->shutdown ();
}
// Constructor
-
Grid_Factory_i::Grid_Factory_i (void)
- : grid_ (0)
{
// no-op
}
// Destructor
-
Grid_Factory_i::~Grid_Factory_i (void)
{
- delete this->grid_;
}
// Make a <Grid>.
-
Grid_ptr
Grid_Factory_i::make_grid (CORBA::Short width,
CORBA::Short height)
{
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) Making a new Grid\n"));
+ ACE_TEXT ("(%P|%t) Making a new Grid\n")));
// Set a default value for width.
if (width <= 0)
@@ -176,9 +190,11 @@ Grid_Factory_i::make_grid (CORBA::Short width,
// This attempts to create a new Grid_i and throws an exception and
// returns a null value if it fails
- ACE_NEW_THROW_EX (this->grid_,
+ Grid_i *grid = 0;
+ ACE_NEW_THROW_EX (grid,
Grid_i (width, height),
CORBA::NO_MEMORY ());
+ this->grids_holder_.push_back (PortableServer::ServantBase_var (grid));
// Register the Grid pointer.
CORBA::Object_var poa_object =
@@ -188,10 +204,9 @@ Grid_Factory_i::make_grid (CORBA::Short width,
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::ObjectId_var id =
- root_poa->activate_object (this->grid_);
+ root_poa->activate_object (grid);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
- Grid_ptr gptr = Grid::_narrow (object.in ());
- return gptr;
+ return Grid::_narrow (object.in ());
}
diff --git a/TAO/examples/Simple/grid/Grid_i.h b/TAO/examples/Simple/grid/Grid_i.h
index 3bfb7e7f78e..07bc383a3c9 100644
--- a/TAO/examples/Simple/grid/Grid_i.h
+++ b/TAO/examples/Simple/grid/Grid_i.h
@@ -20,6 +20,7 @@
#define GRID_I_H
#include "GridS.h"
+#include <ace/Vector_T.h>
class Grid_i: public POA_Grid
{
@@ -38,7 +39,7 @@ public:
CORBA::Short);
// Constructor.
- ~Grid_i (void);
+ virtual ~Grid_i (void);
// Destructor
virtual CORBA::Short width (void);
@@ -63,18 +64,24 @@ public:
// Gets the grid value.
virtual void destroy (void);
-
// Destroy the grid.
private:
+ static CORBA::Long *allocate_array (CORBA::Short x, CORBA::Short y);
+ // Allocates array
+
CORBA::Short width_;
// Width of the grid.
CORBA::Short height_;
// Height of the grid.
- CORBA::Long **array_;
+ typedef ACE_Auto_Array_Ptr<CORBA::Long> GridArray;
+ GridArray array_;
// Pointer to the matrix. This is organized as an "array of arrays."
+
+ static CORBA::UShort min (CORBA::UShort, CORBA::UShort);
+ // Solaris and some Windows compilers don't have min in std namespaces
};
class Grid_Factory_i : public POA_Grid_Factory
@@ -86,7 +93,7 @@ public:
Grid_Factory_i (void);
// Constructor.
- ~Grid_Factory_i (void);
+ virtual ~Grid_Factory_i (void);
// Destructor.
virtual Grid_ptr make_grid (CORBA::Short,
@@ -100,8 +107,9 @@ public:
// Set the ORB pointer.
private:
- Grid_i *grid_;
- // This pointer is here only for proper clean up.
+ typedef ACE_Vector<PortableServer::ServantBase_var> GridsHolder;
+ GridsHolder grids_holder_;
+ // This container is here only for proper clean up.
CORBA::ORB_var orb_;
// ORB pointer.
diff --git a/TAO/examples/Simple/grid/client.cpp b/TAO/examples/Simple/grid/client.cpp
index 9e9c02100f0..80e59a5b0a7 100644
--- a/TAO/examples/Simple/grid/client.cpp
+++ b/TAO/examples/Simple/grid/client.cpp
@@ -9,15 +9,11 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Grid_Client_i client;
-
ACE_DEBUG ((LM_DEBUG,
- "\nGrid client\n\n"));
+ ACE_TEXT ("\nGrid client\n\n")));
if (client.run ("Grid", argc, argv) == -1)
return -1;
else
return 0;
-
}
-
-
diff --git a/TAO/examples/Simple/grid/server.cpp b/TAO/examples/Simple/grid/server.cpp
index 1f7aabc9f1d..e627e46fc7e 100644
--- a/TAO/examples/Simple/grid/server.cpp
+++ b/TAO/examples/Simple/grid/server.cpp
@@ -10,8 +10,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
Server<Grid_Factory_i> server;
ACE_DEBUG ((LM_DEBUG,
- "\n\tGrid server\n\n"));
-
+ ACE_TEXT ("\n\tGrid server\n\n")));
try
{
@@ -39,4 +38,3 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
return 0;
}
-
diff --git a/TAO/examples/Simple/time-date/Time_Date.cpp b/TAO/examples/Simple/time-date/Time_Date.cpp
index acc7ab96520..b98abc6a2d0 100644
--- a/TAO/examples/Simple/time-date/Time_Date.cpp
+++ b/TAO/examples/Simple/time-date/Time_Date.cpp
@@ -36,23 +36,19 @@ int
DLL_ORB::svc (void)
{
ACE_DEBUG ((LM_DEBUG,
- "\n\trunning ORB event loop (%t)\n\n"));
+ ACE_TEXT ("\n\tRunning ORB event loop (%t)\n\n")));
try
{
// Run the ORB event loop in its own thread.
this->orb_->run ();
}
- catch (const CORBA::SystemException& sysex)
- {
- sysex._tao_print_exception ("System Exception");
- return -1;
- }
- catch (const CORBA::UserException& userex)
+ catch (const CORBA::Exception& ex)
{
- userex._tao_print_exception ("User Exception");
+ ex._tao_print_exception ("Exception in DLL_ORB::svc");
return -1;
}
+
return 0;
}
@@ -62,22 +58,21 @@ DLL_ORB::init (int argc, ACE_TCHAR *argv[])
// Prevent TAO from registering with the ACE_Object_Manager so
// that it can be dynamically unloaded successfully.
- int register_with_object_manager = 0;
- if (TAO_Singleton_Manager::instance ()->init (register_with_object_manager) == -1)
- {
-// ACE_ERROR_RETURN ((LM_ERROR,
-// "%p\n",
-// "Unable to pre-initialize ORB"),
+ int register_with_object_manager = 0;
+ if (TAO_Singleton_Manager::instance ()->init (register_with_object_manager) == -1)
+ {
+// ACE_ERROR_RETURN ((LM_ERROR,
+// ACE_TEXT ("%p\n"),
+// ACE_TEXT ("Unable to pre-initialize ORB")),
// -1);
- }
+ }
try
{
ACE_DEBUG ((LM_DEBUG,
- "\n\tInitialize ORB (%t)\n\n"));
+ ACE_TEXT ("\n\tInitialize ORB (%t)\n\n")));
// Initialize the ORB.
- // Initialize the ORB.
this->orb_ = CORBA::ORB_init (argc,
argv,
"An ORB");
@@ -90,7 +85,7 @@ DLL_ORB::init (int argc, ACE_TCHAR *argv[])
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to initialize the POA.\n"),
+ ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")),
1);
this->poa_ =
@@ -120,14 +115,23 @@ DLL_ORB::init (int argc, ACE_TCHAR *argv[])
int
DLL_ORB::fini (void)
{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n\tFinalizing the service (%t)\n\n")));
return TAO_Singleton_Manager::instance ()->fini ();
// return 0;
}
+Time_Date_Servant::Time_Date_Servant (void)
+ : servant_ (0)
+ , ior_output_file_ (0)
+ , orb_ ("")
+{
+}
+
int
Time_Date_Servant::parse_args (int argc, ACE_TCHAR *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("dn:o:"));
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("dn:o:"));
int c = 0;
this->orb_ = "ORB";
@@ -139,11 +143,7 @@ Time_Date_Servant::parse_args (int argc, ACE_TCHAR *argv[])
TAO_debug_level++;
break;
case 'o': // output the IOR to a file.
- this->ior_output_file_ = ACE_OS::fopen (get_opts.opt_arg (), "w");
- if (this->ior_output_file_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to open %s for writing: %p\n",
- get_opts.opt_arg ()), -1);
+ this->ior_output_file_ = get_opts.opt_arg ();
break;
// Find the ORB in the Service Repository.
case 'n':
@@ -152,10 +152,10 @@ Time_Date_Servant::parse_args (int argc, ACE_TCHAR *argv[])
case '?': // display help for use of the server.
default:
ACE_ERROR_RETURN ((LM_ERROR,
- "usage: %s"
- " [-d]"
- " [-o] <ior_output_file>"
- "\n",
+ ACE_TEXT ("usage: %s")
+ ACE_TEXT (" [-d]")
+ ACE_TEXT (" [-o] <ior_output_file>")
+ ACE_TEXT ("\n"),
argv [0]),
-1);
}
@@ -170,21 +170,25 @@ Time_Date_Servant::init (int argc, ACE_TCHAR *argv[])
try
{
ACE_DEBUG ((LM_DEBUG,
- "\n\tTime_Date servant\n\n"));
+ ACE_TEXT ("\n\tTime_Date servant\n\n")));
this->parse_args (argc, argv);
DLL_ORB *orb =
- ACE_Dynamic_Service<DLL_ORB>::instance (this->orb_);
+ ACE_Dynamic_Service<DLL_ORB>::instance (this->orb_.c_str ());
if (orb == 0)
ACE_ERROR_RETURN ((LM_ERROR,
- "can't find %C in the Service Repository\n",
- this->orb_),
+ ACE_TEXT ("can't find %C in the Service Repository\n"),
+ this->orb_.c_str ()),
-1);
- Time_Date_i * servant = new Time_Date_i;
- PortableServer::ServantBase_var safe_servant = servant;
+ Time_Date_i * servant = 0;
+ ACE_NEW_THROW_EX (servant,
+ Time_Date_i,
+ CORBA::NO_MEMORY ());
+ PortableServer::ServantBase_var safe_servant (servant);
+ servant->orb (orb->orb_.in ());
CORBA::Object_var poa_object =
orb->orb_->resolve_initial_references("RootPOA");
@@ -205,12 +209,18 @@ Time_Date_Servant::init (int argc, ACE_TCHAR *argv[])
if (this->ior_output_file_)
{
- ACE_OS::fprintf (this->ior_output_file_,
+ FILE *output_file = ACE_OS::fopen (this->ior_output_file_, "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Unable to open %s for writing (%p)\n"),
+ this->ior_output_file_,
+ ACE_TEXT ("fopen")),
+ -1);
+ ACE_OS::fprintf (output_file,
"%s",
str.in ());
- ACE_OS::fclose (this->ior_output_file_);
+ ACE_OS::fclose (output_file);
}
-
}
catch (const CORBA::Exception& ex)
{
@@ -225,4 +235,3 @@ Time_Date_Servant::init (int argc, ACE_TCHAR *argv[])
// Time_Date service.
ACE_SVC_FACTORY_DEFINE (DLL_ORB)
ACE_SVC_FACTORY_DEFINE (Time_Date_Servant)
-
diff --git a/TAO/examples/Simple/time-date/Time_Date.h b/TAO/examples/Simple/time-date/Time_Date.h
index ebed11c5e11..b003f111cbb 100644
--- a/TAO/examples/Simple/time-date/Time_Date.h
+++ b/TAO/examples/Simple/time-date/Time_Date.h
@@ -23,10 +23,8 @@ class Alt_Resource_Factory_Export My_Resource_Factory
: public TAO_Default_Resource_Factory
{
public:
-
/// Return the @c ACE_Reactor that will be utilized by the ORB.
virtual ACE_Reactor *get_reactor (void);
-
};
ACE_FACTORY_DECLARE (Alt_Resource_Factory, My_Resource_Factory)
@@ -40,7 +38,6 @@ ACE_FACTORY_DECLARE (Alt_Resource_Factory, My_Resource_Factory)
class ACE_Svc_Export DLL_ORB : public ACE_Task_Base
{
public:
-
/// Initialize the @c TAO_ORB_Manager.
virtual int init (int argc, ACE_TCHAR *argv[]);
@@ -51,7 +48,6 @@ public:
virtual int svc (void);
public:
-
/// ORB pseudo-reference.
CORBA::ORB_var orb_;
@@ -60,7 +56,6 @@ public:
/// Reference to the POA Manager.
PortableServer::POAManager_var poa_manager_;
-
};
/**
@@ -73,6 +68,8 @@ public:
class ACE_Svc_Export Time_Date_Servant : public ACE_Service_Object
{
public:
+ /// Constructor.
+ Time_Date_Servant (void);
/// Initialize the @c Time_Date servant.
virtual int init (int argc, ACE_TCHAR *argv[]);
@@ -81,16 +78,14 @@ public:
int parse_args (int argc, ACE_TCHAR *argv[]);
private:
-
/// Servant for the @c Time_Date object.
Time_Date_i * servant_;
/// File where the IOR of the server object is stored.
- FILE *ior_output_file_;
+ const ACE_TCHAR *ior_output_file_;
/// Name of the ORB we're linking dynamically.
- const char *orb_;
-
+ ACE_CString orb_;
};
// The following Factory is used by the <ACE_Service_Config> and
diff --git a/TAO/examples/Simple/time-date/Time_Date.idl b/TAO/examples/Simple/time-date/Time_Date.idl
index 842d6060752..f32d58e2b6b 100644
--- a/TAO/examples/Simple/time-date/Time_Date.idl
+++ b/TAO/examples/Simple/time-date/Time_Date.idl
@@ -11,4 +11,7 @@ interface Time_Date
void str_date (out string time_date);
// Obtain the time and date in string format.
+
+ oneway void shutdown ();
+ // Shutdown the application.
};
diff --git a/TAO/examples/Simple/time-date/Time_Date_Client_i.cpp b/TAO/examples/Simple/time-date/Time_Date_Client_i.cpp
index 8320d688481..f5ee31efff1 100644
--- a/TAO/examples/Simple/time-date/Time_Date_Client_i.cpp
+++ b/TAO/examples/Simple/time-date/Time_Date_Client_i.cpp
@@ -37,7 +37,6 @@ Time_Date_Client_i::run (const char *name,
if (this->parse_args (argc, argv) == -1)
return -1;
-
try
{
CORBA::Long l;
@@ -46,7 +45,7 @@ Time_Date_Client_i::run (const char *name,
client_->bin_date (l);
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) Binary time_date = %d\n",
+ ACE_TEXT ("(%P|%t) Binary time_date = %d\n"),
l));
// Get the time & date in string format.
@@ -54,10 +53,11 @@ Time_Date_Client_i::run (const char *name,
client_->str_date (str_var.out());
ACE_DEBUG ((LM_DEBUG,
- "(%P|%t) String time_date = %C\n",
+ ACE_TEXT ("(%P|%t) String time_date = %C\n"),
str_var.in()));
- client_.shutdown ();
+ if (client_.do_shutdown () == 1)
+ client_->shutdown ();
}
catch (const CORBA::UserException& range_ex)
{
@@ -72,4 +72,3 @@ Time_Date_Client_i::run (const char *name,
return 0;
}
-
diff --git a/TAO/examples/Simple/time-date/Time_Date_Client_i.h b/TAO/examples/Simple/time-date/Time_Date_Client_i.h
index 27ca3f72671..fffad2111d6 100644
--- a/TAO/examples/Simple/time-date/Time_Date_Client_i.h
+++ b/TAO/examples/Simple/time-date/Time_Date_Client_i.h
@@ -46,7 +46,7 @@ public:
// Parses the command line arguments.
private:
- Client<Time_Date, Time_Date_var> client_;
+ Client<Time_Date> client_;
// Instantiate the client object.
};
diff --git a/TAO/examples/Simple/time-date/Time_Date_i.cpp b/TAO/examples/Simple/time-date/Time_Date_i.cpp
index 70d815c8c0d..8a0fe5c13e6 100644
--- a/TAO/examples/Simple/time-date/Time_Date_i.cpp
+++ b/TAO/examples/Simple/time-date/Time_Date_i.cpp
@@ -3,9 +3,9 @@
#include "Time_Date_i.h"
#include "ace/OS_NS_time.h"
+#include "ace/Reactor.h"
// Obtain the time and date in binary format.
-
void
Time_Date_i::bin_date (CORBA::Long_out time_date)
{
@@ -13,7 +13,6 @@ Time_Date_i::bin_date (CORBA::Long_out time_date)
}
// Obtain the time and date in string format.
-
void
Time_Date_i::str_date (CORBA::String_out time_date)
{
@@ -22,8 +21,21 @@ Time_Date_i::str_date (CORBA::String_out time_date)
time_date = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(ACE_OS::ctime (&time)));
}
+// Shutdown.
+void
+Time_Date_i::shutdown (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Time_Date_i is shutting down\n")));
+
+ // Instruct the ORB to shutdown.
+ this->orb_var_->shutdown ();
+ // And shutdown the event loop from started in main.
+ ACE_Reactor::end_event_loop ();
+}
+
void
Time_Date_i::orb (CORBA::ORB_ptr orb_ptr)
{
- orb_var_ = CORBA::ORB::_duplicate (orb_ptr);
+ orb_var_ = CORBA::ORB::_duplicate (orb_ptr);
}
diff --git a/TAO/examples/Simple/time-date/Time_Date_i.h b/TAO/examples/Simple/time-date/Time_Date_i.h
index 96ef47f8003..47e9ef6c792 100644
--- a/TAO/examples/Simple/time-date/Time_Date_i.h
+++ b/TAO/examples/Simple/time-date/Time_Date_i.h
@@ -35,12 +35,14 @@ public:
// = Initialization and termination methods.
virtual void bin_date (CORBA::Long_out time_date);
-
// Obtain the time and date in binary format.
virtual void str_date (CORBA::String_out time_date);
// Obtain the time and date in string format.
+ virtual void shutdown (void);
+ // Shutdown the server.
+
void orb (CORBA::ORB_ptr orb_ptr);
// ORB pointer.
diff --git a/TAO/examples/Simple/time-date/client.cpp b/TAO/examples/Simple/time-date/client.cpp
index 3f8574ebe53..b29c342665f 100644
--- a/TAO/examples/Simple/time-date/client.cpp
+++ b/TAO/examples/Simple/time-date/client.cpp
@@ -10,7 +10,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
Time_Date_Client_i client;
ACE_DEBUG ((LM_DEBUG,
- "\nTime_Date client\n\n"));
+ ACE_TEXT ("\nTime_Date client\n\n")));
if (client.run ("Time_Date", argc, argv) == -1)
return -1;
diff --git a/TAO/examples/Simple/time-date/run_test.pl b/TAO/examples/Simple/time-date/run_test.pl
index f286bcf7c90..092430e81ce 100755
--- a/TAO/examples/Simple/time-date/run_test.pl
+++ b/TAO/examples/Simple/time-date/run_test.pl
@@ -23,7 +23,7 @@ if (PerlACE::is_vxworks_test()) {
else {
$SV = new PerlACE::Process ("server");
}
-$CL = new PerlACE::Process ("client", "-f $iorfile -ORBSvcConf $conf");
+$CL = new PerlACE::Process ("client", "-f $iorfile -x -ORBSvcConf $conf");
$SV->Spawn ();
@@ -40,7 +40,12 @@ if ($client != 0) {
$status = 1;
}
-$SV->Kill ();
+$server = $SV->WaitKill ($PerlACE::wait_interval_for_process_shutdown);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
unlink $iorfile;
diff --git a/TAO/examples/Simple/time/Time_Client_i.cpp b/TAO/examples/Simple/time/Time_Client_i.cpp
index 9951747b29b..3702636e5a9 100644
--- a/TAO/examples/Simple/time/Time_Client_i.cpp
+++ b/TAO/examples/Simple/time/Time_Client_i.cpp
@@ -23,41 +23,42 @@ Time_Client_i::run (const char *name,
ACE_TCHAR *argv[])
{
// Initialize the client.
- if (client.init (name, argc, argv) == -1)
+ if (client_.init (name, argc, argv) == -1)
return -1;
-
try
{
// 64-bit OS's require pointers to be aligned on an
// 8 byte boundary. 64-bit HP-UX requires a double to do this
// while a long does it for 64-bit Solaris.
#if defined (HPUX)
- CORBA::Double padding;
+ CORBA::Double padding = 0.0;
#else
- CORBA::Long padding;
+ CORBA::Long padding = 0;
#endif /* HPUX */
time_t timedate;
ACE_UNUSED_ARG (padding);
//Make the RMI.
- timedate = static_cast <time_t> (client->current_time ());
+ timedate = static_cast <time_t> (client_->current_time ());
// Print out value
// Use ACE_OS::ctime_r(), ctime() doesn't seem to work properly
// under 64-bit solaris.
- ACE_TCHAR ascii_timedate[64] = ACE_TEXT("");
+ ACE_TCHAR ascii_timedate[64] = ACE_TEXT ("");
- ACE_OS::ctime_r (&timedate,
- ascii_timedate, 64);
+ ACE_OS::ctime_r (&timedate, ascii_timedate, 64);
ACE_DEBUG ((LM_DEBUG,
- "string time is %s\n",
+ ACE_TEXT ("string time is %s\n"),
ascii_timedate));
- if (client.shutdown () == 1)
- client->shutdown ();
+ if (client_.do_shutdown () == 1)
+ client_->shutdown ();
+
+ CORBA::ORB_var orb = client_.orb ();
+ orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
@@ -65,7 +66,5 @@ Time_Client_i::run (const char *name,
return -1;
}
-
return 0;
}
-
diff --git a/TAO/examples/Simple/time/Time_Client_i.h b/TAO/examples/Simple/time/Time_Client_i.h
index eeeeb56beb6..f0f6aba59c3 100644
--- a/TAO/examples/Simple/time/Time_Client_i.h
+++ b/TAO/examples/Simple/time/Time_Client_i.h
@@ -14,7 +14,7 @@
//
// = AUTHOR
// Balachandran Natarajan <bala@cs.wustl.edu>
-//
+//
// ============================================================================
#ifndef TIME_CLIENT_I_H
@@ -36,16 +36,15 @@ public:
Time_Client_i (void);
// Constructor
- virtual ~Time_Client_i (void);
+ ~Time_Client_i (void);
// Destructor
- virtual int run (const char *,int, ACE_TCHAR** );
+ int run (const char *, int, ACE_TCHAR**);
// Execute the methods
private:
- Client<Time, Time_var> client;
+ Client<Time> client_;
// Instantiate the client object.
};
-
#endif /* TIME_CLIENT_I_H */
diff --git a/TAO/examples/Simple/time/Time_i.cpp b/TAO/examples/Simple/time/Time_i.cpp
index 88c903303a0..c426a422e07 100644
--- a/TAO/examples/Simple/time/Time_i.cpp
+++ b/TAO/examples/Simple/time/Time_i.cpp
@@ -12,14 +12,12 @@ Time_i::Time_i (void)
}
// Destructor
-
Time_i::~Time_i (void)
{
// no-op
}
// Set the ORB pointer.
-
void
Time_i::orb (CORBA::ORB_ptr o)
{
@@ -27,7 +25,6 @@ Time_i::orb (CORBA::ORB_ptr o)
}
// Return the current date/time on the server.
-
CORBA::Long
Time_i::current_time (void)
{
@@ -35,14 +32,12 @@ Time_i::current_time (void)
}
// Shutdown.
-
void
-Time_i::shutdown ( )
+Time_i::shutdown (void)
{
ACE_DEBUG ((LM_DEBUG,
- "Time_i is shutting down\n"));
+ ACE_TEXT ("Time_i is shutting down\n")));
// Instruct the ORB to shutdown.
this->orb_->shutdown ();
}
-
diff --git a/TAO/examples/Simple/time/Time_i.h b/TAO/examples/Simple/time/Time_i.h
index 904f575851b..9d1c0a74c5b 100644
--- a/TAO/examples/Simple/time/Time_i.h
+++ b/TAO/examples/Simple/time/Time_i.h
@@ -36,14 +36,13 @@ public:
Time_i (void);
// Constructor
- ~Time_i (void);
+ virtual ~Time_i (void);
// Destructor
virtual CORBA::Long current_time (void);
// Return the current time/date on the server
virtual void shutdown (void);
-
// Shutdown the server.
void orb (CORBA::ORB_ptr o);
diff --git a/TAO/examples/Simple/time/client.cpp b/TAO/examples/Simple/time/client.cpp
index 26413aafba6..c147c199653 100644
--- a/TAO/examples/Simple/time/client.cpp
+++ b/TAO/examples/Simple/time/client.cpp
@@ -10,13 +10,10 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
Time_Client_i client;
ACE_DEBUG ((LM_DEBUG,
- "\n\tTime and date client\n\n"));
+ ACE_TEXT ("\n\tTime and date client\n\n")));
- if (client.run ("Time",argc, argv) == -1)
+ if (client.run ("Time", argc, argv) == -1)
return -1;
else
return 0;
-
}
-
-
diff --git a/TAO/examples/Simple/time/server.cpp b/TAO/examples/Simple/time/server.cpp
index dd7f0a6819e..ac8368fbdbf 100644
--- a/TAO/examples/Simple/time/server.cpp
+++ b/TAO/examples/Simple/time/server.cpp
@@ -10,8 +10,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
Server<Time_i> server;
ACE_DEBUG ((LM_DEBUG,
- "\n\tTime and Date server\n\n"));
-
+ ACE_TEXT ("\n\tTime and Date server\n\n")));
try
{
@@ -34,6 +33,6 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
sysex._tao_print_exception ("System Exception in main");
return -1;
}
+
return 0;
}
-
diff --git a/TAO/tao/HTTP_Parser.cpp b/TAO/tao/HTTP_Parser.cpp
index 58d60285d64..f46e75376df 100644
--- a/TAO/tao/HTTP_Parser.cpp
+++ b/TAO/tao/HTTP_Parser.cpp
@@ -32,8 +32,8 @@ TAO_HTTP_Parser::~TAO_HTTP_Parser (void)
bool
TAO_HTTP_Parser::match_prefix (const char *nior_string) const
{
- const ACE_TCHAR *ior_string = ACE_TEXT_CHAR_TO_TCHAR (nior_string);
- return (ACE_OS::strncmp (ior_string,
+ ACE_TString ior_string = ACE_TEXT_CHAR_TO_TCHAR (nior_string);
+ return (ACE_OS::strncmp (ior_string.c_str (),
::file_prefix,
sizeof (::file_prefix) - 1) == 0);
}
@@ -44,9 +44,9 @@ TAO_HTTP_Parser::parse_string (const char *nior,
{
// Skip the prefix, we know it is there because this method in only
// called if <match_prefix> returns 1.
- const ACE_TCHAR *ior = ACE_TEXT_CHAR_TO_TCHAR (nior);
+ ACE_TString ior = ACE_TEXT_CHAR_TO_TCHAR (nior);
const ACE_TCHAR *http_url =
- ior + sizeof (::file_prefix) + 1;
+ ior.c_str () + sizeof (::file_prefix) + 1;
ACE_TCHAR *hostname = 0;
ACE_TCHAR *filename = 0;