TAO_CosNotify_Service Class Reference

A service object for creating the Notify Service Factory. More...

#include <CosNotify_Service.h>

Inheritance diagram for TAO_CosNotify_Service:

Inheritance graph
[legend]
Collaboration diagram for TAO_CosNotify_Service:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_CosNotify_Service (void)
 Constructor.
virtual ~TAO_CosNotify_Service ()
 Destructor.
virtual int init (int argc, ACE_TCHAR *argv[])
 Init the service from configurator.
virtual void init_service (CORBA::ORB_ptr orb)
 Init the service from driver.
virtual int fini (void)
virtual void init_service2 (CORBA::ORB_ptr orb, CORBA::ORB_ptr dispatching_orb)
 separate dispatching orb init
virtual void finalize_service (CosNotifyChannelAdmin::EventChannelFactory_ptr factory)
 Finalize the service.
virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create (PortableServer::POA_ptr default_POA, const char *factory_name="EventChannelFactory")
 Create the Channel Factory.
virtual void remove (TAO_Notify_EventChannelFactory *ecf)
 Called by the factory when it is destroyed.

Protected Member Functions

virtual void init_i (CORBA::ORB_ptr orb)
 Init the data members.
virtual void init_i2 (CORBA::ORB_ptr orb, CORBA::ORB_ptr dispatching_orb)
 Init the data members separate dispatching orb.

Private Member Functions

virtual TAO_Notify_Factorycreate_factory (void)
 Create the Factory for Notify objects.
virtual TAO_Notify_Buildercreate_builder (void)
 Create the Builder for Notify objects.
void set_threads (CosNotification::QoSProperties &qos, int threads)
 Set thread options on qos.
TAO_Notify_Factoryfactory ()
TAO_Notify_Builderbuilder ()
 Service component for building NS participants.

Private Attributes

ACE_Auto_Ptr< TAO_Notify_Factoryfactory_
 Service component for object factory operations.
ACE_Auto_Ptr< TAO_Notify_Builderbuilder_
 Service component for building NS participants.

Detailed Description

A service object for creating the Notify Service Factory.

Definition at line 37 of file CosNotify_Service.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_CosNotify_Service::TAO_CosNotify_Service ( void   ) 

Constructor.

Definition at line 21 of file CosNotify_Service.cpp.

00022 {
00023 }

TAO_CosNotify_Service::~TAO_CosNotify_Service (  )  [virtual]

Destructor.

Definition at line 25 of file CosNotify_Service.cpp.

00026 {
00027 }


Member Function Documentation

TAO_Notify_Builder & TAO_CosNotify_Service::builder (  )  [private]

Service component for building NS participants.

Definition at line 411 of file CosNotify_Service.cpp.

References ACE_ASSERT, and builder_.

Referenced by create(), TAO_RT_Notify_Service::create_builder(), and create_builder().

00412 {
00413   ACE_ASSERT( this->builder_.get() != 0 );
00414   return *this->builder_;
00415 }

CosNotifyChannelAdmin::EventChannelFactory_ptr TAO_CosNotify_Service::create ( PortableServer::POA_ptr  default_POA,
const char *  factory_name = "EventChannelFactory" 
) [virtual]

Create the Channel Factory.

Implements TAO_Notify_Service.

Definition at line 391 of file CosNotify_Service.cpp.

References TAO_Notify_Builder::build_event_channel_factory(), and builder().

00393 {
00394   return this->builder().build_event_channel_factory (poa, factory_name);
00395 }

TAO_Notify_Builder * TAO_CosNotify_Service::create_builder ( void   )  [private, virtual]

Create the Builder for Notify objects.

Reimplemented in TAO_RT_Notify_Service.

Definition at line 380 of file CosNotify_Service.cpp.

References ACE_NEW_THROW_EX, and builder().

00381 {
00382   TAO_Notify_Builder* builder = 0;
00383   ACE_NEW_THROW_EX (builder,
00384                     TAO_Notify_Builder (),
00385                     CORBA::NO_MEMORY ());
00386 
00387   return builder;
00388 }

TAO_Notify_Factory * TAO_CosNotify_Service::create_factory ( void   )  [private, virtual]

Create the Factory for Notify objects.

Reimplemented in TAO_RT_Notify_Service.

Definition at line 367 of file CosNotify_Service.cpp.

References ACE_NEW_THROW_EX, factory(), and ACE_Dynamic_Service< TYPE >::instance().

00368 {
00369   TAO_Notify_Factory* factory = ACE_Dynamic_Service<TAO_Notify_Factory>::instance ("TAO_Notify_Factory");
00370   if (factory == 0)
00371     {
00372        ACE_NEW_THROW_EX (factory,
00373                          TAO_Notify_Default_Factory (),
00374                          CORBA::NO_MEMORY ());
00375     }
00376   return factory;
00377 }

TAO_Notify_Factory & TAO_CosNotify_Service::factory (  )  [private]

Definition at line 404 of file CosNotify_Service.cpp.

References ACE_ASSERT, and factory_.

Referenced by TAO_RT_Notify_Service::create_factory(), create_factory(), and finalize_service().

00405 {
00406   ACE_ASSERT( this->factory_.get() != 0 );
00407   return *this->factory_;
00408 }

void TAO_CosNotify_Service::finalize_service ( CosNotifyChannelAdmin::EventChannelFactory_ptr  factory  )  [virtual]

Finalize the service.

Implements TAO_Notify_Service.

Definition at line 270 of file CosNotify_Service.cpp.

References TAO_Notify_EventChannel::destroy(), factory(), and CORBA::is_nil().

00272 {
00273   // Get out early if we can
00274   if (CORBA::is_nil (factory))
00275     return;
00276 
00277   // Make sure the factory doesn't go away while we're in here
00278   CosNotifyChannelAdmin::EventChannelFactory_var ecf =
00279     CosNotifyChannelAdmin::EventChannelFactory::_duplicate (factory);
00280 
00281   // Find all the consumer admin objects and shutdown the worker tasks
00282   CosNotifyChannelAdmin::ChannelIDSeq_var channels =
00283     ecf->get_all_channels ();
00284   CORBA::ULong length = channels->length ();
00285   for(CORBA::ULong i = 0; i < length; i++)
00286     {
00287       try
00288         {
00289           CosNotifyChannelAdmin::EventChannel_var ec =
00290             ecf->get_event_channel (channels[i]);
00291           if (!CORBA::is_nil (ec.in ()))
00292             {
00293               TAO_Notify_EventChannel* nec =
00294                 dynamic_cast<TAO_Notify_EventChannel*> (ec->_servant ());
00295               if (nec != 0)
00296                 nec->destroy ();
00297             }
00298         }
00299       catch (const CORBA::Exception&)
00300         {
00301           // We're shutting things down, so ignore exceptions
00302         }
00303     }
00304 }

int TAO_CosNotify_Service::fini ( void   )  [virtual]

Reimplemented from ACE_Shared_Object.

Definition at line 216 of file CosNotify_Service.cpp.

References TAO_Notify_Properties::close(), TAO_Notify_Properties::dispatching_orb(), TAO_Notify_Properties::instance(), and CORBA::is_nil().

00217 {
00218   if (TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb())
00219     {
00220       if (!CORBA::is_nil (TAO_Notify_PROPERTIES::instance()->dispatching_orb()))
00221         {
00222           CORBA::ORB_var dispatcher =
00223             TAO_Notify_PROPERTIES::instance()->dispatching_orb();
00224           dispatcher->shutdown ();
00225           dispatcher->destroy ();
00226         }
00227     }
00228 
00229   TAO_Notify_Properties::instance()->close ();
00230   return 0;
00231 }

int TAO_CosNotify_Service::init ( int  argc,
ACE_TCHAR argv[] 
) [virtual]

Init the service from configurator.

Implements TAO_Notify_Service.

Definition at line 30 of file CosNotify_Service.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_TEXT(), TAO_Notify_Properties::allow_reconnect(), TAO_Notify_Properties::asynch_updates(), ACE_OS::atoi(), ACE_Arg_Shifter_T< CHAR_TYPE >::consume_arg(), ACE_Arg_Shifter_T< CHAR_TYPE >::cur_arg_strncasecmp(), TAO_Notify_Properties::default_consumer_admin_qos_properties(), TAO_Notify_Properties::default_event_channel_qos_properties(), TAO_Notify_Properties::default_proxy_consumer_qos_properties(), TAO_Notify_Properties::default_proxy_supplier_qos_properties(), TAO_Notify_Properties::default_supplier_admin_qos_properties(), ACE_Arg_Shifter_T< CHAR_TYPE >::get_current(), ACE_Arg_Shifter_T< CHAR_TYPE >::get_the_parameter(), TAO_Notify_Properties::instance(), ACE_Arg_Shifter_T< CHAR_TYPE >::is_anything_left(), LM_DEBUG, LM_ERROR, TAO_Notify_Properties::separate_dispatching_orb(), set_threads(), ACE_OS::strcmp(), and TAO_Notify_Properties::updates().

00031 {
00032   ACE_Arg_Shifter arg_shifter (argc, argv);
00033 
00034   const ACE_TCHAR *current_arg = 0;
00035 
00036   // Default to an all reactive system.
00037   int ec_threads = 0;
00038   int consumer_threads = 0;
00039   int supplier_threads = 0;
00040 
00041   bool task_per_proxy = false;
00042 
00043   TAO_Notify_Properties *properties = TAO_Notify_PROPERTIES::instance();
00044 
00045   while (arg_shifter.is_anything_left ())
00046     {
00047       if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTDispatching")) == 0)
00048         {
00049           arg_shifter.consume_arg ();
00050           ACE_DEBUG ((LM_DEBUG,
00051                       ACE_TEXT ("(%P|%t) The -MTDispatching option has been deprecated, use -DispatchingThreads \n")));
00052         }
00053       else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-DispatchingThreads"))))
00054         {
00055           consumer_threads += ACE_OS::atoi (current_arg);
00056           arg_shifter.consume_arg ();
00057         }
00058       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTSourceEval")) == 0)
00059         {
00060           arg_shifter.consume_arg ();
00061           ACE_DEBUG ((LM_DEBUG,
00062                       ACE_TEXT ("(%P|%t) The -MTSourceEval option has been deprecated, use -SourceThreads \n")));
00063         }
00064       else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-SourceThreads"))))
00065         {
00066           supplier_threads += ACE_OS::atoi (current_arg);
00067           arg_shifter.consume_arg ();
00068         }
00069       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTLookup")) == 0)
00070         {
00071           arg_shifter.consume_arg ();
00072           ACE_DEBUG ((LM_DEBUG,
00073                       ACE_TEXT ("(%P|%t) The -MTLookup option has been deprecated, use -SourceThreads \n")));
00074         }
00075       else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-LookupThreads"))))
00076         {
00077           supplier_threads += ACE_OS::atoi (current_arg);
00078           arg_shifter.consume_arg ();
00079           ACE_DEBUG ((LM_DEBUG,
00080                       ACE_TEXT ("(%P|%t) The -LookupThreads option has been deprecated, use -SourceThreads \n")));
00081         }
00082       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTListenerEval")) == 0)
00083         {
00084           arg_shifter.consume_arg ();
00085           ACE_DEBUG ((LM_DEBUG,
00086                       ACE_TEXT ("(%P|%t) The -MTListenerEval option has been deprecated, use -DispatchingThreads \n")));
00087         }
00088       else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ListenerThreads"))))
00089         {
00090           // Since this option is always added to consumer_threads, we'll
00091           // deprecate it in favor of that option.
00092           ACE_DEBUG ((LM_DEBUG,
00093                       ACE_TEXT ("(%P|%t) The -ListenerThreads option has been deprecated, use -DispatchingThreads \n")));
00094           consumer_threads += ACE_OS::atoi (current_arg);
00095           arg_shifter.consume_arg ();
00096         }
00097       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AsynchUpdates")) == 0)
00098         {
00099           arg_shifter.consume_arg ();
00100 
00101           properties->asynch_updates (1);
00102         }
00103       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-NoUpdates")) == 0)
00104         {
00105           arg_shifter.consume_arg ();
00106 
00107           properties->updates (0);
00108         }
00109       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AllocateTaskperProxy")) == 0)
00110         {
00111           task_per_proxy = true;
00112           arg_shifter.consume_arg ();
00113         }
00114       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-UseSeparateDispatchingORB")) == 0)
00115         {
00116           current_arg = arg_shifter.get_the_parameter
00117                                 (ACE_TEXT("-UseSeparateDispatchingORB"));
00118           if (current_arg != 0 &&
00119               (ACE_OS::strcmp(ACE_TEXT ("0"), current_arg) == 0 ||
00120                ACE_OS::strcmp(ACE_TEXT ("1"), current_arg) == 0))
00121             {
00122               properties->separate_dispatching_orb (
00123                             static_cast<bool> (ACE_OS::atoi(current_arg)));
00124               ACE_DEBUG ((LM_DEBUG,
00125                           ACE_TEXT ("Using separate Dispatching ORB\n")));
00126             }
00127           else
00128             {
00129               ACE_DEBUG ((LM_DEBUG,
00130                           ACE_TEXT ("(%P|%t) WARNING: Unrecognized ")
00131                           ACE_TEXT ("argument (%s).  Ignoring invalid ")
00132                           ACE_TEXT ("-UseSeparateDispatchingORB usage.\n"),
00133                           (current_arg == 0 ? ACE_TEXT ("''") : current_arg)));
00134             }
00135           if (current_arg != 0)
00136             arg_shifter.consume_arg ();
00137         }
00138       else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AllowReconnect")) == 0)
00139       {
00140         arg_shifter.consume_arg ();
00141         TAO_Notify_PROPERTIES::instance()->allow_reconnect (true);
00142       }
00143       else
00144       {
00145         ACE_ERROR ((LM_ERROR,
00146                     ACE_TEXT ("(%P|%t) Ignoring unknown option for Notify Factory: %s\n"),
00147                     arg_shifter.get_current()
00148           ));
00149         arg_shifter.consume_arg ();
00150       }
00151     }
00152 
00153   // Init the EC QoS
00154   {
00155     CosNotification::QoSProperties qos;
00156     this->set_threads (qos, ec_threads);
00157     properties->default_event_channel_qos_properties (qos);
00158   }
00159 
00160   if (!task_per_proxy)
00161     {
00162       // Set the per ConsumerAdmin QoS
00163       {
00164         if (consumer_threads > 0)
00165           ACE_DEBUG((LM_DEBUG, "Using %d threads for each ConsumerAdmin.\n", consumer_threads));
00166         CosNotification::QoSProperties qos;
00167         this->set_threads (qos, consumer_threads);
00168         properties->default_consumer_admin_qos_properties (qos);
00169       }
00170 
00171       // Set the per SupplierAdmin QoS
00172       {
00173         if (supplier_threads > 0)
00174           ACE_DEBUG((LM_DEBUG, "Using %d threads for each SupplierAdmin.\n", supplier_threads));
00175         CosNotification::QoSProperties qos;
00176         this->set_threads (qos, supplier_threads);
00177         properties->default_supplier_admin_qos_properties (qos);
00178       }
00179     }
00180   else
00181     {
00182       // Set the per ProxyConsumer QoS
00183       {
00184         if (supplier_threads > 0)
00185           ACE_DEBUG((LM_DEBUG, "Using %d threads for each Supplier.\n", supplier_threads));
00186         CosNotification::QoSProperties qos;
00187         this->set_threads (qos, supplier_threads); // lookup thread per proxy doesn't make sense.
00188         properties->default_proxy_consumer_qos_properties (qos);
00189       }
00190 
00191       // Set the per ProxySupplier QoS
00192       {
00193         if (consumer_threads > 0)
00194           ACE_DEBUG((LM_DEBUG, "Using %d threads for each Consumer.\n", consumer_threads));
00195         CosNotification::QoSProperties qos;
00196         this->set_threads (qos, consumer_threads);
00197         properties->default_proxy_supplier_qos_properties (qos);
00198       }
00199     }
00200 
00201   return 0;
00202 }

void TAO_CosNotify_Service::init_i ( CORBA::ORB_ptr  orb  )  [protected, virtual]

Init the data members.

Reimplemented in TAO_RT_Notify_Service.

Definition at line 307 of file CosNotify_Service.cpp.

References ACE_ASSERT, ACE_ERROR, TAO_Notify_Properties::builder(), builder_, TAO_Notify_Properties::factory(), factory_, TAO_Objref_Var_T< T >::in(), TAO_Pseudo_Var_T< T >::in(), TAO_Notify_Properties::instance(), CORBA::is_nil(), LM_ERROR, ACE_Auto_Basic_Ptr< X >::reset(), and CORBA::ORB::resolve_initial_references().

Referenced by TAO_RT_Notify_Service::init_i(), and init_service().

00308 {
00309   // Obtain the Root POA
00310   CORBA::Object_var object  =
00311     orb->resolve_initial_references("RootPOA");
00312 
00313   if (CORBA::is_nil (object.in ()))
00314     ACE_ERROR ((LM_ERROR,
00315                 " (%P|%t) Unable to resolve the RootPOA.\n"));
00316 
00317   PortableServer::POA_var default_poa = PortableServer::POA::_narrow (object.in ());
00318 
00319   // Set the properties
00320   TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();
00321 
00322   properties->orb (orb);
00323   properties->default_poa (default_poa.in ());
00324 
00325   // Init the factory
00326   this->factory_.reset (this->create_factory ());
00327   ACE_ASSERT( this->factory_.get() != 0 );
00328   TAO_Notify_PROPERTIES::instance()->factory (this->factory_.get());
00329 
00330   this->builder_.reset (this->create_builder ());
00331   ACE_ASSERT( this->builder_.get() != 0 );
00332   TAO_Notify_PROPERTIES::instance()->builder (this->builder_.get());
00333 }

void TAO_CosNotify_Service::init_i2 ( CORBA::ORB_ptr  orb,
CORBA::ORB_ptr  dispatching_orb 
) [protected, virtual]

Init the data members separate dispatching orb.

Definition at line 336 of file CosNotify_Service.cpp.

References ACE_ASSERT, ACE_ERROR, TAO_Notify_Properties::builder(), builder_, TAO_Notify_Properties::factory(), factory_, TAO_Objref_Var_T< T >::in(), TAO_Pseudo_Var_T< T >::in(), TAO_Notify_Properties::instance(), CORBA::is_nil(), LM_ERROR, ACE_Auto_Basic_Ptr< X >::reset(), and CORBA::ORB::resolve_initial_references().

Referenced by init_service(), and init_service2().

00337 {
00338   // Obtain the Root POA
00339   CORBA::Object_var object  =
00340     orb->resolve_initial_references("RootPOA");
00341 
00342   if (CORBA::is_nil (object.in ()))
00343     ACE_ERROR ((LM_ERROR, " (%P|%t) Unable to resolve the RootPOA.\n"));
00344 
00345   PortableServer::POA_var default_poa = PortableServer::POA::_narrow (object.in ());
00346 
00347   // Set the properties
00348   TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance();
00349 
00350   properties->orb (orb);
00351   properties->dispatching_orb (dispatching_orb);
00352   properties->separate_dispatching_orb (true);
00353 
00354   properties->default_poa (default_poa.in ());
00355 
00356   // Init the factory and builder
00357   this->factory_.reset (this->create_factory ());
00358   ACE_ASSERT( this->factory_.get() != 0 );
00359   TAO_Notify_PROPERTIES::instance()->factory (this->factory_.get());
00360 
00361   this->builder_.reset (this->create_builder ());
00362   ACE_ASSERT( this->builder_.get() != 0 );
00363   TAO_Notify_PROPERTIES::instance()->builder (this->builder_.get());
00364 }

void TAO_CosNotify_Service::init_service ( CORBA::ORB_ptr  orb  )  [virtual]

Init the service from driver.

Implements TAO_Notify_Service.

Reimplemented in TAO_RT_Notify_Service.

Definition at line 234 of file CosNotify_Service.cpp.

References ACE_DEBUG, TAO_Notify_Properties::dispatching_orb(), TAO_Pseudo_Var_T< T >::in(), init_i(), init_i2(), TAO_Notify_Properties::instance(), CORBA::is_nil(), LM_DEBUG, and CORBA::ORB_init().

00235 {
00236   ACE_DEBUG ((LM_DEBUG, "Loading the Cos Notification Service...\n"));
00237 
00238   if (TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb())
00239     {
00240       // got here by way of svc.conf. no second orb supplied so create one
00241       if (CORBA::is_nil (TAO_Notify_PROPERTIES::instance()->dispatching_orb()))
00242         {
00243           ACE_DEBUG ((LM_DEBUG, "No dispatching orb supplied. Creating default one.\n"));
00244 
00245           int argc = 0;
00246           char *argv0 = 0;
00247           char **argv = &argv0;  // ansi requires argv be null terminated.
00248           CORBA::ORB_var dispatcher = CORBA::ORB_init (argc, argv,
00249                                                        "default_dispatcher");
00250 
00251           TAO_Notify_PROPERTIES::instance()->dispatching_orb(dispatcher.in());
00252         }
00253 
00254       this->init_i2 (orb, TAO_Notify_PROPERTIES::instance()->dispatching_orb());
00255 
00256     }
00257   else
00258     {
00259       this->init_i (orb);
00260     }
00261 }

void TAO_CosNotify_Service::init_service2 ( CORBA::ORB_ptr  orb,
CORBA::ORB_ptr  dispatching_orb 
) [virtual]

separate dispatching orb init

Implements TAO_Notify_Service.

Definition at line 264 of file CosNotify_Service.cpp.

References init_i2().

00265 {
00266   this->init_i2 (orb, dispatching_orb);
00267 }

void TAO_CosNotify_Service::remove ( TAO_Notify_EventChannelFactory ecf  )  [virtual]

Called by the factory when it is destroyed.

Definition at line 398 of file CosNotify_Service.cpp.

00399 {
00400   // NOP.
00401 }

void TAO_CosNotify_Service::set_threads ( CosNotification::QoSProperties qos,
int  threads 
) [private]

Set thread options on qos.

Definition at line 205 of file CosNotify_Service.cpp.

References CORBA::string_dup().

Referenced by init().

00206 {
00207   NotifyExt::ThreadPoolParams tp_params =
00208     {NotifyExt::CLIENT_PROPAGATED, 0, 0, (unsigned)threads, 0, 0, 0, 0, 0 };
00209 
00210   qos.length (1);
00211   qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool);
00212   qos[0].value <<= tp_params;
00213 }


Member Data Documentation

ACE_Auto_Ptr< TAO_Notify_Builder > TAO_CosNotify_Service::builder_ [private]

Service component for building NS participants.

Definition at line 95 of file CosNotify_Service.h.

Referenced by builder(), init_i(), and init_i2().

ACE_Auto_Ptr< TAO_Notify_Factory > TAO_CosNotify_Service::factory_ [private]

Service component for object factory operations.

Definition at line 92 of file CosNotify_Service.h.

Referenced by factory(), init_i(), and init_i2().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:46:15 2010 for TAO_CosNotification by  doxygen 1.4.7