2 //=============================================================================
4 * @file Notify_Service.h
6 * Notification Service front end.
8 * @author Pradeep Gore <pradeep@cs.wustl.edu>
9 * @author Service options code by Wei Chiang <Wei.Chiang@nokia.com>.
11 //=============================================================================
14 #ifndef NOTIFY_SERVICE_H
15 #define NOTIFY_SERVICE_H
16 #include /**/ "ace/pre.h"
19 #include "tao/PortableServer/PortableServer.h"
20 #include "orbsvcs/CosNotifyChannelAdminC.h"
21 #include "orbsvcs/CosNamingC.h"
22 #include "orbsvcs/Notify/CosNotify_Initializer.h"
23 #include "ace/SString.h"
24 #include "ace/Reactor.h"
25 #include "ace/Service_Object.h"
26 #include "Notify_Service_Export.h"
28 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
29 class TAO_Notify_Service
;
30 class TAO_Notify_Service_Driver
;
32 #define NOTIFY_KEY "NotifyEventChannelFactory"
33 #define NOTIFY_CHANNEL_NAME "NotifyEventChannel"
35 class LoggingWorker
: public ACE_Task_Base
38 LoggingWorker (TAO_Notify_Service_Driver
* ns
);
39 virtual int svc (void);
43 ACE_Reactor logging_reactor_
;
44 TAO_Notify_Service_Driver
* ns_
;
52 * @brief Run a server thread
54 * Use the ACE_Task_Base class to run server threads
56 class Worker
: public ACE_Task_Base
62 void orb (CORBA::ORB_ptr orb
);
64 /// The thread entry point.
65 virtual int svc (void);
73 * @class TAO_Notify_Service_Driver
75 * @brief Notify_Service
77 * Implementation of the Notification Service front end.
79 class TAO_Notify_Service_Export TAO_Notify_Service_Driver
: public ACE_Service_Object
81 friend class LoggingWorker
;
85 TAO_Notify_Service_Driver (void);
88 virtual ~TAO_Notify_Service_Driver (void);
90 /// Initializes the Service.
91 /// Returns 0 on success, -1 on error.
92 virtual int init (int argc
, ACE_TCHAR
*argv
[]);
95 /// Returns 0 on success, -1 on error.
98 /// Shutdown the Service.
99 /// Returns 0 on success, -1 on error.
100 virtual int fini (void);
103 /// initialize the ORB.
104 int init_ORB (int& argc
, ACE_TCHAR
*argv
[]);
106 /// initialize the dispatching ORB.
107 int init_dispatching_ORB (int& argc
, ACE_TCHAR
*argv
[]);
109 /// Apply a relative round-trip timeout to the ORB
110 void apply_timeout (CORBA::ORB_ptr orb
);
112 TAO_Notify_Service
* notify_service_
;
114 /// Resolve the naming service.
115 int resolve_naming_service (void);
117 /// Parses the command line arguments.
118 int parse_args (int argc
, ACE_TCHAR
*argv
[]);
122 /// true: this service is bootstrappable
125 /// true: register itself with the name service
128 /// File name where the IOR of the server object is stored.
129 const ACE_TCHAR
*ior_output_file_name_
;
131 /// The Factory name.
132 ACE_CString notify_factory_name_
;
134 /// The event channel names.
135 ACE_Unbounded_Set
<ACE_CString
> notify_channel_name_
;
137 /// true: create an event channel and registers it with the Naming Service
138 /// with the name <notify_channel_name_>
139 bool register_event_channel_
;
142 CosNotifyChannelAdmin::EventChannelFactory_var notify_factory_
;
144 /// The ORB that we use.
147 /// Separate dispatching orb if needed.
148 CORBA::ORB_var dispatching_orb_
;
150 /// Reference to the root poa.
151 PortableServer::POA_var poa_
;
153 /// A naming context.
154 CosNaming::NamingContextExt_var naming_
;
156 /// Worker for TP reactor mode.
159 /// Number of worker threads.
162 /// indicate that a separate ORB is used for dispatching events.
163 bool separate_dispatching_orb_
;
165 /// The relative round-trip timeout
166 suseconds_t timeout_
;
169 ACE_Time_Value logging_interval_
;
172 LoggingWorker logging_worker_
;
174 /// Shutdown the ORB?
177 /// Shutdown the dispatching ORB?
178 bool shutdown_dispatching_orb_
;
181 TAO_END_VERSIONED_NAMESPACE_DECL
183 ACE_STATIC_SVC_DECLARE (TAO_Notify_Service_Driver
)
184 ACE_FACTORY_DECLARE (TAO_Notify_Service
, TAO_Notify_Service_Driver
)
186 #include /**/ "ace/post.h"
187 #endif /* NOTIFY_SERVICE_H */