diff options
author | jtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-12-08 06:07:26 +0000 |
---|---|---|
committer | jtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-12-08 06:07:26 +0000 |
commit | 01c52c669b70c0f1b87c3a63cdbb70f28e054d58 (patch) | |
tree | 33bbb545524ec1a1c36a979e77421f55662c6893 /TAO/orbsvcs/Logging_Service | |
parent | 8337cd7a6eef11d233365ba9f7105e64707b9860 (diff) | |
download | ATCD-01c52c669b70c0f1b87c3a63cdbb70f28e054d58.tar.gz |
ChangeLogTag: Tue Dec 7 21:55:44 2004 J.T. Conklin <jtc@acorntoolworks.com>
Diffstat (limited to 'TAO/orbsvcs/Logging_Service')
6 files changed, 366 insertions, 86 deletions
diff --git a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp index 84e7dac2baf..c0d56844f6b 100644 --- a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp @@ -9,7 +9,10 @@ ACE_RCSID (Basic_Logging_Service, Basic_Logging_Service::Basic_Logging_Service (void) - : basic_log_factory_name_ ("BasicLogFactory") + : service_name_ ("BasicLogFactory"), + ior_file_name_ (0), + pid_file_name_ (0), + bind_to_naming_service_ (1) { // No-Op. } @@ -48,6 +51,49 @@ Basic_Logging_Service::init_ORB (int& argc, char *argv [] } int +Basic_Logging_Service::parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("n:o:p:x")); + int opt; + + while ((opt = get_opt ()) != EOF) + { + switch (opt) + { + case 'n': + service_name_ = get_opt.opt_arg(); + break; + + case 'o': + ior_file_name_ = get_opt.opt_arg(); + break; + + case 'p': + pid_file_name_ = get_opt.opt_arg(); + break; + + case 'x': + bind_to_naming_service_ = 0; + break; + + case '?': + default: + ACE_DEBUG ((LM_DEBUG, + "Usage: %s " + "-n service_name " + "-o ior_file_name " + "-p pid_file_name " + "-x [disable naming service bind] " + "\n", + argv[0])); + return -1; + } + } + + return 0; +} + +int Basic_Logging_Service::startup (int argc, char *argv[] ACE_ENV_ARG_DECL) { @@ -59,9 +105,8 @@ Basic_Logging_Service::startup (int argc, char *argv[] ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - // Resolve the naming service. - this->resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + if (this->parse_args (argc, argv) == -1) + return -1; // Activate the basic log factory // CORBA::Object_var obj = @@ -78,21 +123,55 @@ Basic_Logging_Service::startup (int argc, char *argv[] ACE_DEBUG ((LM_DEBUG, "The Basic Log Factory IOR is <%s>\n", str.in ())); - // Register the Basic Log Factory. - ACE_ASSERT(!CORBA::is_nil (this->naming_.in ())); + if (ior_file_name_ != 0) + { + FILE* iorf = ACE_OS::fopen (ior_file_name_, ACE_LIB_TEXT("w")); + if (iorf == 0) { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_file_name_), + -1); + } + + ACE_OS::fprintf (iorf, "%s\n", str.in ()); + ACE_OS::fclose (iorf); + } + + if (pid_file_name_ != 0) + { + FILE* pidf = ACE_OS::fopen (pid_file_name_, ACE_LIB_TEXT("w")); + if (pidf != 0) + { + ACE_OS::fprintf (pidf, + "%ld\n", + ACE_static_cast (long, ACE_OS::getpid ())); + ACE_OS::fclose (pidf); + } + } + + if (bind_to_naming_service_) + { + // Resolve the naming service. + this->resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup (this->basic_log_factory_name_); + // Register the Basic Log Factory. + ACE_ASSERT(!CORBA::is_nil (this->naming_.in ())); - this->naming_->rebind (name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (this->service_name_); + + this->naming_->rebind (name, + obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + ACE_DEBUG ((LM_DEBUG, + "Registered with the naming service as: %s\n", + this->service_name_)); + } - ACE_DEBUG ((LM_DEBUG, - "Registered with the naming service as: %s\n", - this->basic_log_factory_name_)); return 0; } @@ -148,13 +227,16 @@ Basic_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_ENV_ARG_PARAMETER); ACE_CHECK; - // Unbind from the naming service. - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup (this->basic_log_factory_name_); + if (bind_to_naming_service_) + { + // Unbind from the naming service. + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (this->service_name_); - this->naming_->unbind (name - ACE_ENV_ARG_PARAMETER); + this->naming_->unbind (name + ACE_ENV_ARG_PARAMETER); + } // Shutdown the ORB. if (!CORBA::is_nil (this->orb_.in ())) diff --git a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h index d04d3d35c5b..7c488a1dd80 100644 --- a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h +++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h @@ -37,9 +37,6 @@ class Basic_Logging_Service virtual ~Basic_Logging_Service (void); // Destructor. - int parse_args (int argc, char *argv []); - // Parses the command line arguments. - int startup (int argc, char *argv[] ACE_ENV_ARG_DECL); // Initializes the Telecom Log Service. @@ -58,13 +55,13 @@ protected: ACE_ENV_ARG_DECL); // initialize the ORB. + int parse_args (int argc, char *argv []); + // Parses the command line arguments. + void resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL); // Resolve the naming service. // = Data members - const char* basic_log_factory_name_; - // The Log Factory name. - TAO_BasicLogFactory_i basic_log_factory_; // The Basic Log Factory. @@ -77,5 +74,16 @@ protected: CosNaming::NamingContext_var naming_; // A naming context. + const char* service_name_; + // The name we use to bind with the NameService + + const char* ior_file_name_; + // The name of the file were we output the Event_Service IOR. + + const char* pid_file_name_; + // The name of a file where the process stores its pid + + int bind_to_naming_service_; + // If true, bind to naming service }; #endif /* BASIC_LOGGING_SERVICE_H */ diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp index e804956eca5..8878ba9aef6 100644 --- a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp @@ -10,7 +10,10 @@ ACE_RCSID (Event_Logging_Service, Event_Logging_Service::Event_Logging_Service (void) - : event_log_factory_name_ ("EventLogFactory") + : service_name_ ("EventLogFactory"), + ior_file_name_ (0), + pid_file_name_ (0), + bind_to_naming_service_ (1) { // No-Op. } @@ -49,6 +52,49 @@ Event_Logging_Service::init_ORB (int& argc, char *argv [] } int +Event_Logging_Service::parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("n:o:p:x")); + int opt; + + while ((opt = get_opt ()) != EOF) + { + switch (opt) + { + case 'n': + service_name_ = get_opt.opt_arg(); + break; + + case 'o': + ior_file_name_ = get_opt.opt_arg(); + break; + + case 'p': + pid_file_name_ = get_opt.opt_arg(); + break; + + case 'x': + bind_to_naming_service_ = 0; + break; + + case '?': + default: + ACE_DEBUG ((LM_DEBUG, + "Usage: %s " + "-n service_name " + "-o ior_file_name " + "-p pid_file_name " + "-x [disable naming service bind] " + "\n", + argv[0])); + return -1; + } + } + + return 0; +} + +int Event_Logging_Service::startup (int argc, char *argv[] ACE_ENV_ARG_DECL) { @@ -60,9 +106,8 @@ Event_Logging_Service::startup (int argc, char *argv[] ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - // Resolve the naming service. - this->resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + if (this->parse_args (argc, argv) == -1) + return -1; // Activate the event log factory // CORBA::Object_var obj = @@ -79,21 +124,54 @@ Event_Logging_Service::startup (int argc, char *argv[] ACE_DEBUG ((LM_DEBUG, "The Event Log Factory IOR is <%s>\n", str.in ())); - // Register the Event Log Factory - ACE_ASSERT(!CORBA::is_nil (this->naming_.in ())); + if (ior_file_name_ != 0) + { + FILE* iorf = ACE_OS::fopen (ior_file_name_, ACE_LIB_TEXT("w")); + if (iorf == 0) { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_file_name_), + -1); + } + + ACE_OS::fprintf (iorf, "%s\n", str.in ()); + ACE_OS::fclose (iorf); + } - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup (this->event_log_factory_name_); + if (pid_file_name_ != 0) + { + FILE* pidf = ACE_OS::fopen (pid_file_name_, ACE_LIB_TEXT("w")); + if (pidf != 0) + { + ACE_OS::fprintf (pidf, + "%ld\n", + ACE_static_cast (long, ACE_OS::getpid ())); + ACE_OS::fclose (pidf); + } + } + + if (bind_to_naming_service_) + { + // Resolve the naming service. + this->resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); - this->naming_->rebind (name, - obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + // Register the Event Log Factory. + ACE_ASSERT(!CORBA::is_nil (this->naming_.in ())); - ACE_DEBUG ((LM_DEBUG, - "Registered with the naming service as: %s\n", - this->event_log_factory_name_)); + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (this->service_name_); + + this->naming_->rebind (name, + obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + ACE_DEBUG ((LM_DEBUG, + "Registered with the naming service as: %s\n", + this->service_name_)); + } return 0; } @@ -150,13 +228,16 @@ Event_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_ENV_ARG_PARAMETER); ACE_CHECK; - // Unbind from the naming service. - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup (this->event_log_factory_name_); + if (bind_to_naming_service_) + { + // Unbind from the naming service. + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (this->service_name_); - this->naming_->unbind (name - ACE_ENV_ARG_PARAMETER); + this->naming_->unbind (name + ACE_ENV_ARG_PARAMETER); + } // shutdown the ORB. if (!CORBA::is_nil (this->orb_.in ())) diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h index a5b383cfe45..ed459869d0c 100644 --- a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h @@ -38,9 +38,6 @@ class Event_Logging_Service virtual ~Event_Logging_Service (void); // Destructor. - int parse_args (int argc, char *argv []); - // Parses the command line arguments. - int startup (int argc, char *argv[] ACE_ENV_ARG_DECL); // Initializes the Telecom EventLog Service. @@ -59,13 +56,13 @@ protected: ACE_ENV_ARG_DECL); // initialize the ORB. + int parse_args (int argc, char *argv []); + // Parses the command line arguments. + void resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL); // Resolve the naming service. // = Data members - const char* event_log_factory_name_; - // The Log Factory name. - TAO_EventLogFactory_i event_log_factory_; // The Event Log Factory. @@ -77,5 +74,17 @@ protected: CosNaming::NamingContext_var naming_; // A naming context. + + const char* service_name_; + // The name we use to bind with the NameService + + const char* ior_file_name_; + // The name of the file were we output the Event_Service IOR. + + const char* pid_file_name_; + // The name of a file where the process stores its pid + + int bind_to_naming_service_; + // If true, bind to naming service }; #endif /* EVENT_LOGGING_SERVICE_H */ diff --git a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp index 299eadd3187..0a790b8c97e 100644 --- a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp @@ -12,7 +12,10 @@ ACE_RCSID (Notify_Logging_Service, Notify_Logging_Service::Notify_Logging_Service (void) -: notify_factory_name_ (NOTIFY_KEY) + : service_name_ (NOTIFY_KEY), + ior_file_name_ (0), + pid_file_name_ (0), + bind_to_naming_service_ (1) { // No-Op. } @@ -66,6 +69,49 @@ Notify_Logging_Service::init_ORB (int& argc, char *argv [] } int +Notify_Logging_Service::parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("n:o:p:x")); + int opt; + + while ((opt = get_opt ()) != EOF) + { + switch (opt) + { + case 'n': + service_name_ = get_opt.opt_arg(); + break; + + case 'o': + ior_file_name_ = get_opt.opt_arg(); + break; + + case 'p': + pid_file_name_ = get_opt.opt_arg(); + break; + + case 'x': + bind_to_naming_service_ = 0; + break; + + case '?': + default: + ACE_DEBUG ((LM_DEBUG, + "Usage: %s " + "-n service_name " + "-o ior_file_name " + "-p pid_file_name " + "-x [disable naming service bind] " + "\n", + argv[0])); + return -1; + } + } + + return 0; +} + +int Notify_Logging_Service::init (int argc, char *argv[] ACE_ENV_ARG_DECL) { @@ -74,11 +120,10 @@ Notify_Logging_Service::init (int argc, char *argv[] ACE_ENV_ARG_PARAMETER) != 0) return -1; - this->notify_service_->init (this->orb_.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + if (this->parse_args (argc, argv) == -1) + return -1; - // Resolve the naming service. - resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); + this->notify_service_->init (this->orb_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); ACE_DEBUG ((LM_DEBUG, @@ -98,22 +143,63 @@ Notify_Logging_Service::init (int argc, char *argv[] ACE_CHECK_RETURN (-1); - // Register the Factory - ACE_ASSERT (!CORBA::is_nil (this->naming_.in ())); - - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup (this->notify_factory_name_.c_str ()); - ACE_CHECK_RETURN (-1); - - this->naming_->rebind (name, - obj.in () - ACE_ENV_ARG_PARAMETER); + CORBA::String_var str = + this->orb_->object_to_string (obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); ACE_DEBUG ((LM_DEBUG, - "Registered with the naming service as: %s\n", - this->notify_factory_name_.c_str())); + "The Notify Log Factory IOR is <%s>\n", str.in())); + + if (ior_file_name_ != 0) + { + FILE* iorf = ACE_OS::fopen (ior_file_name_, ACE_LIB_TEXT("w")); + if (iorf == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_file_name_), + -1); + } + + ACE_OS::fprintf (iorf, "%s\n", str.in ()); + ACE_OS::fclose (iorf); + } + + if (pid_file_name_ != 0) + { + FILE* pidf = ACE_OS::fopen (pid_file_name_, ACE_LIB_TEXT("w")); + if (pidf != 0) + { + ACE_OS::fprintf (pidf, + "%ld\n", + ACE_static_cast (long, ACE_OS::getpid ())); + ACE_OS::fclose (pidf); + } + } + + if (bind_to_naming_service_) + { + // Resolve the naming service. + resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + // Register the Factory + ACE_ASSERT (!CORBA::is_nil (this->naming_.in ())); + + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (this->service_name_); + ACE_CHECK_RETURN (-1); + + this->naming_->rebind (name, + obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + ACE_DEBUG ((LM_DEBUG, + "Registered with the naming service as: %s\n", + this->service_name_)); + } return 0; } @@ -172,14 +258,17 @@ Notify_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_ENV_ARG_PARAMETER); ACE_CHECK; - CosNaming::Name name (1); - name.length (1); - name[0].id = CORBA::string_dup (this->notify_factory_name_.c_str ()); - ACE_CHECK; - - this->naming_->unbind (name - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + if (bind_to_naming_service_) + { + CosNaming::Name name (1); + name.length (1); + name[0].id = CORBA::string_dup (this->service_name_); + ACE_CHECK; + + this->naming_->unbind (name + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } // shutdown the ORB. if (!CORBA::is_nil (this->orb_.in ())) diff --git a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h index 079e2de0e52..5cb59012033 100644 --- a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h +++ b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h @@ -62,15 +62,15 @@ protected: ACE_ENV_ARG_DECL); // initialize the ORB. - TAO_Notify_Service* notify_service_; + int parse_args (int argc, char *argv[]); + // Parses the command line arguments. void resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL); // Resolve the naming service. - // = Data members + TAO_Notify_Service* notify_service_; - ACE_CString notify_factory_name_; - // The Factory name. + // = Data members CosNotifyChannelAdmin::EventChannelFactory_var notify_factory_; // The Factory. @@ -87,5 +87,16 @@ protected: CosNaming::NamingContext_var naming_; // A naming context. + const char* service_name_; + // The name we use to bind with the NameService + + const char* ior_file_name_; + // The name of the file were we output the Event_Service IOR. + + const char* pid_file_name_; + // The name of a file where the process stores its pid + + int bind_to_naming_service_; + // If true, bind to naming service }; #endif /* NOTIFY_SERVICE_H */ |