#include #include "CipresCommlib/poautil.h" PortableServer::POA_ptr POAUtil::create_basic_POA( PortableServer::POA_ptr parentPOA, PortableServer::POAManager_ptr POAManager, const char * POAName, CORBA::Boolean isMultiThread, CORBA::Boolean isPersistent) { CORBA::PolicyList policies; policies.length(3); CORBA::ULong i = 0; PortableServer::ThreadPolicyValue threadPolicy; if (isMultiThread) { threadPolicy = PortableServer::ORB_CTRL_MODEL; } else { threadPolicy = PortableServer::SINGLE_THREAD_MODEL; } policies[i] = parentPOA->create_thread_policy(threadPolicy); PortableServer::LifespanPolicyValue lifespanPolicy; PortableServer::IdAssignmentPolicyValue idAssignPolicy; if (isPersistent) { lifespanPolicy = PortableServer::PERSISTENT; idAssignPolicy = PortableServer::USER_ID; } else { lifespanPolicy = PortableServer::TRANSIENT; idAssignPolicy = PortableServer::SYSTEM_ID; } policies[++i] = parentPOA->create_lifespan_policy(lifespanPolicy); policies[++i] = parentPOA->create_id_assignment_policy(idAssignPolicy); return parentPOA->create_POA(POAName, POAManager, policies); } CORBA::Object_ptr POAUtil::activate_servant( CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, # if defined(CIPRES_USING_IORTABLE) && CIPRES_USING_IORTABLE IORTable::Table_ptr iortable, # endif PortableServer::ServantBase *servant, const char *objectName, const char *objectAlias) { // create the object ID from the objectName. PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId(objectName); // activate the servant in the poa. poa->activate_object_with_id(oid.in(), servant); // get and display the corresponding corba object reference. CORBA::Object_var obj = poa->id_to_reference(oid.in()); CORBA::String_var ior = orb->object_to_string(obj.in()); std::cout << ior.in() << std::endl; # if defined(CIPRES_USING_IORTABLE) && CIPRES_USING_IORTABLE // register objectAlias as an alias for the full object reference. iortable->bind(objectAlias, ior.in()); # endif return obj._retn(); }