Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / Notify_Service / Notify_Service.h
blob3a1d7f95e723345f6d96b6880142d9c885929884
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
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"
18 #include "ace/Task.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
37 public:
38 LoggingWorker (TAO_Notify_Service_Driver* ns);
39 virtual int svc (void);
40 void start ();
41 void end ();
42 private:
43 ACE_Reactor logging_reactor_;
44 TAO_Notify_Service_Driver* ns_;
45 bool started_;
46 long timer_id_;
49 /**
50 * @class Worker
52 * @brief Run a server thread
54 * Use the ACE_Task_Base class to run server threads
56 class Worker : public ACE_Task_Base
58 public:
59 /// ctor
60 Worker (void);
62 void orb (CORBA::ORB_ptr orb);
64 /// The thread entry point.
65 virtual int svc (void);
67 private:
68 /// The orb
69 CORBA::ORB_var orb_;
72 /**
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;
83 public:
84 /// Constructor.
85 TAO_Notify_Service_Driver (void);
87 /// Destructor.
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[]);
94 /// run the Service.
95 /// Returns 0 on success, -1 on error.
96 int run (void);
98 /// Shutdown the Service.
99 /// Returns 0 on success, -1 on error.
100 virtual int fini (void);
102 protected:
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 []);
120 // = Data members
122 /// true: this service is bootstrappable
123 bool bootstrap_;
125 /// true: register itself with the name service
126 bool use_name_svc_;
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_;
141 /// The Factory.
142 CosNotifyChannelAdmin::EventChannelFactory_var notify_factory_;
144 /// The ORB that we use.
145 CORBA::ORB_var orb_;
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.
157 Worker worker_;
159 /// Number of worker threads.
160 int nthreads_;
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_;
168 /// Logging interval
169 ACE_Time_Value logging_interval_;
171 /// Logging worker
172 LoggingWorker logging_worker_;
174 /// Shutdown the ORB?
175 bool shutdown_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 */