本文整理汇总了C++中portableserver::POA_var::create_POA方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_var::create_POA方法的具体用法?C++ POA_var::create_POA怎么用?C++ POA_var::create_POA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portableserver::POA_var
的用法示例。
在下文中一共展示了POA_var::create_POA方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_persistent_poa
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
PortableServer::POA_var create_persistent_poa(PortableServer::POA_var root_poa,
PortableServer::POAManager_var mgr,
const char* name,
CORBA::PolicyList& policy_list)
{
PortableServer::POA_var result;
PortableServer::LifespanPolicy_var lifespan =
root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
// create a USER_ID IdAssignmentPolicy object
PortableServer::IdAssignmentPolicy_var assign =
root_poa->create_id_assignment_policy(PortableServer::USER_ID);
// create PolicyList.
size_t orig_len = policy_list.length();
policy_list.length(orig_len+2);
policy_list[orig_len+0]=
PortableServer::LifespanPolicy::_duplicate(lifespan.in());
policy_list[orig_len+1]=
PortableServer::IdAssignmentPolicy::_duplicate(assign.in());
// create the child POA
result = root_poa->create_POA(name, mgr.in(), policy_list);
return result;
}
示例2:
void
createPOAs(ACE_CString &base)
{
PortableServer::LifespanPolicy_var life =
root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
PortableServer::IdAssignmentPolicy_var assign =
root_poa->create_id_assignment_policy(PortableServer::USER_ID);
CORBA::PolicyList pols;
pols.length(2);
pols[0] = PortableServer::LifespanPolicy::_duplicate(life.in());
pols[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign.in());
PortableServer::POAManager_var mgr = PortableServer::POAManager::_nil();
ACE_CString poa_name = base + ACE_CString ("_a");
poa_a = root_poa->create_POA(poa_name.c_str(), mgr.in(), pols);
poa_name = base + ACE_CString ("_b");
poa_b = root_poa->create_POA(poa_name.c_str(), mgr.in(), pols);
}
示例3: create_user_persistent_POA
void PersistentServantBase::create_user_persistent_POA(const char* POAname)
{
Object_var poaObj = orb_->resolve_initial_references("RootPOA");
PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj.in());
PortableServer::POAManager_var poaManager = rootPOA->the_POAManager();
poaManager->activate();
PolicyList policyList;
policyList.length(2);
policyList[0] = rootPOA->create_lifespan_policy(PortableServer::PERSISTENT);
policyList[1] = rootPOA->create_id_assignment_policy(PortableServer::USER_ID);
defaultPOA_ = rootPOA->create_POA( POAname,
poaManager,
policyList );
}
示例4: Stock_StockNameConsumer_i
// Implementation skeleton constructor
Stock_StockBroker_i::Stock_StockBroker_i (CORBA::ORB_ptr orb,
Stock::StockDistributor_ptr dist,
const char *stock_name)
: orb_ (CORBA::ORB::_duplicate (orb)),
quoter_ (Stock::StockQuoter::_nil()),
consumer_ (0),
distributor_ (Stock::StockDistributor::_duplicate (dist))
{
// Get a reference to the <RTORB>.
CORBA::Object_var obj = orb->resolve_initial_references ("RTORB");
RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ());
// Create a <CORBA::PolicyList> for the child POA.
TAO::Utils::PolicyList_Destroyer consumer_policies (1);
consumer_policies.length (1);
// Create a <CLIENT_PROPAGATED> priority model policy.
consumer_policies[0] =
rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
Stock::Priority_Mapping::MEDIUM);
PortableServer::POA_var poa = this->_default_POA ();
PortableServer::POAManager_var poa_mgr = poa->the_POAManager ();
// Create a child POA with CLIENT_PROPAGATED policies. The name of
// the POA will be <StockNameConsumer_POA>. Instances of the
// Stock_StockNameConsumer_i will be activated under this POA.
PortableServer::POA_var child_poa =
poa->create_POA ("StockNameConsumer_POA",
poa_mgr. in(),
consumer_policies);
// Narrow the POA to a <RTPortableServer::POA>.
RTPortableServer::POA_var rt_poa =
RTPortableServer::POA::_narrow (child_poa.in ());
// Create and activate the <consumer_>.
this->consumer_ =
new Stock_StockNameConsumer_i (*this, stock_name);
PortableServer::ServantBase_var nameconsumer_owner_transfer =
this->consumer_;
rt_poa->activate_object (this->consumer_);
}
示例5: policies
int
main( int argc, char *argv[] )
{
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
// Destringify ior
CORBA::Object_var obj = orb->string_to_object( "file://IOR" );
if( CORBA::is_nil( obj.in() ) ) {
cerr << "Nil reference" << endl;
throw 0;
}
// Narrow
CallbackServer_var cb_server = CallbackServer::_narrow( obj.in() );
if( CORBA::is_nil( cb_server.in() ) ) {
cerr << "Argument is not a CallbackServer reference" << endl;
throw 0;
}
//Get reference to Root POA
obj = orb->resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );
// Policies for the childPOA to be created.
CORBA::PolicyList policies (4);
policies.length (4);
CORBA::Any pol;
pol <<= BiDirPolicy::BOTH;
policies[0] =
orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
pol);
policies[1] =
poa->create_id_assignment_policy(PortableServer::SYSTEM_ID);
policies[2] =
poa->create_implicit_activation_policy( PortableServer::IMPLICIT_ACTIVATION );
policies[3] =
poa->create_lifespan_policy(PortableServer::TRANSIENT);
PortableServer::POAManager_var mgr = poa->the_POAManager();
// Create POA as child of RootPOA with the above policies. This POA
// will receive request in the same connection in which it sent
// the request
PortableServer::POA_var child_poa =
poa->create_POA ("childPOA",
mgr.in(),
policies);
// Creation of childPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
policies[i]->destroy ();
}
// Activate POA Manager
mgr->activate();
// Create an object
ClientCallback_i servant;
// Register the servant with the RootPOA, obtain its object
// reference, stringify it, and write it to a file.
obj = child_poa->servant_to_reference( &servant );
//ClientCallback_var ccb = ClientCallback::_narrow( obj.in() );
cb_server->callback_hello( ClientCallback::_narrow( obj.in() ),
CORBA::string_dup( "Greetings earthling" ));
}
catch( const CORBA::Exception &ex ) {
cerr << "Uncaught CORBA exception: " << ex << endl;
return 1;
}
}
示例6: policies
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootPOA = PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager ();
// Policies for the firstPOA to be created.
CORBA::PolicyList policies (5);
policies.length (5);
// Lifespan policy
policies[0] =
rootPOA->create_lifespan_policy (PortableServer::PERSISTENT );
// Servant Retention Policy
policies[1] =
rootPOA->create_servant_retention_policy (PortableServer::RETAIN );
// ID Assignment Policy
policies[2] =
rootPOA->create_id_assignment_policy (PortableServer::USER_ID );
// Request Processing Policy
policies[3] =
rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );
// Threading policy
policies[4] =
rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL );
PortableServer::POA_var demoPOA
= rootPOA->create_POA ("HelloWorldServer",
poa_manager.in (),
policies
);
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
// Create object for shutdown commanded by client.
{
// create the object
Demo_HelloWorld_i * hello = new Demo_HelloWorld_i(orb.in());
// Get the Object ID.
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("shutdown");
demoPOA->activate_object_with_id (oid.in (), hello);
// Create an object reference.
CORBA::Object_var myhello = demoPOA->id_to_reference(oid.in());
// Put the object reference as an IOR string
ofstream out(ACE_TEXT_ALWAYS_CHAR (shutdown_ior_output_file));
CORBA::String_var ior = orb->object_to_string (myhello.in ());
out << ior.in();
// save the reference into a file
out.close();
}
// Create object to handle client sayHello requests.
{
// create the object
Demo_HelloWorld_i * hello = new Demo_HelloWorld_i(orb.in());
// Get the Object ID.
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("hello");
demoPOA->activate_object_with_id (oid.in (), hello);
// Create an object reference.
CORBA::Object_var myhello = demoPOA->id_to_reference(oid.in());
// Put the object reference as an IOR string
ofstream out(ACE_TEXT_ALWAYS_CHAR (ior_output_file));
CORBA::String_var ior = orb->object_to_string (myhello.in ());
out << ior.in();
// save the reference into a file
out.close();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
poa_manager->activate ();
std::cout << ior_output_file << " is ready " << std::endl;
//.........这里部分代码省略.........
示例7: lanes
// Implementation skeleton constructor
StockDistributorHome_i::StockDistributorHome_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate (orb)),
rt_poa_ (RTPortableServer::POA::_nil ()),
dist_id_ (0)
{
// Register this class as a signal handler to catch keyboard interrupts.
if (orb_->orb_core ()->reactor ()->register_handler (SIGINT, this) == -1)
ACE_DEBUG ((LM_DEBUG, "ERROR: Failed to register as a signal handler: %p\n",
"register_handler\n"));
// Register the necessary factories and mappings with the specified
// <orb>. If we neglect to perform these registrations then the app
// will not execute.
Stock::StockNames_init *stockname_factory = new Stock::StockNames_init;
orb_->register_value_factory (stockname_factory->tao_repository_id (),
stockname_factory);
Stock::Cookie_init *cookie_factory = new Stock::Cookie_init;
this->orb_->register_value_factory (cookie_factory->tao_repository_id (),
cookie_factory);
Stock::Priority_Mapping::register_mapping (orb_.in ());
// Get a reference to the <RTORB>.
CORBA::Object_var obj = orb_->resolve_initial_references ("RTORB");
RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (obj.in ());
TAO::Utils::PolicyList_Destroyer policies (2);
policies.length (2);
// Create a <SERVER_DECLARED> priority model policy.
policies[0] =
rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED,
Stock::Priority_Mapping::VERY_LOW);
// Create a threadpool with lanes for the distributor. Since the brokers
// will have various priorities, create a lane for each priority.
RTCORBA::ThreadpoolLanes lanes (5); lanes.length (5);
for (CORBA::ULong i = 0; i < lanes.length (); ++i)
{
lanes[i].lane_priority = static_cast<RTCORBA::Priority> (i);
lanes[i].static_threads = 5;
lanes[i].dynamic_threads = 0;
}
RTCORBA::ThreadpoolId threadpool_id =
rt_orb->create_threadpool_with_lanes (1024*1024,
lanes,
false, false, 0, 0);
policies[1] = rt_orb->create_threadpool_policy (threadpool_id);
PortableServer::POA_var poa = this->_default_POA ();
PortableServer::POAManager_var poa_mgr = poa->the_POAManager ();
// Create a child POA with <SERVER_DECLARED> policies. The name of
// the POA will be <StockDistributor_POA>. Any instances of the
// StockDistributor_i created via the create() method will be
// activated under this POA.
PortableServer::POA_var child_poa =
poa->create_POA ("StockDistributor_POA",
poa_mgr.in (),
policies);
// Narrow the POA to a RT POA, and cache the reference
this->rt_poa_ = RTPortableServer::POA::_narrow (child_poa.in ());
// Create the initial distributor reference
this->create_distributor ();
}
示例8: policies
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
{
return 1;
}
CORBA::Object_var object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow (object.in ());
PortableServer::POAManager_var poa_manager =
rootPOA->the_POAManager ();
CORBA::PolicyList policies (5);
policies.length (5);
// Lifespan policy
policies[0] =
rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);
// Servant Retention Policy
policies[1] =
rootPOA->create_servant_retention_policy (PortableServer::RETAIN );
// ID Assignment Policy
policies[2] =
rootPOA->create_id_assignment_policy (PortableServer::USER_ID );
// Request Processing Policy
policies[3] =
rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );
// Threading policy
policies[4] =
rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
PortableServer::POA_var poa_a = rootPOA->create_POA ("poaA",
poa_manager.in (),
policies
);
PortableServer::POA_var poa_c = rootPOA->create_POA ("poaC",
poa_manager.in (),
policies
);
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
Test_Time_i* time = new Test_Time_i();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("Server_A");
poa_a->activate_object_with_id (oid.in (), time);
CORBA::Object_var time_obj = poa_a->id_to_reference(oid.in());
CORBA::String_var ior =
orb->object_to_string (time_obj.in ());
poa_manager->activate ();
FILE *output_file = ACE_OS::fopen (pid_file, ACE_TEXT ("w"));
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Cannot open output file for writing IOR: %s\n"),
pid_file),
1);
int pid = static_cast<int> (ACE_OS::getpid ());
ACE_OS::fprintf (output_file, "%d\n", pid);
ACE_OS::fclose (output_file);
orb->run ();
rootPOA->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception &ex)
{
ex._tao_print_exception (ACE_TEXT ("server:"));
return 1;
}
return 0;
}
示例9: bindServiceObject
//.........这里部分代码省略.........
try{
nc->bind(name,object);
}catch(const CosNaming::NamingContext::AlreadyBound&){
std::cerr<<argv()[0]<<":can't bind "<<objName<<" (AlreadyBound)"<< std::endl;
return false;
}
}
}catch(const CosNaming::NamingContext::CannotProceed&){
std::cerr<<argv()[0]<<": can't bind "<<objName<<" (CannotProceed)"<< std::endl;
return false;
}catch(const CosNaming::NamingContext::InvalidName&){
std::cerr<<argv()[0]<<":can't bind "<<objName<<" (InvalidName)"<< std::endl;
return false;
}
std::cout<<argv()[0]<<": binding completed successfully"<<std::endl;
}
CORBA::String_var ior ;
try {
ior = orb->object_to_string(object);
}catch(const CORBA::SystemException& ex){
#ifdef CORBA_SYSTEM_EXCEPTION_IS_STREAMBLE
std::cerr << ex << std::endl;
#else
std::cerr << "CORBA::SystemException" << std::endl;
#endif
return false;
}
const char* fname = get_ior_fname(objName);
if (fname!=NULL && strcmp(fname,"")!=0) {
std::ofstream ofs (fname);
if (ofs.bad()) {
std::cerr << argv()[0] << ": can't open file " << fname << std::endl;
perror(argv()[0]);
return false;
}
ofs << ior.in();
ofs.close();
}
if (is_set("ior-stdout")) {
std::cout << ior << std::flush;
}
#ifdef ORBACUS
CORBA::Object_var bmgrObj = orb->resolve_initial_references("BootManager");
OB::BootManager_var bootManager = OB::BootManager::_narrow(bmgrObj);
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId(objName);
bootManager -> add_binding(oid.in(),object);
#elif defined(OMNIORB)
PortableServer::POA_var objPOA = p_servant->_default_POA();
CORBA::String_var objPOAName = objPOA->the_name();
if (strcmp(objPOAName.in(),"omniINSPOA")!=0) {
CORBA::Object_var insPOAObj = orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var insPOA = PortableServer::POA::_narrow(insPOAObj);
PortableServer::POAManager_var insPOAManager=insPOA->the_POAManager();
insPOAManager->activate();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId(objName);
insPOA->activate_object_with_id(oid.in(),p_servant);
}
#elif defined(RSSH_TAO)
#ifdef TAO_HAVE_IORTABLE_ADAPTER
CORBA::Object_var table = orb->resolve_initial_references ("IORTable");
IORTable::Table_var adapter = IORTable::Table::_narrow (table.in());
if (CORBA::is_nil(adapter.in())) {
cerr<<argv()[0]<<": nil IORTable reference"<<endl;
} else {
adapter->bind (objName, ior.in ());
}
#else
ACE_CString ins(objName);
if (orb->_tao_add_to_IOR_table(ins,object)!=0) {
return false;
}
#endif
#elif defined(MICO)
// create persistent POA with name as service name if we have no one.
PortableServer::POA_var objPOA = p_servant->_default_POA();
CORBA::String_var objPOAName = objPOA->the_name();
std::cerr << "existent OBJPOAName=" << objPOAName.in() << std::endl;
std::cerr << "objName=" << objName << std::endl;
if (strcmp(objPOAName.in(),objName)!=0) {
CORBA::Object_var rootPOAObj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(rootPOAObj);
CORBA::PolicyList pl;
pl.length (2);
pl[0] = rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);
pl[1] = rootPOA->create_id_assignment_policy (PortableServer::USER_ID);
PortableServer::POA_var objPOA = rootPOA->create_POA(objName,
PortableServer::POAManager::_nil (),
pl);
PortableServer::POAManager_var objPOAManager = objPOA->the_POAManager ();
PortableServer::ObjectId_var objId =
PortableServer::string_to_ObjectId (objName);
objPOA->activate_object_with_id (objId.in(), p_servant);
objPOAManager->activate();
}else{
//PortbaobjPOA
}
#endif
return true;
}
示例10: ctrl_servant
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
CORBA::ORB_var orb;
try {
// Initialize orb
orb = CORBA::ORB_init (argc, argv);
// Get reference to Root POA.
CORBA::Object_var obj
= orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa
= PortableServer::POA::_narrow (obj.in ());
// Get POA manager
PortableServer::POAManager_var poa_mgr = poa->the_POAManager ();
// Create a policy list. We use persistent objects with
// user-assigned IDs, and explicit activation.
CORBA::PolicyList policy_list;
policy_list.length (6);
policy_list[0] = poa->create_lifespan_policy (
PortableServer::TRANSIENT // REVISIT
);
policy_list[1] = poa->create_id_assignment_policy (
PortableServer::USER_ID
);
policy_list[2] = poa->create_implicit_activation_policy (
PortableServer::NO_IMPLICIT_ACTIVATION
);
policy_list[3] = poa->create_request_processing_policy (
PortableServer::USE_SERVANT_MANAGER
);
policy_list[4] = poa->create_servant_retention_policy (
PortableServer::NON_RETAIN
);
policy_list[5] = poa->create_thread_policy (
PortableServer::SINGLE_THREAD_MODEL
);
// Create a POA for all CCS elements.
PortableServer::POA_var ccs_poa
= poa->create_POA ("CCS_POA", poa_mgr.in (), policy_list);
// Create a controller and set static m_ctrl member
// for thermostats and thermometers.
Controller_impl ctrl_servant (ccs_poa.in (), "/tmp/CCS_assets");
Thermometer_impl::m_ctrl = &ctrl_servant;
// Create a reference for the controller and
// create the corresponding CORBA object.
PortableServer::ObjectId_var oid
= PortableServer::string_to_ObjectId (Controller_oid);
CORBA::Object_var ctrl
= ccs_poa->create_reference_with_id (
oid.in (), "IDL:acme.com/CCS/Controller:1.0"
);
// Get reference to initial naming context.
CosNaming::NamingContext_var inc
= resolve_init<CosNaming::NamingContext> (
orb.in (), "NameService"
);
// Attempt to create CCS context.
CosNaming::Name n;
n.length (1);
n[0].id = CORBA::string_dup ("CCS");
try {
CosNaming::NamingContext_var nc
= inc->bind_new_context (n);
} catch (const CosNaming::NamingContext::AlreadyBound &) {
// Fine, CCS context already exists.
}
// Force binding of controller reference to make
// sure it is always up-to-date.
n.length (2);
n[1].id = CORBA::string_dup ("Controller");
inc->rebind (n, ctrl.in ());
// Instantiate the servant locator for devices.
PortableServer::ServantManager_var locator =
new DeviceLocator_impl (&ctrl_servant);
// Set servant locator.
ccs_poa->set_servant_manager (locator.in ());
// Activate the POA manager.
poa_mgr->activate ();
// Accept requests
orb->run ();
}
catch (const CORBA::Exception & e) {
std::cerr << "Uncaught CORBA exception: "
<< e
<< std::endl;
return 1;
//.........这里部分代码省略.........
示例11:
RtecEventChannelAdmin::EventChannel_ptr
FTEC_Gateway::activate(PortableServer::POA_ptr root_poa)
{
PortableServer::POA_var poa;
PortableServer::POAManager_var mgr;
if (impl_->local_orb) {
int argc = 0;
char** argv = 0;
impl_->orb = CORBA::ORB_init(argc, argv, "FTEC_GatewayORB");
Interceptor_Destoryer::execute(impl_->orb.in());
poa = resolve_init<PortableServer::POA>(impl_->orb.in(), "RootPOA");
mgr = poa->the_POAManager();
mgr->activate();
}
else {
poa = PortableServer::POA::_duplicate(root_poa);
mgr = poa->the_POAManager();
}
PortableServer::IdUniquenessPolicy_var id_uniqueness_policy =
poa->create_id_uniqueness_policy(PortableServer::MULTIPLE_ID);
PortableServer::LifespanPolicy_var lifespan =
poa->create_lifespan_policy(PortableServer::PERSISTENT);
// create a USER_ID IdAssignmentPolicy object
PortableServer::IdAssignmentPolicy_var assign =
poa->create_id_assignment_policy(PortableServer::USER_ID);
CORBA::PolicyList policy_list;
policy_list.length(3);
policy_list[0] = PortableServer::IdUniquenessPolicy::_duplicate(
id_uniqueness_policy.in());
policy_list[1]=
PortableServer::LifespanPolicy::_duplicate(lifespan.in());
policy_list[2]=
PortableServer::IdAssignmentPolicy::_duplicate(assign.in());
impl_->poa = poa->create_POA("gateway_poa", mgr.in(), policy_list);
id_uniqueness_policy->destroy();
lifespan->destroy();
assign->destroy();
FtRtecEventComm::ObjectId oid;
oid.length(16);
TAO_FtRt::UUID::create(oid.get_buffer());
RtecEventChannelAdmin::EventChannel_var gateway;
activate_object_with_id(gateway.out(), impl_->poa.in(), this, oid);
++oid[9];
activate_object_with_id(impl_->consumer_admin.out(),
impl_->poa.in(),
&impl_->consumer_admin_servant,
oid);
++oid[9];
activate_object_with_id(impl_->supplier_admin.out(),
impl_->poa.in(),
&impl_->supplier_admin_servant,
oid);
return gateway._retn();
}
示例12: lanes
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var naming_obj =
orb->resolve_initial_references ("NameService");
CosNaming::NamingContext_var naming_context =
CosNaming::NamingContext::_narrow(naming_obj.in());
CosNaming::Name name;
name.length (1);
name[0].id = CORBA::string_dup("MyEventChannel");
CORBA::Object_var ecObj = naming_context->resolve(name);
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers(ifgop,
adminid);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in());
CORBA::Object_var rtorb_obj = orb->resolve_initial_references ("RTORB");
RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (rtorb_obj.in ());
// Create an RT POA with a lane at the given priority.
CORBA::Policy_var priority_model_policy =
rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
DEFAULT_PRIORITY);
RTCORBA::ThreadpoolLanes lanes (2);
lanes.length (2);
lanes[0].lane_priority = LOW_PRIORITY;
lanes[0].static_threads = 2;
lanes[0].dynamic_threads = 0;
lanes[1].lane_priority = HIGH_PRIORITY;
lanes[1].static_threads = 2;
lanes[1].dynamic_threads = 0;
// Create a thread-pool.
CORBA::ULong stacksize = 0;
CORBA::Boolean allow_request_buffering = 0;
CORBA::ULong max_buffered_requests = 0;
CORBA::ULong max_request_buffer_size = 0;
CORBA::Boolean allow_borrowing = 0;
// Create the thread-pool.
RTCORBA::ThreadpoolId threadpool_id =
rt_orb->create_threadpool_with_lanes (stacksize,
lanes,
allow_borrowing,
allow_request_buffering,
max_buffered_requests,
max_request_buffer_size);
// Create a thread-pool policy.
CORBA::Policy_var lanes_policy =
rt_orb->create_threadpool_policy (threadpool_id);
CORBA::PolicyList poa_policy_list(2);
poa_policy_list.length (2);
poa_policy_list[0] = priority_model_policy;
poa_policy_list[1] = lanes_policy;
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
PortableServer::POA_var rt_poa = poa->create_POA ("RT POA",
poa_manager.in (),
poa_policy_list);
PortableServer::Servant_var<StructuredEventConsumer_i> servant =
new StructuredEventConsumer_i(orb.in());
PortableServer::ObjectId_var objectId =
rt_poa->activate_object (servant.in());
CORBA::Object_var consumer_obj =
rt_poa->id_to_reference (objectId.in ());
CosNotifyComm::StructuredPushConsumer_var consumer =
CosNotifyComm::StructuredPushConsumer::_narrow (consumer_obj.in ());
//.........这里部分代码省略.........
示例13: out
int
run(CORBA::ORB_ptr orb, int /* argc */, char* argv[])
{
//
// Resolve Root POA
//
CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj);
//
// Create Persistent POA
//
CORBA::PolicyList pl;
pl.length (4);
pl[0] = rootPOA->create_lifespan_policy(PortableServer::PERSISTENT);
pl[1] = rootPOA->create_id_assignment_policy(PortableServer::USER_ID);
pl[2] = rootPOA->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
pl[3] = rootPOA->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION);
//
// Get a reference to the POA manager
//
PortableServer::POAManager_var manager = rootPOA -> the_POAManager();
//
// Create Persistent POA
//
PortableServer::POA_var stapoa = rootPOA->create_POA ("stapoa",manager,pl) ;
//
// Resolve the BootManager and register the server
//
CORBA::Object_var obj = orb -> resolve_initial_references("BootManager");
OB::BootManager_var bootManager = OB::BootManager::_narrow(obj);
//
// Create implementation object
//
Hello_impl* helloImpl = new Hello_impl(stapoa);
PortableServer::ServantBase_var servant = helloImpl;
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId("Hello");
stapoa->activate_object_with_id(oid, servant);
Hello_var hello = helloImpl -> _this();
//
// add binding to BootManager
//
bootManager -> add_binding(oid, hello);
//
// Save reference
//
CORBA::String_var s = orb -> object_to_string(hello);
const char* refFile = "Hello.ref";
ofstream out(refFile);
if(out.fail())
{
cerr << argv[0] << ": can't open `" << refFile << "': "
<< strerror(errno) << endl;
return EXIT_FAILURE;
}
out << s << endl;
out.close();
//
// Run implementation
//
manager -> activate();
orb -> run();
return EXIT_SUCCESS;
}
示例14: worker
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
{
return 1;
}
CORBA::Object_var object =
orb->resolve_initial_references ("RootPOA");
ORB_Task worker (orb.in ());
worker.activate (THR_NEW_LWP | THR_JOINABLE,
1);
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow (object.in ());
PortableServer::POAManager_var poa_manager =
rootPOA->the_POAManager ();
CORBA::PolicyList policies (5);
policies.length (5);
// Lifespan policy
policies[0] =
rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);
// Servant Retention Policy
policies[1] =
rootPOA->create_servant_retention_policy (PortableServer::RETAIN );
// ID Assignment Policy
policies[2] =
rootPOA->create_id_assignment_policy (PortableServer::USER_ID );
// Request Processing Policy
policies[3] =
rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );
// Threading policy
policies[4] =
rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
if (server_notify_delay > 0)
{
ACE_OS::sleep (server_notify_delay);
ACE_DEBUG ((LM_DEBUG, "(%P|%t)ServerB Now register with IMR \n"));
}
PortableServer::POA_var poa_a = rootPOA->create_POA ("poaB",
poa_manager.in (),
policies
);
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
Test_Dummy_i* dummy = new Test_Dummy_i();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("Server_B");
poa_a->activate_object_with_id (oid.in (), dummy);
CORBA::Object_var dummy_obj = poa_a->id_to_reference(oid.in());
CORBA::String_var ior =
orb->object_to_string (dummy_obj.in ());
poa_manager->activate ();
// Output the IOR to the <ior_output_file>
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
worker.wait ();
rootPOA->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception &ex)
{
ex._tao_print_exception ("Exception caught by serverB:");
return 1;
}
return 0;
}
示例15: self_manage
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize orb
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
// Get reference to Root POA.
CORBA::Object_var obj =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootpoa =
PortableServer::POA::_narrow (obj.in ());
// Activate POA manager
PortableServer::POAManager_var mgr =
rootpoa->the_POAManager ();
mgr->activate ();
PortableServer::POA_var poa;
TAO::Utils::PolicyList_Destroyer PolicyList (3);
PolicyList.length (3);
PolicyList [0] =
rootpoa->create_lifespan_policy (PortableServer::PERSISTENT);
PolicyList [1] =
rootpoa->create_id_assignment_policy (PortableServer::USER_ID);
CORBA::Any CallbackPolicy;
CallbackPolicy <<= BiDirPolicy::BOTH;
const char* sServerPoaName = "TelemetryServer";
PolicyList [2] =
orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
CallbackPolicy);
poa = rootpoa->create_POA (sServerPoaName,
mgr.in(),
PolicyList);
PortableServer::ObjectId_var ServerId =
PortableServer::string_to_ObjectId ("TimeServer");
// Create an object
Time_impl *time_servant = new Time_impl;
PortableServer::ServantBase_var self_manage (time_servant);
poa->activate_object_with_id (ServerId.in (),
time_servant);
// Get a reference after activating the object
CORBA::Object_var object = poa->id_to_reference (ServerId.in ());
TimeModule::Time_var tm = TimeModule::Time::_narrow (object.in ());
// Get reference to initial naming context
CORBA::Object_var name_obj =
orb->resolve_initial_references ("NameService");
CosNaming::NamingContext_var inc =
CosNaming::NamingContext::_narrow (name_obj.in ());
if (CORBA::is_nil (inc.in ()))
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) Error fetching naming context\n"));
}
CosNaming::Name service_name;
service_name.length(1);
service_name[0].id =
CORBA::string_dup ("Time");
inc->rebind (service_name,
tm.in ());
// Run the event loop for fun
ACE_Time_Value tv (3, 0);
// Accept requests
orb->run (&tv);
rootpoa->destroy (0 , 0);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught an exception\n");
return -1;
}
return 0;
//.........这里部分代码省略.........