#include <POA_Helper.h>
Inheritance diagram for TAO_Notify_POA_Helper:
Public Member Functions | |
TAO_Notify_POA_Helper (void) | |
Default Constructor. | |
void | init (PortableServer::POA_ptr parent_poa, const char *poa_name) |
Create a new PortableServer::POA. | |
void | init (PortableServer::POA_ptr parent_poa) |
Create a new PortableServer::POA. The name is chosen at random. | |
virtual | ~TAO_Notify_POA_Helper () |
Destructor. | |
PortableServer::POA_ptr | poa (void) |
Get underlying POA. | |
void | destroy () |
Destroy underlying POA. | |
CORBA::Object_ptr | activate (PortableServer::Servant servant, CORBA::Long &id) |
Activate Object, the POA will assign an ID and return its value. | |
CORBA::Object_ptr | activate_with_id (PortableServer::Servant servant, CORBA::Long id) |
Activate Object, using existing ID. | |
void | deactivate (CORBA::Long id) const |
Deactivate Object with ID. | |
CORBA::Object_ptr | id_to_reference (CORBA::Long id) const |
Convert ID to reference. | |
PortableServer::ServantBase * | reference_to_servant (CORBA::Object_ptr ptr) const |
Convert reference to pointer to servant. | |
CORBA::Object_ptr | servant_to_reference (PortableServer::ServantBase *servant) const |
Protected Member Functions | |
virtual void | set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list) |
Set default POA policies. | |
void | create_i (PortableServer::POA_ptr parent_poa, const char *poa_name, CORBA::PolicyList &policy_list) |
Apply the polices and create child POA. | |
ACE_CString | get_unique_id (void) |
Generate a unique id for each POA created. | |
PortableServer::ObjectId * | long_to_ObjectId (CORBA::Long id) const |
Convert id to ObjectID. | |
Protected Attributes | |
PortableServer::POA_var | poa_ |
POA. | |
TAO_Notify_ID_Factory | id_factory_ |
ID Factory for objects. |
Definition at line 36 of file POA_Helper.h.
|
Default Constructor.
Definition at line 19 of file POA_Helper.cpp.
00020 { 00021 } |
|
Destructor.
Definition at line 23 of file POA_Helper.cpp.
00024 { 00025 } |
|
Activate Object, the POA will assign an ID and return its value.
Definition at line 131 of file POA_Helper.cpp. References ACE_CHECK_RETURN, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, DEBUG_LEVEL, TAO_Notify_ID_Factory::id(), id_factory_, LM_DEBUG, and long_to_ObjectId(). Referenced by TAO_Notify_Object::activate().
00132 { 00133 // Generate a new ID. 00134 id = this->id_factory_.id (); 00135 00136 if (DEBUG_LEVEL > 0) 00137 ACE_DEBUG ((LM_DEBUG, "Activating object with id = %d in POA : %s\n", id, this->poa_->the_name ())); 00138 00139 // Convert CORBA::Long to ObjectId 00140 PortableServer::ObjectId_var oid = 00141 this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); 00142 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00143 00144 poa_->activate_object_with_id (oid.in (), 00145 servant 00146 ACE_ENV_ARG_PARAMETER); 00147 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00148 00149 return poa_->id_to_reference (oid.in () 00150 ACE_ENV_ARG_PARAMETER); 00151 } |
|
Activate Object, using existing ID.
Definition at line 154 of file POA_Helper.cpp. References ACE_CHECK_RETURN, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, DEBUG_LEVEL, id_factory_, LM_DEBUG, long_to_ObjectId(), and TAO_Notify_ID_Factory::set_last_used(). Referenced by TAO_Notify_Object::activate().
00155 { 00156 if (DEBUG_LEVEL > 0) 00157 ACE_DEBUG ((LM_DEBUG, "Activating object with existing id = %d in POA : %s\n", id, this->poa_->the_name ())); 00158 this->id_factory_.set_last_used (id); 00159 00160 // Convert CORBA::Long to ObjectId 00161 PortableServer::ObjectId_var oid = 00162 this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); 00163 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00164 00165 poa_->activate_object_with_id (oid.in (), 00166 servant 00167 ACE_ENV_ARG_PARAMETER); 00168 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00169 00170 return poa_->id_to_reference (oid.in () 00171 ACE_ENV_ARG_PARAMETER); 00172 } |
|
Apply the polices and create child POA.
Definition at line 76 of file POA_Helper.cpp. References ACE_CHECK, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, DEBUG_LEVEL, and LM_DEBUG. Referenced by TAO_Notify_RT_POA_Helper::init(), and init().
00077 { 00078 PortableServer::POAManager_var manager = 00079 parent_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); 00080 ACE_CHECK; 00081 00082 // Create the child POA. 00083 this->poa_ = parent_poa->create_POA (poa_name, 00084 manager.in (), 00085 policy_list 00086 ACE_ENV_ARG_PARAMETER); 00087 ACE_CHECK; 00088 00089 if (DEBUG_LEVEL > 0) 00090 ACE_DEBUG ((LM_DEBUG, "Created POA : %s\n", this->poa_->the_name ())); 00091 /* 00092 // Destroy the policies 00093 for (CORBA::ULong index = 0; index < policy_list.length (); ++index) 00094 { 00095 policy_list[index]->destroy (); 00096 } 00097 */ 00098 } |
|
Deactivate Object with ID.
Definition at line 175 of file POA_Helper.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, and long_to_ObjectId(). Referenced by TAO_Notify_Proxy::deactivate(), and TAO_Notify_Object::deactivate().
00176 { 00177 // Convert CORBA::Long to ObjectId 00178 PortableServer::ObjectId_var oid = 00179 this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); 00180 ACE_CHECK; 00181 00182 poa_->deactivate_object (oid.in () ACE_ENV_ARG_PARAMETER); 00183 } |
|
Destroy underlying POA.
Definition at line 212 of file POA_Helper.cpp. References ACE_ENV_ARG_PARAMETER. Referenced by TAO_Notify_Object::destroy_object_poa(), and TAO_Notify_Object::destroy_proxy_poa().
00213 { 00214 poa_->destroy (1,0 ACE_ENV_ARG_PARAMETER); 00215 // The <wait_for_completion> flag = 0 00216 } |
|
Generate a unique id for each POA created. Factory for generating unique ids for the POAs. Definition at line 28 of file POA_Helper.cpp. References ACE_CString, TAO_Notify_ID_Factory::id(), and ACE_OS::itoa(). Referenced by TAO_Notify_RT_POA_Helper::init(), and init().
00029 { 00030 /// Factory for generating unique ids for the POAs. 00031 static TAO_Notify_ID_Factory poa_id_factory; 00032 00033 char buf[32]; 00034 ACE_OS::itoa (poa_id_factory.id (), buf, 10); 00035 00036 return ACE_CString (buf); 00037 } |
|
Convert ID to reference.
Definition at line 186 of file POA_Helper.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, and long_to_ObjectId(). Referenced by TAO_Notify_Object::ref().
00187 { 00188 // Convert CORBA::Long to ObjectId 00189 PortableServer::ObjectId_var oid = 00190 this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); 00191 ACE_CHECK_RETURN (CORBA::Object::_nil ()); 00192 00193 return poa_->id_to_reference (oid.in () 00194 ACE_ENV_ARG_PARAMETER); 00195 } |
|
Create a new PortableServer::POA. The name is chosen at random.
Reimplemented in TAO_Notify_RT_POA_Helper. Definition at line 51 of file POA_Helper.cpp. References ACE_CString, ACE_ENV_ARG_PARAMETER, get_unique_id(), and init().
00052 { 00053 ACE_CString child_poa_name = this->get_unique_id (); 00054 00055 this->init (parent_poa, child_poa_name.c_str () ACE_ENV_ARG_PARAMETER); 00056 } |
|
Create a new PortableServer::POA.
Definition at line 40 of file POA_Helper.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, create_i(), and set_policy(). Referenced by init(), and TAO_Notify_EventChannelFactory::init().
00041 { 00042 CORBA::PolicyList policy_list (2); 00043 00044 this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER); 00045 ACE_CHECK; 00046 00047 this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER); 00048 } |
|
Convert id to ObjectID.
Definition at line 101 of file POA_Helper.cpp. References ACE_NEW_THROW_EX, and ACE_OS::memcpy(). Referenced by activate(), activate_with_id(), deactivate(), and id_to_reference().
00102 { 00103 // Modified code from string_to_ObjectId .. 00104 // 00105 00106 CORBA::ULong buffer_size = 4; 00107 00108 // Create the buffer for the Id 00109 CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size); 00110 00111 // Copy the contents 00112 ACE_OS::memcpy (buffer, (char*)&id, buffer_size); 00113 00114 // @@ Pradeep: TAO guarantees that Long is 4 bytes wide, but the 00115 // standard only guarantees that it is at least 4 bytes wide. You 00116 // may want to think about that.... 00117 00118 // Create and return a new ID 00119 PortableServer::ObjectId *obj_id = 0; 00120 ACE_NEW_THROW_EX (obj_id, 00121 PortableServer::ObjectId (buffer_size, 00122 buffer_size, 00123 buffer, 00124 1), 00125 CORBA::NO_MEMORY ()); 00126 00127 return obj_id; 00128 } |
|
Get underlying POA.
Definition at line 8 of file POA_Helper.inl.
00009 { 00010 return this->poa_.in (); 00011 } |
|
Convert reference to pointer to servant.
Definition at line 198 of file POA_Helper.cpp. References ACE_ENV_ARG_PARAMETER.
00199 { 00200 return poa_->reference_to_servant (ptr ACE_ENV_ARG_PARAMETER); 00201 } |
|
Definition at line 204 of file POA_Helper.cpp. References ACE_ENV_ARG_PARAMETER. Referenced by TAO_Notify_EventChannel::load_child().
00206 { 00207 return poa_->servant_to_reference (servant ACE_ENV_ARG_PARAMETER); 00208 } |
|
Set default POA policies.
Definition at line 59 of file POA_Helper.cpp. References ACE_CHECK, and ACE_ENV_ARG_PARAMETER. Referenced by TAO_Notify_RT_POA_Helper::init(), and init().
00060 { 00061 policy_list.length (2); 00062 00063 policy_list[0] = 00064 parent_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID 00065 ACE_ENV_ARG_PARAMETER); 00066 ACE_CHECK; 00067 00068 policy_list[1] = 00069 parent_poa->create_id_assignment_policy (PortableServer::USER_ID 00070 ACE_ENV_ARG_PARAMETER); 00071 ACE_CHECK; 00072 } |
|
ID Factory for objects.
Definition at line 104 of file POA_Helper.h. Referenced by activate(), and activate_with_id(). |
|
POA.
Definition at line 101 of file POA_Helper.h. |