本文整理汇总了C++中portableserver::POA_var::create_implicit_activation_policy方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_var::create_implicit_activation_policy方法的具体用法?C++ POA_var::create_implicit_activation_policy怎么用?C++ POA_var::create_implicit_activation_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portableserver::POA_var
的用法示例。
在下文中一共展示了POA_var::create_implicit_activation_policy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
CORBA::ORB_var orb;
try
{
orb = CORBA::ORB_init (argc, argv);
CORBA::Object_var root_poa_o =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow (root_poa_o.in ());
if (CORBA::is_nil (rootPOA.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"), 1);
}
PortableServer::POAManager_var poaMgr = rootPOA->the_POAManager ();
poaMgr->activate ();
CORBA::PolicyList policies;
policies.length (3);
policies[0] = rootPOA->create_id_assignment_policy (
PortableServer::SYSTEM_ID);
policies[1] = rootPOA->create_implicit_activation_policy (
PortableServer::NO_IMPLICIT_ACTIVATION);
policies[2] = rootPOA->create_lifespan_policy (
PortableServer::TRANSIENT);
PortableServer::POA_var fooPoa = rootPOA->create_POA (
"FOO_POA", poaMgr.in (), policies );
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
policies[i]->destroy ();
}
Foo_i servant;
PortableServer::ObjectId_var oid = fooPoa->activate_object( &servant );
CORBA::Object_var obj = fooPoa->id_to_reference (oid.in ());
foo_var client = foo::_narrow (obj.in());
client->check();
if (vc_check(client.in()))
{
orb->destroy();
return 1;
}
fooPoa->deactivate_object (oid.in () ); //servant is gone
if (vc_check(client.in(), false)) //exception expected
{
orb->destroy();
return 2;
}
}
catch(...)
{
return 3;
}
return 0;
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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;
//.........这里部分代码省略.........