summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/Naming_Service/Naming_Service.cpp')
-rw-r--r--TAO/orbsvcs/Naming_Service/Naming_Service.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/TAO/orbsvcs/Naming_Service/Naming_Service.cpp b/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
index bb1a7fe56d7..73682314357 100644
--- a/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
+++ b/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
@@ -2,6 +2,7 @@
#include "Naming_Service.h"
+#include "orbsvcs/Naming/Naming_Server.h"
#include "orbsvcs/Daemon_Utilities.h"
#include "ace/Get_Opt.h"
#include "ace/Argv_Type_Converter.h"
@@ -9,14 +10,16 @@
// Default Constructor.
TAO_Naming_Service::TAO_Naming_Service (void)
- : time_ (0),
+ : my_naming_server_ (0),
+ time_ (0),
num_threads_ (1)
{
}
// Constructor taking command-line arguments.
TAO_Naming_Service::TAO_Naming_Service (int argc, ACE_TCHAR* argv[])
- : time_ (0),
+ : my_naming_server_(0),
+ time_ (0),
num_threads_ (1)
{
this->init (argc, argv);
@@ -41,14 +44,26 @@ TAO_Naming_Service::init (int argc, ACE_TCHAR* argv[])
// arguments.
this->parse_args (argc, argv);
+ // Factory method used to construct a naming server to be used in
+ // creation and initialization of the naming service components.
+ this->my_naming_server_ = this->create_naming_server ();
+
+ // For some reason we are unable to create a naming server.
+ if (this->my_naming_server_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("TAO_Naming_Service::init -- ")
+ ACE_TEXT ("Unable to create a Naming_Server. Exiting.\n")),
+ -1);
+
// This function call initializes the naming service and returns
// '-1' in case of an exception.
- int const result = this->my_naming_server_.init_with_orb (argc,
+ int const result = this->my_naming_server_->init_with_orb (argc,
argv,
this->orb_.in ());
if (result == -1)
return result;
+
}
catch (const CORBA::Exception& ex)
{
@@ -172,7 +187,7 @@ TAO_Naming_Service::shutdown (void)
int
TAO_Naming_Service::fini (void)
{
- this->my_naming_server_.fini();
+ this->my_naming_server_->fini();
try
{
@@ -190,8 +205,18 @@ TAO_Naming_Service::fini (void)
return 0;
}
+/// Factory method used to create a server object for the naming service
+TAO_Naming_Server*
+TAO_Naming_Service::create_naming_server ()
+{
+ // Default behavior is to use the Naming_Server located in orbsvcs\orbsvcs\Naming
+ return new (ACE_nothrow) TAO_Naming_Server;
+}
+
+
// Destructor.
TAO_Naming_Service::~TAO_Naming_Service (void)
{
- // Destructor
+ // Invoke destructor of naming server which was created using the factory method
+ delete this->my_naming_server_;
}