diff options
Diffstat (limited to 'TAO/orbsvcs/Notify_Service/Notify_Service.cpp')
-rw-r--r-- | TAO/orbsvcs/Notify_Service/Notify_Service.cpp | 161 |
1 files changed, 79 insertions, 82 deletions
diff --git a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp index e7d95c4dd99..f3626d462e4 100644 --- a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp +++ b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp @@ -1,29 +1,26 @@ // $Id$ #include "Notify_Service.h" - -#include "orbsvcs/Notify/Service.h" - #include "tao/debug.h" #include "tao/IORTable/IORTable.h" -#include "tao/ORB_Core.h" - #include "ace/Arg_Shifter.h" #include "ace/Get_Opt.h" #include "ace/Sched_Params.h" #include "ace/Synch.h" #include "ace/Argv_Type_Converter.h" +#include "tao/ORB_Core.h" #include "ace/Dynamic_Service.h" +#include "orbsvcs/Notify/Service.h" TAO_Notify_Service_Driver::TAO_Notify_Service_Driver (void) -: notify_service_ (0) -, bootstrap_ (0) -, use_name_svc_ (1) -, ior_output_file_ (0) -, notify_factory_name_ (NOTIFY_KEY) -, notify_channel_name_ (NOTIFY_CHANNEL_NAME) -, register_event_channel_ (0) -, nthreads_ (1) + : notify_service_ (0), + bootstrap_ (0), + use_name_svc_ (1), + ior_output_file_ (0), + notify_factory_name_ (NOTIFY_KEY), + notify_channel_name_ (NOTIFY_CHANNEL_NAME), + register_event_channel_ (0), + nthreads_ (1) { // No-Op. } @@ -35,8 +32,8 @@ TAO_Notify_Service_Driver::~TAO_Notify_Service_Driver (void) } int -TAO_Notify_Service_Driver::init_ORB (int& argc, ACE_TCHAR *argv [] - ACE_ENV_ARG_DECL) +TAO_Notify_Service_Driver::init_ORB (int& argc, char *argv [] + ACE_ENV_ARG_DECL) { // Copy command line parameter. ACE_Argv_Type_Converter command_line(argc, argv); @@ -74,15 +71,17 @@ TAO_Notify_Service_Driver::init_ORB (int& argc, ACE_TCHAR *argv [] int TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_DECL) { + ACE_Argv_Type_Converter convert (argc, argv); + if (this->parse_args(argc, argv) != 0) return -1; // initalize the ORB. - if (this->init_ORB (argc, argv + if (this->init_ORB (convert.get_argc(), convert.get_ASCII_argv() ACE_ENV_ARG_PARAMETER) != 0) - return -1; + return -1; this->notify_service_ = ACE_Dynamic_Service<TAO_Notify_Service>::instance (TAO_NOTIFICATION_SERVICE_NAME); @@ -92,17 +91,17 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] } if (this->notify_service_ == 0) - { - ACE_DEBUG ((LM_DEBUG, "Service not found. Check service configurator file.\n")); + { + ACE_DEBUG ((LM_DEBUG, "Service not found! check conf.file\n")); return -1; - } + } this->notify_service_->init_service (this->orb_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (this->nthreads_ > 0) // we have chosen to run in a thread pool. { - ACE_DEBUG ((LM_DEBUG, "Running %d ORB threads\n", this->nthreads_)); + ACE_DEBUG ((LM_DEBUG, "Running %d server threads\n", this->nthreads_)); worker_.orb (this->orb_.in ()); // Task activation flags. @@ -111,9 +110,8 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] THR_JOINABLE | this->orb_->orb_core ()->orb_params ()->thread_creation_flags (); - int priority = - ACE_Sched_Params::priority_min (this->orb_->orb_core ()->orb_params ()->sched_policy (), - this->orb_->orb_core ()->orb_params ()->scope_policy ()); + int priority = ACE_Sched_Params::priority_min (this->orb_->orb_core ()->orb_params ()->sched_policy (), + this->orb_->orb_core ()->orb_params ()->scope_policy ()); if (worker_.activate (flags, this->nthreads_, 0, priority) != 0) @@ -137,12 +135,14 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] // Activate the factory this->notify_factory_ = - notify_service_->create (this->poa_.in () ACE_ENV_ARG_PARAMETER); + notify_service_->create (this->poa_.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); ACE_ASSERT (!CORBA::is_nil (this->notify_factory_.in ())); - if (this->bootstrap_) // Enable corbaloc usage + // Make it bootstrappable, if asked. + if (this->bootstrap_) { CORBA::Object_var table_object = this->orb_->resolve_initial_references ("IORTable" @@ -154,7 +154,7 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] ACE_CHECK_RETURN (-1); if (CORBA::is_nil (adapter.in ())) { - ACE_ERROR ((LM_ERROR, "Nil IORTable. corbaloc support not enabled.\n")); + ACE_ERROR ((LM_ERROR, "Nil IORTable\n")); } else { @@ -172,8 +172,10 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] // Register with the Name service, if asked if (this->use_name_svc_) { + // Register the Factory ACE_ASSERT (!CORBA::is_nil (this->naming_.in ())); + CosNaming::Name_var name = this->naming_->to_name (this->notify_factory_name_.c_str () ACE_ENV_ARG_PARAMETER); @@ -181,8 +183,8 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] this->naming_->rebind (name.in (), - this->notify_factory_.in () - ACE_ENV_ARG_PARAMETER); + this->notify_factory_.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); ACE_DEBUG ((LM_DEBUG, @@ -199,18 +201,19 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] CosNotifyChannelAdmin::EventChannel_var ec = this->notify_factory_->create_channel (initial_qos, - initial_admin, - id - ACE_ENV_ARG_PARAMETER); + initial_admin, + id + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - name = this->naming_->to_name (this->notify_channel_name_.c_str () - ACE_ENV_ARG_PARAMETER); + name = this->naming_->to_name ( + this->notify_channel_name_.c_str () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); this->naming_->rebind (name.in (), - ec.in () - ACE_ENV_ARG_PARAMETER); + ec.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); ACE_DEBUG ((LM_DEBUG, @@ -223,22 +226,21 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[] // Write IOR to a file, if asked. // Note: do this last to ensure that we're up and running before the file is written CORBA::String_var str = - this->orb_->object_to_string (this->notify_factory_.in () - ACE_ENV_ARG_PARAMETER); + this->orb_->object_to_string (this->notify_factory_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (this->ior_output_file_) { - ACE_OS::fprintf (this->ior_output_file_, "%s", str.in ()); + ACE_OS::fprintf (this->ior_output_file_, + "%s", + str.in ()); ACE_OS::fclose (this->ior_output_file_); this->ior_output_file_ = 0; - } + } else if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - "The Notification Event Channel Factory IOR is <%s>\n", - str.in ())); - } + ACE_DEBUG ((LM_DEBUG, + "The Notification Event Channel Factory IOR is <%s>\n", + str.in ())); return 0; } @@ -258,7 +260,8 @@ TAO_Notify_Service_Driver::resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL) -1); this->naming_ = - CosNaming::NamingContextExt::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); + CosNaming::NamingContextExt::_narrow (naming_obj.in () + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); return 0; @@ -287,18 +290,18 @@ void TAO_Notify_Service_Driver::shutdown (ACE_ENV_SINGLE_ARG_DECL) { // Deactivate. - if (this->use_name_svc_ && !CORBA::is_nil (this->naming_.in ())) - { - // Unbind from the naming service. - CosNaming::Name_var name = - this->naming_->to_name (this->notify_factory_name_.c_str () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - this->naming_->unbind (name.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } + if (this->use_name_svc_) + { + // Unbind from the naming service. + CosNaming::Name_var name = + this->naming_->to_name (this->notify_factory_name_.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->naming_->unbind (name.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } // shutdown the ORB. if (!CORBA::is_nil (this->orb_.in ())) @@ -308,14 +311,14 @@ TAO_Notify_Service_Driver::shutdown (ACE_ENV_SINGLE_ARG_DECL) int TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[]) { - ACE_Arg_Shifter arg_shifter (argc, argv); + ACE_Arg_Shifter arg_shifter (argc, argv); - const ACE_TCHAR* current_arg = 0; - while (arg_shifter.is_anything_left ()) + const ACE_TCHAR* current_arg = 0; + while (arg_shifter.is_anything_left ()) { - if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Factory")))) + if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Factory")))) { - this->notify_factory_name_.set (ACE_TEXT_ALWAYS_CHAR(current_arg)); + this->notify_factory_name_.set (ACE_TEXT_TO_CHAR_IN(current_arg)); arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Boot")) == 0) @@ -339,7 +342,7 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[]) arg_shifter.consume_arg (); } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-IORoutput")))) + else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-IORoutput")))) { this->ior_output_file_ = ACE_OS::fopen (current_arg, ACE_TEXT("w")); if (this->ior_output_file_ == 0) @@ -348,9 +351,9 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[]) current_arg), -1); arg_shifter.consume_arg (); } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ChannelName")))) + else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ChannelName")))) { - this->notify_channel_name_.set(ACE_TEXT_ALWAYS_CHAR(current_arg)); + this->notify_channel_name_.set(ACE_TEXT_TO_CHAR_IN(current_arg)); arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Channel")) == 0) @@ -360,14 +363,14 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[]) arg_shifter.consume_arg (); } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Notify_TPReactor")))) + else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Notify_TPReactor")))) { ACE_DEBUG((LM_DEBUG, "-Notify_TPReactor option is deprecated, use -ORBRunThreads option\n")); this->nthreads_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBRunThreads")))) + else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBRunThreads")))) { this->nthreads_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); @@ -378,10 +381,10 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[]) "usage: %s -Factory factory_name " "-Boot -[No]NameSvc " "-IORoutput file_name " - "-Channel -ChannelName channel_name " - "-ORBRunThreads threads\n" + "-Channel -ChannelName channel_name\n" "default: %s -Factory NotifyEventChannelFactory " - "-NameSvc -Channel NotifyEventChannel -ORBRunThreads 1\n", + "-NameSvc -Channel NotifyEventChannel\n", + "-ORBRunThreads [threads]\n", argv[0], argv[0])); arg_shifter.consume_arg (); @@ -390,10 +393,12 @@ TAO_Notify_Service_Driver::parse_args (int &argc, ACE_TCHAR *argv[]) } else { - arg_shifter.ignore_arg (); + /*ACE_DEBUG((LM_DEBUG, "Unrecognized command %s", + arg_shifter.get_current ()));*/ + arg_shifter.ignore_arg (); } } - return 0; + return 0; } /*****************************************************************/ @@ -411,13 +416,6 @@ Worker::orb (CORBA::ORB_ptr orb) int Worker::svc (void) { -#if 0 - // ACE_Thread::getprio() fails on systems that do not support thread - // priorities. While we could just treat the failure as benign, I'm - // just disabling it altogether. It doesn't provide much value, and - // makes service startup needlessly more verbose. See bugzilla 2477 - // for details. - ACE_hthread_t current; ACE_Thread::self (current); @@ -429,7 +427,6 @@ Worker::svc (void) } ACE_DEBUG ((LM_DEBUG, "Activated Worker Thread to run the ORB @ priority:%d \n", priority)); -#endif ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY |