Helper class for simple ORB/POA initialization and registering servants with the POA. More...
#include <ORB_Manager.h>
Public Member Functions | |
TAO_ORB_Manager (CORBA::ORB_ptr orb=CORBA::ORB::_nil(), PortableServer::POA_ptr poa=PortableServer::POA::_nil(), PortableServer::POAManager_ptr poa_manager=PortableServer::POAManager::_nil()) | |
int | init (int &argc, ACE_TCHAR *argv[], const char *orb_name=0) |
int | init_child_poa (int &argc, ACE_TCHAR *argv[], const char *poa_name, const char *orb_name=0) |
int | fini (void) |
~TAO_ORB_Manager (void) | |
Destructor. | |
int | activate_poa_manager (void) |
char * | activate (PortableServer::Servant servant) |
void | deactivate (const char *id) |
char * | activate_under_child_poa (const char *object_name, PortableServer::Servant servant) |
void | deactivate_under_child_poa (const char *id) |
int | run (ACE_Time_Value &tv) |
int | run (void) |
CORBA::ORB_ptr | orb (void) |
PortableServer::POA_ptr | root_poa (void) |
PortableServer::POA_ptr | child_poa (void) |
PortableServer::POAManager_ptr | poa_manager (void) |
Protected Attributes | |
CORBA::ORB_var | orb_ |
The ORB. | |
PortableServer::POA_var | poa_ |
The POA for this ORB. | |
PortableServer::POA_var | child_poa_ |
Child poa under the root POA. | |
PortableServer::POAManager_var | poa_manager_ |
The POA manager of poa_. |
Helper class for simple ORB/POA initialization and registering servants with the POA.
This class is a TAO extension that makes it easier to write CORBA applications. It's just a wrapper and doesn't do anything special within the ORB itself.
Definition at line 38 of file ORB_Manager.h.
TAO_ORB_Manager::TAO_ORB_Manager | ( | CORBA::ORB_ptr | orb = CORBA::ORB::_nil() , |
|
PortableServer::POA_ptr | poa = PortableServer::POA::_nil() , |
|||
PortableServer::POAManager_ptr | poa_manager = PortableServer::POAManager::_nil() | |||
) |
Constructor.
orb | pointer to an ORB which is duplicated an stored internally in an ORB_var. If pointer is 0, a new ORB pointer is created internally in the init() call. | |
poa | pointer to a POA which is duplicated and stored internally in a POA_var. If pointer is 0, a pointer to the Root POA is obtained from the ORB. | |
poa_manager | pointer to a POA Manager which is duplicated and stored internally in a POAManager_var. If pointer is 0, a new POAManager is created internally in the init() call. |
Definition at line 33 of file ORB_Manager.cpp.
: orb_ (CORBA::ORB::_duplicate(orb)), poa_ (PortableServer::POA::_duplicate(poa)), poa_manager_ (PortableServer::POAManager::_duplicate(poa_manager)) { }
TAO_ORB_Manager::~TAO_ORB_Manager | ( | void | ) |
Destructor.
Definition at line 249 of file ORB_Manager.cpp.
{ try { if (!CORBA::is_nil (this->poa_.in ())) { this->poa_->destroy (1,1); } if (!CORBA::is_nil (this->orb_.in ())) { this->orb_->destroy (); } } catch (const ::CORBA::Exception&) { // ignore any exceptions.. } }
char * TAO_ORB_Manager::activate | ( | PortableServer::Servant | servant | ) |
Activate <servant>, using the POA <activate_object> call. Users can call this method multiple times to activate multiple objects.
Definition at line 123 of file ORB_Manager.cpp.
{ PortableServer::ObjectId_var id = this->poa_->activate_object (servant); CORBA::Object_var obj = this->poa_->id_to_reference (id.in ()); CORBA::String_var str = this->orb_->object_to_string (obj.in ()); return str._retn (); }
int TAO_ORB_Manager::activate_poa_manager | ( | void | ) |
Put POA manager into the <Active> state, so that incoming corba requests are processed. This method is useful for clients, which are not going to enter "orb->run" loop, yet may want to service incoming requests while waiting for a result of CORBA call on a server.
-1 | Failure | |
0 | Success |
Definition at line 114 of file ORB_Manager.cpp.
{ this->poa_manager_->activate (); return 0; }
char * TAO_ORB_Manager::activate_under_child_poa | ( | const char * | object_name, | |
PortableServer::Servant | servant | |||
) |
Precondition: init_child_poa has been called. Activate <servant> using the POA <activate_object_with_id> created from the string <object_name>. Users should call this to activate objects under the child_poa.
object_name | String name which will be used to create an Object ID for the servant. | |
servant | The servant to activate under the child POA. |
Definition at line 148 of file ORB_Manager.cpp.
{ if (object_name == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("\n(%P|%t) TAO_ORB_Manager::register: ") ACE_TEXT ("object_name is null!")), 0); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId (object_name); this->child_poa_->activate_object_with_id (id.in (), servant); CORBA::Object_var obj = this->child_poa_->id_to_reference (id.in ()); CORBA::String_var str = this->orb_->object_to_string (obj.in ()); return str._retn(); }
PortableServer::POA_ptr TAO_ORB_Manager::child_poa | ( | void | ) |
Accessor which returns the child poa. Following the normal CORBA memory management rules of return values from functions, this function duplicates the poa return value before returning it.
Definition at line 236 of file ORB_Manager.cpp.
{ return PortableServer::POA::_duplicate (this->child_poa_.in ()); }
void TAO_ORB_Manager::deactivate | ( | const char * | id | ) |
Deactivate object in RootPOA.
id | A string representation of the Object ID of the servant to deactivate in the POA |
Definition at line 135 of file ORB_Manager.cpp.
{ CORBA::Object_var object = this->orb_->string_to_object (id); PortableServer::ObjectId_var object_id = this->poa_->reference_to_id (object.in ()); this->poa_->deactivate_object (object_id.in ()); }
void TAO_ORB_Manager::deactivate_under_child_poa | ( | const char * | id | ) |
Deactivate object in child POA.
id | string representation of the object ID, which represents the object to deactivate in the POA |
Definition at line 170 of file ORB_Manager.cpp.
{ CORBA::Object_var object = this->orb_->string_to_object (id); PortableServer::ObjectId_var object_id = this->child_poa_->reference_to_id (object.in ()); this->child_poa_->deactivate_object (object_id.in ()); }
int TAO_ORB_Manager::fini | ( | void | ) |
Shut down. Invoke the destroy() methods on the orb and poa.
-1 | Failure | |
0 | Success |
Definition at line 194 of file ORB_Manager.cpp.
{ this->poa_->destroy (1, 1); this->child_poa_ = PortableServer::POA::_nil(); this->poa_ = PortableServer::POA::_nil(); this->poa_manager_ = PortableServer::POAManager::_nil(); this->orb_->destroy (); this->orb_ = CORBA::ORB::_nil(); return 0; }
int TAO_ORB_Manager::init | ( | int & | argc, | |
ACE_TCHAR * | argv[], | |||
const char * | orb_name = 0 | |||
) |
Initialize the ORB/root POA, using the supplied command line arguments or the default ORB components.
-1 | Failure | |
0 | Success |
Definition at line 43 of file ORB_Manager.cpp.
{ if (CORBA::is_nil (this->orb_.in ())) { this->orb_ = CORBA::ORB_init (argc, argv, orb_name); } if (CORBA::is_nil (this->poa_.in ())) { // Get the POA from the ORB. CORBA::Object_var poa_object = this->orb_->resolve_initial_references (TAO_OBJID_ROOTPOA); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")), -1); // Get the POA object. this->poa_ = PortableServer::POA::_narrow (poa_object.in ()); } if (CORBA::is_nil (this->poa_manager_.in ())) { // Get the POA_Manager. this->poa_manager_ = this->poa_->the_POAManager (); } return 0; }
int TAO_ORB_Manager::init_child_poa | ( | int & | argc, | |
ACE_TCHAR * | argv[], | |||
const char * | poa_name, | |||
const char * | orb_name = 0 | |||
) |
Creates a child poa under the root poa with PERSISTENT and USER_ID policies. Call this if you want a child_poa with the above policies, otherwise call init.
-1 | Failure | |
0 | Success |
CORBA::ORB_ptr TAO_ORB_Manager::orb | ( | void | ) |
Accessor which returns the ORB pointer. Following the normal CORBA memory management rules of return values from functions, this function duplicates the orb return value before returning it.
Definition at line 222 of file ORB_Manager.cpp.
{ return CORBA::ORB::_duplicate (this->orb_.in ()); }
PortableServer::POAManager_ptr TAO_ORB_Manager::poa_manager | ( | void | ) |
Accessor which returns the poa manager. Following the normal CORBA memory management rules of return values from functions, this function duplicates the poa manager return value before returning it.
Definition at line 242 of file ORB_Manager.cpp.
{ return PortableServer::POAManager::_duplicate (this->poa_manager_.in ()); }
PortableServer::POA_ptr TAO_ORB_Manager::root_poa | ( | void | ) |
Accessor which returns the root poa. Following the normal CORBA memory management rules of return values from functions, this function duplicates the poa return value before returning it.
Definition at line 229 of file ORB_Manager.cpp.
int TAO_ORB_Manager::run | ( | ACE_Time_Value & | tv | ) |
Run the ORB event loop with the specified tv time value.
tv | the time interval for how long to run the ORB event loop. |
-1 | Failure | |
0 | Success |
Definition at line 184 of file ORB_Manager.cpp.
{ this->poa_manager_->activate (); this->orb_->run (tv); return 0; }
int TAO_ORB_Manager::run | ( | void | ) |
Run the ORB event loop.
Definition at line 210 of file ORB_Manager.cpp.
{ this->poa_manager_->activate (); this->orb_->run (); return 0; }
PortableServer::POA_var TAO_ORB_Manager::child_poa_ [protected] |
Child poa under the root POA.
Definition at line 222 of file ORB_Manager.h.
CORBA::ORB_var TAO_ORB_Manager::orb_ [protected] |
The ORB.
Definition at line 216 of file ORB_Manager.h.
PortableServer::POA_var TAO_ORB_Manager::poa_ [protected] |
The POA for this ORB.
Definition at line 219 of file ORB_Manager.h.
The POA manager of poa_.
Definition at line 225 of file ORB_Manager.h.