本文整理汇总了C++中owner_transfer函数的典型用法代码示例。如果您正苦于以下问题:C++ owner_transfer函数的具体用法?C++ owner_transfer怎么用?C++ owner_transfer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了owner_transfer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepare_tests
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
{
register_factories(orb);
CORBA::Object_var objectman =
orb->resolve_initial_references ("ORBPolicyManager");
CORBA::PolicyManager_var policy_manager =
CORBA::PolicyManager::_narrow (objectman.in ());
PortableServer::POA_var my_compress_poa = 0;
CORBA::PolicyList policies(4);
policies.length(4);
try
{
policies[0] = create_compressor_id_level_list_policy (orb);
policies[1] = create_low_value_policy (orb);
policies[2] = create_compression_enabled_policy (orb);
policies[3] = create_min_ratio_policy (orb);
my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
}
catch(const CORBA::PolicyError&)
{
policies.length(0);
my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
}
policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
CORBA::Object_var pcobject =
orb->resolve_initial_references ("PolicyCurrent");
CORBA::PolicyCurrent_var policy_current =
CORBA::PolicyCurrent::_narrow (pcobject.in ());
policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
PortableServer::POAManager_var poa_manager = my_compress_poa->the_POAManager ();
Hello *hello_impl = 0;
ACE_NEW_RETURN (hello_impl,
Hello (orb),
0);
PortableServer::ServantBase_var owner_transfer(hello_impl);
PortableServer::ObjectId_var id =
my_compress_poa->activate_object (hello_impl);
CORBA::Object_var object = my_compress_poa->id_to_reference (id.in ());
Test::Hello_var hello = Test::Hello::_narrow (object.in ());
poa_manager->activate ();
return hello._retn ();
}
示例2: main
int
main (int argc, char *argv[])
{
try {
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "");
CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%N|%l) Panic: nil RootPOA\n"),
1);
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
Hello *hello_impl;
ACE_NEW_RETURN (hello_impl,
Hello (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(hello_impl);
Test::Hello_var hello = hello_impl->_this ();
//
// Register the server object in the IOR table
//
// Turn the object reference into an IOR string
CORBA::String_var ior_string = orb->object_to_string(hello.in());
// Get a reference to the IOR Table and bind the hello object
CORBA::Object_var table_obj = orb->resolve_initial_references("IORTable");
IORTable::Table_var ior_table = IORTable::Table::_narrow(table_obj.in());
ior_table->bind(::Test::Hello::IOR_TABLE_KEY, ior_string.in());
poa_manager->activate ();
ACE_DEBUG ((LM_DEBUG, "(%N|%l) server - event loop beginning\n"));
orb->run ();
ACE_DEBUG ((LM_DEBUG, "(%N|%l) server - event loop finished\n"));
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex) {
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例3: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"),
1);
Hello *hello_impl;
ACE_NEW_RETURN (hello_impl,
Hello,
1);
PortableServer::ServantBase_var owner_transfer(hello_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (hello_impl);
CORBA::Object_var obj = root_poa->id_to_reference (id.in ());
Test::Hello_var hello = Test::Hello::_narrow (obj.in ());
Filter_Localhost filter;
obj = filter.sanitize_profiles (hello.in ());
Test::Hello_var after = Test::Hello::_narrow(obj.in());
if (hello->_stubobj ()->base_profiles ().profile_count () ==
after->_stubobj ()->base_profiles ().profile_count ())
{
ACE_ERROR ((LM_ERROR,
"ERROR: profiles were not correctly filtered\n"));
status++;
}
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
status++;
}
return status;
}
示例4: ACE_ERROR_RETURN
int
Server_Task::svc (void)
{
try
{
CORBA::Object_var poa_object =
this->sorb_->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
Hello *hello_impl = 0;
ACE_NEW_RETURN (hello_impl,
Hello (this->sorb_.in (),
ACE_Thread::self ()),
1);
PortableServer::ServantBase_var owner_transfer(hello_impl);
Test::Hello_var hello =
hello_impl->_this ();
CosNaming::NamingContext_var example_nc;
CosNaming::Name name;
name.length(1);
name[0].id = CORBA::string_dup("Hello");
root_context_->rebind(name, hello.in());
poa_manager->activate ();
// Signal the main thread before we call orb->run ();
this->me_.signal ();
ACE_Time_Value runtime (10);
this->sorb_->run (runtime);
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例5: ACE_NEW_THROW_EX
Test::Simple_ptr
Factory::create_simple_object (void)
{
Simple *simple_impl;
ACE_NEW_THROW_EX (simple_impl,
Simple,
CORBA::NO_MEMORY ());
PortableServer::ServantBase_var owner_transfer(simple_impl);
return simple_impl->_this ();
}
示例6: ACE_TMAIN
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 root_poa = PortableServer::POA::_narrow(poa_object.in());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
ServerImpl *hello_impl = 0;
ACE_NEW_RETURN (hello_impl,
ServerImpl (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(hello_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (hello_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
MasterClient::Server_var vserver = MasterClient::Server::_narrow (object.in ());
CORBA::Object_var tmp = orb->string_to_object(ior);
MasterClient::Master_var vmaster = MasterClient::Master::_narrow(tmp.in ());
poa_manager->activate ();
vmaster->registerServer(vserver.in());
orb->run();
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例7: ACE_READ_GUARD_RETURN
::Stock::StockQuoter_ptr
StockDistributor_i::provide_quoter_info (::Stock::Cookie *ck)
{
ACE_READ_GUARD_RETURN (ACE_RW_Thread_Mutex, guard, lock_, 0);
try
{
CookieMap::const_iterator iter = this->subscribers_list_.find (ck->cookie_id ());
ACE_DEBUG ((LM_DEBUG, "Looking up cookie %s\n", ck->cookie_id ()));
if (iter == this->subscribers_list_.end ())
throw ::Stock::Invalid_Subscription ();
StockQuoter_i *quoter = new StockQuoter_i;
PortableServer::ServantBase_var owner_transfer (quoter);
PortableServer::ObjectId *oid =
this->rt_poa_->activate_object_with_priority (quoter,
iter->second.second);
CORBA::Object_var obj = rt_poa_->id_to_reference (*oid);
::Stock::StockQuoter_var quoter_var = ::Stock::StockQuoter::_narrow (obj.in ());
if (CORBA::is_nil (quoter_var.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: No reference to quoter returned from narrow!\n"),
0);
return quoter_var._retn ();
}
catch (CORBA::Exception &ex)
{
ex._tao_print_exception ("StockDistributor_i::provide_quoter_info");
return ::Stock::StockQuoter::_nil ();
}
}
示例8: run_buffer_size
int
run_buffer_size (CORBA::ORB_ptr orb,
PortableServer::POA_ptr root_poa,
Test::AMI_Buffering_ptr ami_buffering,
Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
TAO::BufferingConstraint buffering_constraint;
buffering_constraint.mode = TAO::BUFFER_MESSAGE_BYTES;
buffering_constraint.message_count = 0;
buffering_constraint.message_bytes = BUFFER_SIZE;
buffering_constraint.timeout = 0;
Test::AMI_Buffering_var flusher;
int test_failed =
configure_policies (orb, buffering_constraint,
ami_buffering, flusher.out ());
if (test_failed != 0)
return test_failed;
Test::Payload payload (PAYLOAD_LENGTH);
payload.length (PAYLOAD_LENGTH);
Reply_Handler *reply_handler_impl;
ACE_NEW_RETURN (reply_handler_impl,
Reply_Handler,
1);
PortableServer::ServantBase_var owner_transfer(reply_handler_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (reply_handler_impl);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Test::AMI_AMI_BufferingHandler_var reply_handler =
Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());
CORBA::ULong bytes_sent = 0;
for (int i = 0; i != iterations; ++i)
{
sync_server (orb, flusher.in ());
CORBA::ULong initial_bytes_received =
ami_buffering_admin->bytes_received_count ();
if (initial_bytes_received != bytes_sent)
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d data lost (%u != %u)\n",
i, initial_bytes_received, bytes_sent));
}
while (1)
{
ami_buffering->sendc_receive_data (reply_handler.in (),
payload);
bytes_sent += PAYLOAD_LENGTH;
CORBA::ULong bytes_received =
ami_buffering_admin->bytes_received_count ();
ACE_Time_Value tv (0, 10 * 1000);
orb->run (tv);
CORBA::ULong payload_delta =
bytes_sent - initial_bytes_received;
if (bytes_received != initial_bytes_received)
{
// The queue has been flushed, check that enough data
// has been sent. The check cannot be precise because
// the ORB counts the GIOP message overhead, in this
// test we assume the overhead to be less than 10%
if (payload_delta < CORBA::ULong (GIOP_OVERHEAD * BUFFER_SIZE))
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d flush before "
"minimum buffer size was reached. "
"Sent = %u, Minimum buffer = %u bytes\n",
i,
payload_delta, BUFFER_SIZE));
}
break;
}
if (payload_delta > 2 * BUFFER_SIZE)
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d no flush past "
"buffer size threshold. "
"Sent = %u, Minimum buffer = %u bytes\n",
i,
payload_delta, BUFFER_SIZE));
break;
}
}
}
//.........这里部分代码省略.........
示例9: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (argc < 2)
{
// Paranoia, we should have an auto_ptr-like gadget for
// this.
orb->destroy ();
ACE_ERROR_RETURN ((LM_ERROR,
"Usage: %s <ior>\n",
argv[0]), 1);
}
CORBA::Object_var object =
orb->string_to_object (argv[1]);
Test::Startup_Callback_var startup_callback =
Test::Startup_Callback::_narrow (object.in ());
if (CORBA::is_nil (startup_callback.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: nil startup callback\n"),
1);
}
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
Process *process_impl = 0;
ACE_NEW_RETURN (process_impl,
Process (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(process_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (process_impl);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Test::Process_var process =
Test::Process::_narrow (object_act.in ());
poa_manager->activate ();
startup_callback->started (process.in ());
ACE_Time_Value tv (50, 0);
orb->run (tv);
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception&)
{
// Do not print error messages, they only make the test output
// confusing.
return 1;
}
return 0;
}
示例10: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
const char *location1 = "MyLocation 1";
const char *location2 = "MyLocation 2";
const char *location3 = "MyLocation 3";
const char *location4 = "MyLocation 4";
const char *location5 = "MyLocation 5";
const char *location6 = "MyLocation 6";
LB_server lb_server (argc, argv);
if (lb_server.start_orb_and_poa () == -1)
return 1;
if (parse_args (argc, argv) == -1)
return 1;
if (server_id == 1 && lb_server.create_object_group () == -1)
return 1;
else if (lb_server.get_object_group () == -1)
return 1;
const char ** location = 0;
switch (server_id)
{
case 1:
location = &location1;
break;
case 2:
location = &location2;
break;
case 3:
location = &location3;
break;
case 4:
location = &location4;
break;
case 5:
location = &location5;
break;
case 6:
location = &location6;
break;
}
Basic *basic_servant;
ACE_NEW_RETURN (basic_servant,
Basic (lb_server.object_group (),
lb_server.load_manager (),
lb_server.orb (),
*location,
server_id),
1);
PortableServer::ServantBase_var owner_transfer(basic_servant);
if (lb_server.register_servant (basic_servant, *location) == -1)
{
(void) lb_server.destroy ();
return 1;
}
if (server_id == 2)
{
Basic *direct_basic_servant = 0;
ACE_NEW_RETURN (direct_basic_servant,
Basic (server_id),
1);
PortableServer::ServantBase_var owner_transfer(direct_basic_servant);
Test::Basic_var direct_basic =
direct_basic_servant->_this ();
CORBA::String_var ior =
lb_server.orb ()->object_to_string (direct_basic.in ());
FILE *output_file =
ACE_OS::fopen (direct_obj_file, "w");
if (output_file == 0)
{
ACE_ERROR ((LM_ERROR,
"Cannot open output file(%s) for writing IOR:", direct_obj_file));
if (lb_server.destroy () == -1)
return 1;
}
ACE_OS::fprintf (output_file, "%s", ior.in());
ACE_OS::fclose (output_file);
}
// ACE_OS::sleep (1000);
lb_server.orb ()->run ();
//.........这里部分代码省略.........
示例11: run_timeout_reactive
int
run_timeout_reactive (CORBA::ORB_ptr orb,
PortableServer::POA_ptr root_poa,
Test::AMI_Buffering_ptr ami_buffering,
Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
TAO::BufferingConstraint buffering_constraint;
buffering_constraint.mode = TAO::BUFFER_TIMEOUT;
buffering_constraint.message_count = 0;
buffering_constraint.message_bytes = 0;
buffering_constraint.timeout = TIMEOUT_MILLISECONDS * 10000;
Test::AMI_Buffering_var flusher;
int test_failed =
configure_policies (orb, buffering_constraint,
ami_buffering, flusher.out ());
if (test_failed != 0)
return test_failed;
Test::Payload payload (PAYLOAD_LENGTH);
payload.length (PAYLOAD_LENGTH);
for (int j = 0; j != PAYLOAD_LENGTH; ++j)
payload[j] = CORBA::Octet(j % 256);
Reply_Handler *reply_handler_impl = 0;
ACE_NEW_RETURN (reply_handler_impl,
Reply_Handler,
1);
PortableServer::ServantBase_var owner_transfer(reply_handler_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (reply_handler_impl);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Test::AMI_AMI_BufferingHandler_var reply_handler =
Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());
CORBA::ULong send_count = 0;
int retry_attempt = 0;
for (int i = 0; i != iterations; ++i)
{
sync_server (orb, flusher.in ());
CORBA::ULong initial_receive_count =
ami_buffering_admin->request_count ();
if (initial_receive_count != send_count)
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d message lost (%u != %u)\n",
i, initial_receive_count, send_count));
}
ACE_Time_Value start = ACE_OS::gettimeofday ();
for (int j = 0; j != 20; ++j)
{
ami_buffering->sendc_receive_data (reply_handler.in (),
payload);
send_count++;
}
while (1)
{
CORBA::ULong receive_count =
ami_buffering_admin->request_count ();
ACE_Time_Value tv (0, 10 * 1000);
orb->run (tv);
ACE_Time_Value elapsed = ACE_OS::gettimeofday () - start;
if (receive_count != initial_receive_count)
{
if (elapsed.msec () < TIMEOUT_MILLISECONDS)
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d flush before "
"timeout expired. "
"Elapsed = %d, Timeout = %d msecs\n",
i,
elapsed.msec (), TIMEOUT_MILLISECONDS));
}
// terminate the while loop.
break;
}
if (elapsed.msec () > TIMEOUT_TOLERANCE)
{
if (retry_attempt++ < 10) {
ACE_DEBUG ((LM_DEBUG, "DEBUG: Retry attempt %d beyond TIMEOUT_TOLERANCE.\n",
retry_attempt));
continue;
}
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d no flush past "
"timeout threshold. "
"Elapsed = %d, Timeout = %d msecs\n",
//.........这里部分代码省略.........
示例12: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
Process_Factory *process_factory_impl = 0;
ACE_NEW_RETURN (process_factory_impl,
Process_Factory (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(process_factory_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (process_factory_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Test::Process_Factory_var process =
Test::Process_Factory::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (process.in ());
// If the ior_output_file exists, output the ior to it
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);
poa_manager->activate ();
Server_Task server_task (orb.in (),
ACE_Thread_Manager::instance ());
if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 8, 1) == -1)
{
ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
}
ACE_Thread_Manager::instance ()->wait ();
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例13: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int priority =
(ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
+ ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO,
priority);
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
priority,
ACE_SCOPE_PROCESS)) != 0)
{
if (ACE_OS::last_error () == EPERM)
{
ACE_DEBUG ((LM_DEBUG,
"server (%P|%t): user is not superuser, "
"test runs in time-shared class\n"));
}
else
ACE_ERROR ((LM_ERROR,
"server (%P|%t): sched_params failed\n"));
}
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
Factory *factory_impl;
ACE_NEW_RETURN (factory_impl,
Factory (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(factory_impl);
Test::Factory_var factory =
factory_impl->_this ();
CORBA::String_var ior =
orb->object_to_string (factory.in ());
// If the ior_output_file exists, output the ior to it
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);
poa_manager->activate ();
orb->run ();
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例14: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
#if TAO_HAS_INTERCEPTORS == 1
Server_ORBInitializer *temp_initializer = 0;
ACE_NEW_RETURN (temp_initializer,
Server_ORBInitializer,
-1); // No exceptions yet!
PortableInterceptor::ORBInitializer_var orb_initializer =
temp_initializer;
PortableInterceptor::register_orb_initializer (orb_initializer.in ());
#endif /* TAO_HAS_INTERCEPTORS == 1 */
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv, "Server ORB");
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (::parse_args (argc, argv) != 0)
return -1;
test_i *test_impl;
ACE_NEW_RETURN (test_impl, test_i (number, orb.in ()), 1);
PortableServer::ServantBase_var owner_transfer (test_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (test_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
RedirectionTest::test_var test =
RedirectionTest::test::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (test.in ());
FILE *output_file= ACE_OS::fopen (ior_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file <%s> for writing "
"IOR: %C\n",
ior_file, ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
if (server_number == 2)
ACE_OS::exit (1);
poa_manager->activate ();
// Run the ORB event loop.
orb->run ();
root_poa->destroy (1, 1);
orb->destroy ();
ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return -1;
}
return 0;
}
示例15: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv, "Server ORB");
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the POA.\n"),
1);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (::parse_args (argc, argv) != 0)
return -1;
test_i *test_impl = 0;
ACE_NEW_RETURN (test_impl, test_i (1, orb.in ()), 1);
PortableServer::ServantBase_var owner_transfer (test_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (test_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
RedirectionTest::test_var test =
RedirectionTest::test::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (test.in ());
FILE *output_file= ACE_OS::fopen (ior_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file <%s> for writing "
"IOR: %s",
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
root_poa->destroy (1, 1 );
orb->destroy ();
ACE_DEBUG ((LM_DEBUG, "Server event loop finished.\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return -1;
}
return 0;
}