1 #include "Application_Command.h"
4 #include "tao/PortableServer/PortableServer.h"
5 #include "LookupManager.h"
7 #include "Activation_Manager.h"
8 #include "Driver_Base.h"
9 #include "Priority_Mapping.h"
11 TAO_Notify_Tests_Application_Command::TAO_Notify_Tests_Application_Command ()
16 TAO_Notify_Tests_Application_Command::~TAO_Notify_Tests_Application_Command ()
21 TAO_Notify_Tests_Application_Command::get_name ()
23 return TAO_Notify_Tests_Application_Command::name ();
27 TAO_Notify_Tests_Application_Command::name ()
29 return TAO_Notify_Tests_Name::application_command
;
33 TAO_Notify_Tests_Application_Command::init (ACE_Arg_Shifter
& arg_shifter
)
35 if (arg_shifter
.is_anything_left ())
37 /// -Init | Run | Shutdown
38 if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Init")) == 0)
40 this->command_
= INIT
;
42 arg_shifter
.consume_arg ();
44 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Run")) == 0)
48 arg_shifter
.consume_arg ();
50 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-WaitForEvents")) == 0)
52 this->command_
= WAIT_FOR_EVENTS
;
54 arg_shifter
.consume_arg ();
56 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Shutdown")) == 0)
58 this->command_
= SHUTDOWN
;
60 arg_shifter
.consume_arg ();
62 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-DumpStats")) == 0)
64 this->command_
= DUMP_STATE
;
66 arg_shifter
.consume_arg ();
68 if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-Samples")) == 0)
70 this->dump_samples_
= 1;
72 arg_shifter
.consume_arg ();
75 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-SignalPeer")) == 0)
77 this->command_
= SIGNAL_PEER
;
79 arg_shifter
.consume_arg ();
81 else if (arg_shifter
.cur_arg_strncasecmp (ACE_TEXT("-WaitToStart")) == 0)
83 this->command_
= WAIT_TO_START
;
85 arg_shifter
.consume_arg ();
92 TAO_Notify_Tests_Application_Command::handle_init ()
94 /// Fetch the root poa.
95 PortableServer::POA_var root_poa
;
96 LOOKUP_MANAGER
->resolve (root_poa
);
98 PortableServer::POAManager_var poa_manager
=
99 root_poa
->the_POAManager ();
101 /// Activate the root POA.
102 poa_manager
->activate ();
104 TAO_Notify_Tests_Priority_Mapping
* mapping
= new TAO_Notify_Tests_Priority_Mapping ();
106 LOOKUP_MANAGER
->_register (mapping
);
110 TAO_Notify_Tests_Application_Command::handle_wait_for_completion ()
112 ACE_DEBUG ((LM_DEBUG
, "(%P, %t) Waiting for suppliers and consumers to finish...\n"));
114 TAO_Notify_Tests_Activation_Manager
* act_mgr
= 0;
115 LOOKUP_MANAGER
->resolve (act_mgr
);
117 act_mgr
->wait_for_completion ();
121 TAO_Notify_Tests_Application_Command::handle_shutdown ()
123 ACE_DEBUG ((LM_DEBUG
, "(%P, %t)Shutting down the Application...\n"));
125 TAO_Notify_Tests_Driver_Base
* driver
= 0;
126 LOOKUP_MANAGER
->resolve (driver
);
132 TAO_Notify_Tests_Application_Command::handle_dump_stats ()
134 ACE_DEBUG ((LM_DEBUG
, "(%P, %t)Dumpimg stats...\n"));
136 TAO_Notify_Tests_Activation_Manager
* act_mgr
= 0;
137 LOOKUP_MANAGER
->resolve (act_mgr
);
139 act_mgr
->dump_stats (this->dump_samples_
);
143 TAO_Notify_Tests_Application_Command::handle_run ()
148 //= Run the Suppliers
149 TAO_Notify_Tests_Activation_Manager
* act_mgr
= 0;
150 LOOKUP_MANAGER
->resolve (act_mgr
);
152 if (act_mgr
->activate_suppliers () == 0)
153 ACE_DEBUG ((LM_DEBUG
, "Suppliers activated...\n"));
155 ACE_DEBUG ((LM_DEBUG
, "Suppliers activation failed!...\n"));
159 TAO_Notify_Tests_Application_Command::handle_signal_peer ()
161 TAO_Notify_Tests_Activation_Manager
* act_mgr
= 0;
162 LOOKUP_MANAGER
->resolve (act_mgr
);
164 act_mgr
->signal_peer ();
168 TAO_Notify_Tests_Application_Command::handle_wait_to_start ()
170 TAO_Notify_Tests_Activation_Manager
* act_mgr
= 0;
171 LOOKUP_MANAGER
->resolve (act_mgr
);
173 act_mgr
->write_ior ();
175 act_mgr
->wait_for_start_signal ();
179 TAO_Notify_Tests_Application_Command::execute_i ()
181 if (this->command_
== INIT
)
183 this->handle_init ();
185 else if (this->command_
== RUN
)
189 else if (this->command_
== WAIT_FOR_EVENTS
)
191 this->handle_wait_for_completion ();
193 else if (this->command_
== SHUTDOWN
)
195 this->handle_shutdown ();
197 else if (this->command_
== DUMP_STATE
)
199 this->handle_dump_stats ();
201 else if (this->command_
== SIGNAL_PEER
)
203 this->handle_signal_peer ();
205 else if (this->command_
== WAIT_TO_START
)
207 this->handle_wait_to_start ();