#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_persistent (PortableServer::POA_ptr parent_poa, const char *poa_name) |
Create a new persistent 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 (void) |
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 |
ACE_CString | get_unique_id (void) |
Generate a unique id for each POA created. | |
Protected Member Functions | |
virtual void | set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list) |
Set default POA policies. | |
virtual void | set_persistent_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list) |
Set persistent 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. | |
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.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Notify_POA_Helper::TAO_Notify_POA_Helper | ( | void | ) |
TAO_Notify_POA_Helper::~TAO_Notify_POA_Helper | ( | ) | [virtual] |
CORBA::Object_ptr TAO_Notify_POA_Helper::activate | ( | PortableServer::Servant | servant, | |
CORBA::Long & | id | |||
) |
Activate Object, the POA will assign an ID and return its value.
Definition at line 155 of file POA_Helper.cpp.
References ACE_DEBUG, DEBUG_LEVEL, TAO_Notify_ID_Factory::id(), id_factory_, LM_DEBUG, long_to_ObjectId(), and poa_.
Referenced by TAO_Notify_Object::activate().
00156 { 00157 // Generate a new ID. 00158 id = this->id_factory_.id (); 00159 00160 if (DEBUG_LEVEL > 0) 00161 { 00162 CORBA::String_var the_name = this->poa_->the_name (); 00163 00164 ACE_DEBUG ((LM_DEBUG, "Activating object with id = %d in POA : %s\n", id, the_name.in ())); 00165 } 00166 00167 // Convert CORBA::Long to ObjectId 00168 PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); 00169 00170 poa_->activate_object_with_id (oid.in (), servant); 00171 00172 return poa_->id_to_reference (oid.in ()); 00173 }
CORBA::Object_ptr TAO_Notify_POA_Helper::activate_with_id | ( | PortableServer::Servant | servant, | |
CORBA::Long | id | |||
) |
Activate Object, using existing ID.
Definition at line 176 of file POA_Helper.cpp.
References ACE_DEBUG, DEBUG_LEVEL, id_factory_, LM_DEBUG, long_to_ObjectId(), poa_, and TAO_Notify_ID_Factory::set_last_used().
Referenced by TAO_Notify_Object::activate().
00177 { 00178 if (DEBUG_LEVEL > 0) 00179 { 00180 CORBA::String_var the_name = this->poa_->the_name (); 00181 ACE_DEBUG ((LM_DEBUG, "Activating object with existing id = %d in POA : %s\n", id, the_name.in ())); 00182 } 00183 this->id_factory_.set_last_used (id); 00184 00185 // Convert CORBA::Long to ObjectId 00186 PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); 00187 00188 poa_->activate_object_with_id (oid.in (), servant); 00189 00190 return poa_->id_to_reference (oid.in ()); 00191 }
void TAO_Notify_POA_Helper::create_i | ( | PortableServer::POA_ptr | parent_poa, | |
const char * | poa_name, | |||
CORBA::PolicyList & | policy_list | |||
) | [protected] |
Apply the polices and create child POA.
Definition at line 98 of file POA_Helper.cpp.
References ACE_DEBUG, DEBUG_LEVEL, TAO_Objref_Var_T< T >::in(), LM_DEBUG, and poa_.
Referenced by TAO_Notify_RT_POA_Helper::init(), init(), and init_persistent().
00102 { 00103 PortableServer::POAManager_var manager = 00104 parent_poa->the_POAManager (); 00105 00106 // Create the child POA. 00107 this->poa_ = parent_poa->create_POA (poa_name, manager.in (), policy_list); 00108 00109 if (DEBUG_LEVEL > 0) 00110 { 00111 CORBA::String_var the_name = this->poa_->the_name (); 00112 ACE_DEBUG ((LM_DEBUG, "Created POA : %s\n", the_name.in ())); 00113 } 00114 00115 /* 00116 // Destroy the policies 00117 for (CORBA::ULong index = 0; index < policy_list.length (); ++index) 00118 { 00119 policy_list[index]->destroy (); 00120 } 00121 */ 00122 }
void TAO_Notify_POA_Helper::deactivate | ( | CORBA::Long | id | ) | const |
Deactivate Object with ID.
Definition at line 194 of file POA_Helper.cpp.
References long_to_ObjectId(), and poa_.
Referenced by TAO_Notify_Proxy::deactivate(), and TAO_Notify_Object::deactivate().
00195 { 00196 // Convert CORBA::Long to ObjectId 00197 PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); 00198 00199 poa_->deactivate_object (oid.in ()); 00200 }
void TAO_Notify_POA_Helper::destroy | ( | void | ) |
Destroy underlying POA.
Definition at line 226 of file POA_Helper.cpp.
References poa_.
Referenced by TAO_Notify_Object::destroy_object_poa(), and TAO_Notify_Object::destroy_proxy_poa().
00227 { 00228 poa_->destroy (1,0); 00229 // The <wait_for_completion> flag = 0 00230 }
ACE_CString TAO_Notify_POA_Helper::get_unique_id | ( | void | ) |
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 TAO_Notify_ID_Factory::id(), and ACE_OS::itoa().
Referenced by TAO_Notify_RT_POA_Helper::init(), init(), and TAO_Notify_EventChannelFactory::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 }
CORBA::Object_ptr TAO_Notify_POA_Helper::id_to_reference | ( | CORBA::Long | id | ) | const |
Convert ID to reference.
Definition at line 203 of file POA_Helper.cpp.
References long_to_ObjectId(), and poa_.
Referenced by TAO_Notify_Object::ref().
00204 { 00205 // Convert CORBA::Long to ObjectId 00206 PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); 00207 00208 return poa_->id_to_reference (oid.in ()); 00209 }
void TAO_Notify_POA_Helper::init | ( | PortableServer::POA_ptr | parent_poa | ) |
Create a new PortableServer::POA. The name is chosen at random.
Reimplemented in TAO_Notify_RT_POA_Helper.
Definition at line 62 of file POA_Helper.cpp.
References ACE_String_Base< CHAR >::c_str(), get_unique_id(), and init().
00063 { 00064 ACE_CString child_poa_name = this->get_unique_id (); 00065 00066 this->init (parent_poa, child_poa_name.c_str ()); 00067 }
void TAO_Notify_POA_Helper::init | ( | PortableServer::POA_ptr | parent_poa, | |
const char * | poa_name | |||
) |
Create a new PortableServer::POA.
Definition at line 40 of file POA_Helper.cpp.
References 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); 00045 00046 this->create_i (parent_poa, poa_name, policy_list); 00047 }
void TAO_Notify_POA_Helper::init_persistent | ( | PortableServer::POA_ptr | parent_poa, | |
const char * | poa_name | |||
) |
Create a new persistent PortableServer::POA.
Definition at line 51 of file POA_Helper.cpp.
References create_i(), and set_persistent_policy().
Referenced by TAO_Notify_EventChannelFactory::init().
00052 { 00053 CORBA::PolicyList policy_list (2); 00054 00055 this->set_persistent_policy (parent_poa, policy_list); 00056 00057 this->create_i (parent_poa, poa_name, policy_list); 00058 }
PortableServer::ObjectId * TAO_Notify_POA_Helper::long_to_ObjectId | ( | CORBA::Long | id | ) | const [protected] |
Convert id to ObjectID.
Definition at line 125 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().
00126 { 00127 // Modified code from string_to_ObjectId .. 00128 // 00129 00130 CORBA::ULong buffer_size = 4; 00131 00132 // Create the buffer for the Id 00133 CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size); 00134 00135 // Copy the contents 00136 ACE_OS::memcpy (buffer, (char*)&id, buffer_size); 00137 00138 // @@ Pradeep: TAO guarantees that Long is 4 bytes wide, but the 00139 // standard only guarantees that it is at least 4 bytes wide. You 00140 // may want to think about that.... 00141 00142 // Create and return a new ID 00143 PortableServer::ObjectId *obj_id = 0; 00144 ACE_NEW_THROW_EX (obj_id, 00145 PortableServer::ObjectId (buffer_size, 00146 buffer_size, 00147 buffer, 00148 1), 00149 CORBA::NO_MEMORY ()); 00150 00151 return obj_id; 00152 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE PortableServer::POA_ptr TAO_Notify_POA_Helper::poa | ( | void | ) |
Get underlying POA.
Definition at line 8 of file POA_Helper.inl.
References TAO_Objref_Var_T< T >::in(), and poa_.
Referenced by TAO_Notify_EventChannel::default_supplier_admin().
PortableServer::ServantBase * TAO_Notify_POA_Helper::reference_to_servant | ( | CORBA::Object_ptr | ptr | ) | const |
Convert reference to pointer to servant.
Definition at line 212 of file POA_Helper.cpp.
References poa_.
Referenced by TAO_Notify_EventChannel::default_consumer_admin().
00213 { 00214 return poa_->reference_to_servant (ptr); 00215 }
CORBA::Object_ptr TAO_Notify_POA_Helper::servant_to_reference | ( | PortableServer::ServantBase * | servant | ) | const |
Definition at line 218 of file POA_Helper.cpp.
References poa_.
00220 { 00221 return poa_->servant_to_reference (servant); 00222 }
void TAO_Notify_POA_Helper::set_persistent_policy | ( | PortableServer::POA_ptr | parent_poa, | |
CORBA::PolicyList & | policy_list | |||
) | [protected, virtual] |
Set persistent POA policies.
Definition at line 84 of file POA_Helper.cpp.
Referenced by init_persistent().
00085 { 00086 policy_list.length (2); 00087 00088 policy_list[0] = 00089 parent_poa->create_lifespan_policy (PortableServer::PERSISTENT); 00090 00091 policy_list[1] = 00092 parent_poa->create_id_assignment_policy (PortableServer::USER_ID); 00093 }
void TAO_Notify_POA_Helper::set_policy | ( | PortableServer::POA_ptr | parent_poa, | |
CORBA::PolicyList & | policy_list | |||
) | [protected, virtual] |
Set default POA policies.
Definition at line 70 of file POA_Helper.cpp.
Referenced by TAO_Notify_RT_POA_Helper::init(), and init().
00071 { 00072 policy_list.length (2); 00073 00074 policy_list[0] = 00075 parent_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID); 00076 00077 policy_list[1] = 00078 parent_poa->create_id_assignment_policy (PortableServer::USER_ID); 00079 }
ID Factory for objects.
Definition at line 108 of file POA_Helper.h.
Referenced by activate(), and activate_with_id().
PortableServer::POA_var TAO_Notify_POA_Helper::poa_ [protected] |
POA.
Definition at line 105 of file POA_Helper.h.
Referenced by activate(), activate_with_id(), create_i(), deactivate(), destroy(), id_to_reference(), poa(), reference_to_servant(), and servant_to_reference().