本文整理汇总了C++中portableserver::POAManager_var类的典型用法代码示例。如果您正苦于以下问题:C++ POAManager_var类的具体用法?C++ POAManager_var怎么用?C++ POAManager_var使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了POAManager_var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
//Get reference to the RootPOA.
CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );
// Activate the POAManager.
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
if (parse_args (argc, argv) != 0)
return 1;
// Create a servant.
PortableServer::Servant_var<Messenger_i> messenger_servant = new Messenger_i;
// Register the servant with the RootPOA, obtain its object
// reference, stringify it, and write it to a file.
PortableServer::ObjectId_var oid =
poa->activate_object( messenger_servant.in() );
CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
std::ofstream iorFile(ACE_TEXT_ALWAYS_CHAR (ior_output_file));
iorFile << str.in() << std::endl;
iorFile.close();
std::cout << "IOR written to file " <<
ACE_TEXT_ALWAYS_CHAR (ior_output_file) << std::endl;
// 3. Create and activate threads for the thread pool.
ORB_Task task (orb.in());
int retval = task.activate (THR_NEW_LWP | THR_JOINABLE, nthreads);
if (retval != 0) {
std::cerr << "Failed to activate " << nthreads << " threads." << std::endl;
return 1;
}
// 4. Wait for threads to finish.
task.wait();
// Clean up.
orb->destroy();
}
catch(const CORBA::Exception& ex) {
std::cerr << "CORBA exception: " << ex << std::endl;
return 1;
}
return 0;
}
示例2: tv
int
ACE_TMAIN (int argc,
ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var obj
= orb->resolve_initial_references ("RootPOA");
// Get the POA_var object from Object_var
PortableServer::POA_var root_poa
= PortableServer::POA::_narrow (obj.in ());
PortableServer::POAManager_var mgr
= root_poa->the_POAManager ();
mgr->activate ();
// Initialize the AV Stream components.
TAO_AV_CORE::instance ()->init (orb.in (),
root_poa.in ());
// Initialize the Sender.
int result = 0;
result = SENDER::instance ()->init (argc,
argv);
if (result < 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Sender::init failed\n"),
-1);
SENDER::instance ()->pace_data ();
ACE_Time_Value tv (10);
orb->run (tv);
// Hack for now....
ACE_OS::sleep (1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Sender Failed\n");
return -1;
}
SENDER::close (); // Explicitly finalize the Unmanaged_Singleton.
return 0;
}
示例3: while
int
ACE_TMAIN (int argc,
ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB first.
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var obj
= orb->resolve_initial_references ("RootPOA");
// Get the POA_var object from Object_var.
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (obj.in ());
PortableServer::POAManager_var mgr
= root_poa->the_POAManager ();
mgr->activate ();
// Initialize the AVStreams components.
TAO_AV_CORE::instance ()->init (orb.in (),
root_poa.in ());
// Initialize the Distributer
int result =
DISTRIBUTER::instance ()->init (argc,
argv);
if (result != 0)
return result;
while (!DISTRIBUTER::instance ()->done ())
{
orb->perform_work ();
}
// Hack for now....
ACE_OS::sleep (1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("main");
return -1;
}
DISTRIBUTER::close (); // Explicitly finalize the Unmanaged_Singleton.
return 0;
}
示例4: main
void main(int argc,char **argv){
try {
//Crear ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
//Crear POA
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
PortableServer::POAManager_var manager = poa->the_POAManager();
//Crear servidor
Servidor *service = NULL;
service = new Servidor();
service->orb = &orb;
//Subir servidor a servicio de nombres
try {
CORBA::Object_var ns_obj = orb->resolve_initial_references("NameService");
if (!CORBA::is_nil(ns_obj)) {
CosNaming::NamingContext_ptr nc = CosNaming::NamingContext::_narrow(ns_obj);
service->nc = &nc;
CosNaming::Name name;
name.length(1);
name[0].id = CORBA::string_dup("Server");
name[0].kind = CORBA::string_dup("");
nc->bind(name, service->_this());
cout << "Server is running ..." << endl;
}
}
catch (CosNaming::NamingContext::NotFound &) {
cerr << "not found" << endl;
}catch (CosNaming::NamingContext::InvalidName &) {
cerr << "invalid name" << endl;
}catch (CosNaming::NamingContext::CannotProceed &) {
cerr << "cannot proceed" << endl;
}
manager->activate();
orb->run();
delete service;
orb->destroy();
}
catch (CORBA::UNKNOWN) {
cerr << "unknown exception" << endl;
}catch (CORBA::SystemException &) {
cerr << "system exception" << endl;
}
getchar();
//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
示例5: iorFile
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try {
PortableInterceptor::ORBInitializer_var orb_initializer =
new ServerInitializer;
PortableInterceptor::register_orb_initializer (orb_initializer.in ());
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
if (parse_args (argc, argv) != 0)
return 1;
//Get reference to Root POA
CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );
// Activate POA Manager
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
// Create an object
PortableServer::Servant_var<Messenger_i> messenger_servant = new Messenger_i;
// Register the servant with the RootPOA, obtain its object
// reference, stringify it, and write it to a file.
PortableServer::ObjectId_var oid =
poa->activate_object( messenger_servant.in() );
CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
std::ofstream iorFile( ACE_TEXT_ALWAYS_CHAR(ior_output_file) );
iorFile << str.in() << std::endl;
iorFile.close();
std::cout << "IOR written to file " << ACE_TEXT_ALWAYS_CHAR(ior_output_file) << std::endl;
// Accept requests
orb->run();
orb->destroy();
}
catch(const CORBA::Exception& ex)
{
std::cerr << "Exception in MessengerServer: " << ex << std::endl;
return 1;
}
return 0;
}
示例6: main
int main (int argc, char *argv[])
{
try
{
// Initialize orb
printf("orb init\n");
CORBA::ORB_var orb = CORBA::ORB_init (argc, (char**)argv);
// Get reference to Root POA.
printf("resolve_initial_references\n");
CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ());
// Activate POA manager
PortableServer::POAManager_var mgr = poa->the_POAManager ();
mgr->activate();
// Create an object
HelloWorld_impl HelloWorld_servant;
// Write its stringified reference to stdout
perf::jitter::HelloWorld_var myInterface = HelloWorld_servant._this ();
CORBA::String_var str = orb->object_to_string (myInterface.in ());
FILE* outFile = fopen("ior.txt", "w");
if (outFile == NULL)
{
printf("Error: Cannot open IOR file for writing\n");
}
else
{
if (fprintf(outFile, "%s\n", str.in ()) <= 0)
{
printf("Error: Could not write IOR string to file\n");
}
fclose(outFile);
printf("Listening for CORBA requests...\n");
orb->run();
}
}
catch (const CORBA::Exception &)
{
printf("Uncaught CORBA exception");
}
return 0;
}
示例7: main
int main(int argc, char ** argv)
{
try {
// init ORB
CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
// init POA
CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
PortableServer::POAManager_var manager = poa->the_POAManager();
// create service
Math_operation * service = new Math_operation;
// register within the naming service
try {
CORBA::Object_var ns_obj = orb->resolve_initial_references("NameService");
if (!CORBA::is_nil(ns_obj)) {
CosNaming::NamingContext_ptr nc = CosNaming::NamingContext::_narrow(ns_obj);
CosNaming::Name name;
name.length(1);
name[0].id = CORBA::string_dup("TestServer");
name[0].kind = CORBA::string_dup("");
nc->rebind(name, service->_this());
cout << argv[0] << ": server 'TestServer' bound" << endl;
}
} catch (CosNaming::NamingContext::NotFound &) {
cerr << "not found" << endl;
} catch (CosNaming::NamingContext::InvalidName &) {
cerr << "invalid name" << endl;
} catch (CosNaming::NamingContext::CannotProceed &) {
cerr << "cannot proceed" << endl;
}
// run
manager->activate();
orb->run();
// clean up
delete service;
// quit
orb->destroy();
} catch (CORBA::UNKNOWN) {
cerr << "unknown exception" << endl;
} catch (CORBA::SystemException &) {
cerr << "system exception" << endl;
}
}
示例8: run
void CorbaService::run()
{
vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL) << "Server is running!\n"
<< vprDEBUG_FLUSH;
// PortableServer::POAManager_var pman = mChildPOA->the_POAManager();
PortableServer::POAManager_var pman = mRootPOA->the_POAManager();
pman->activate();
mORB->run();
// mORB->destroy();
vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL) << "Server has shut down\n"
<< vprDEBUG_FLUSH;
}
示例9: 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 );
}
示例10: initializeCorbaUtil
void cnoid::initializeCorbaUtil(CORBA::ORB_ptr orb_, bool activatePOAManager)
{
if(!orb){
orb = orb_;
}
namingContextHelper.setLocation("localhost", 2809);
if(activatePOAManager){
CORBA::Object_var poaObj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj);
PortableServer::POAManager_var manager = poa->the_POAManager();
manager->activate();
}
}
示例11: messenger_servant
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
if (parse_args (argc, argv) != 0)
return 1;
//Get reference to Root POA
CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );
// Activate POA Manager
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
// Create an object
Messenger_i messenger_servant (orb.in ());
// Register the servant with the RootPOA, obtain its object
// reference, stringify it, and write it to a file.
PortableServer::ObjectId_var oid =
poa->activate_object( &messenger_servant );
CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
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\n",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", str.in ());
ACE_OS::fclose (output_file);
// Accept requests
orb->run();
orb->destroy();
}
catch( const CORBA::Exception & ex)
{
ex._tao_print_exception ("Caught CORBA exception: ");
return 1;
}
return 0;
}
示例12: 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;
}
示例13:
void
Hello::method (CORBA::Short count)
{
if (++this->count_ > 10)
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) supplied count = %d\n", count));
PortableServer::POA_var poa = this->_default_POA();
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->hold_requests(false);
// Pass duplicated ptr to a thread and let the thread to free the reference.
CORBA::ORB_ptr orb = CORBA::ORB::_duplicate (this->orb_.in ());
ACE_Thread_Manager::instance()->spawn_n (1,
ACE_THR_FUNC (killer),
static_cast<void*> (orb));
}
}
示例14: t
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int result = 0;
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
ACE_DEBUG ((LM_DEBUG,"Client using ior source %s\n", ior));
CORBA::Object_var server = orb->string_to_object (ior);
CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var root =
PortableServer::POA::_narrow (obj.in());
PortableServer::POAManager_var pm = root->the_POAManager();
pm->activate();
bool got_reply = false;
Messaging::ReplyHandler_var callback = new DII_ReplyHandler(got_reply);
do_primary_test (server,callback);
for (int i = 0; i < 100 && !got_reply; i++)
{
ACE_Time_Value t(0,10000);
orb->perform_work(t);
}
if (do_shutdown)
result = do_shutdown_test (server);
ACE_DEBUG ((LM_DEBUG,"Shutting down and destrying ORB.\n"));
orb->destroy();
ACE_DEBUG ((LM_DEBUG,"ORB destroyed\n"));
}
catch (const ::CORBA::Exception &ex)
{
ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :");
++result;
}
return result;
}
示例15:
void omnijni::ORB::Init (JNIEnv* env)
{
// Initialize the ORB with no arguments.
int argc = 0;
char** argv = 0;
orb = CORBA::ORB_init(argc, argv);
// Automatically activate the root POA manager.
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
PortableServer::POAManager_var manager = root_poa->the_POAManager();
manager->activate();
// Initialize JNI references
cls_ = omnijni::loadClass(env, "omnijni.ORB");
object_to_string_ = env->GetStaticMethodID(cls_, "object_to_string", "(Lorg/omg/CORBA/Object;)Ljava/lang/String;");
}