本文整理汇总了C++中corba::ORB_var::in方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_var::in方法的具体用法?C++ ORB_var::in怎么用?C++ ORB_var::in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::ORB_var
的用法示例。
在下文中一共展示了ORB_var::in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: owner_transfer
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;
Memory_Growth *memory;
ACE_NEW_RETURN (memory,
Memory_Growth (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(memory);
Test::Memory_Growth_var mem =
memory->_this ();
CORBA::String_var ior =
orb->object_to_string (mem.in ());
// 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);
poa_manager->activate ();
// Run the evnt loop for ever
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;
}
示例2: sleep_interval
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
// Initialize options based on command-line arguments.
int parse_args_result = parse_args (argc, argv);
if (parse_args_result != 0)
return parse_args_result;
CORBA::Object_var base =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (base.in ());
// Get an object reference from the argument string.
base = orb->string_to_object (IOR);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
// Try to narrow the object reference to a <test> reference.
test_var test_object = test::_narrow (base.in ());
Reply_Handler reply_handler_servant;
AMI_testHandler_var reply_handler_object = reply_handler_servant._this ();
if (setup_buffering)
{
setup_buffering_constraints (orb.in ());
}
for (CORBA::ULong i = 1; i <= iterations; ++i)
{
ACE_DEBUG ((LM_DEBUG,
"client: Iteration %d @ %T\n",
i));
if (invoke_ami_style)
{
// Invoke the AMI method.
test_object->sendc_method (reply_handler_object.in (),
i);
}
else
{
CORBA::ULong reply_number = 0;
// Invoke the regular method.
test_object->method (i,
reply_number);
ACE_DEBUG ((LM_DEBUG,
"client: Regular Reply %d @ %T\n",
reply_number));
}
// Interval between successive calls.
ACE_Time_Value sleep_interval (0,
interval * 1000);
orb->run (sleep_interval);
}
// Loop until all replies have been received.
while (!received_all_replies)
{
orb->perform_work ();
}
// Shutdown server.
if (shutdown_server)
{
test_object->shutdown ();
}
root_poa->destroy (1,
1);
// Destroy the ORB. On some platforms, e.g., Win32, the socket
// library is closed at the end of main(). This means that any
// socket calls made after main() fail. Hence if we wait for
// static destructors to flush the queues, it will be too late.
// Therefore, we use explicit destruction here and flush the
// queues before main() ends.
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return -1;
}
//.........这里部分代码省略.........
示例3: writing
// Initialize the server.
template <class Servant> int
Server<Servant>::init (const char *servant_name,
int argc,
ACE_TCHAR *argv[])
{
// Call the init of <TAO_ORB_Manager> to initialize the ORB and
// create a child POA under the root POA.
if (this->orb_manager_.init_child_poa (argc,
argv,
"child_poa") == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("init_child_poa")),
-1);
this->argc_ = argc;
this->argv_ = argv;
int retval = this->parse_args ();
if (retval != 0)
return retval;
CORBA::ORB_var orb = this->orb_manager_.orb ();
// Stash our ORB pointer for later reference.
this->servant_->orb (orb.in ());
// Activate the servant in its own child POA.
// Make sure that you check for failures here via the try?!
try
{
CORBA::String_var str =
this->orb_manager_.activate_under_child_poa (servant_name,
this->servant_.in ());
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("The IOR is: <%C>\n"),
str.in ()));
if (this->ins_ && this->test_for_ins (str.in ()) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("test_for_ins (): failed\n")),
-1);
if (this->ior_output_file_)
{
FILE *fh = ACE_OS::fopen (this->ior_output_file_, "w");
if (fh == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Unable to open %s for writing (%p)\n"),
this->ior_output_file_,
ACE_TEXT ("fopen")),
-1);
ACE_OS::fprintf (fh, "%s", str.in ());
ACE_OS::fclose (fh);
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("\tException in activation of POA");
return -1;
}
return 0;
}
示例4: owner_transfer
int
Server_Worker::test_main (int argc, ACE_TCHAR *argv[])
{
try
{
// Making sure there are no stale ior files to confuse a client
ACE_OS::unlink (ior_file_.c_str ());
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,
ACE_TEXT ("(%P|%t) Panic: nil RootPOA\n")),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
Hello *hello_impl;
ACE_NEW_RETURN (hello_impl,
Hello (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer (hello_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (hello_impl);
CORBA::Object_var hello_obj =
root_poa->id_to_reference (id.in ());
Test::Hello_var hello =
Test::Hello::_narrow (hello_obj.in ());
CORBA::String_var ior =
orb->object_to_string (hello.in ());
poa_manager->activate ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Server activated POA manager\n")));
// Output the IOR to the <ior_output_file>
FILE *output_file= ACE_OS::fopen (ior_file_.c_str (), "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) Cannot open output file %s for writing IOR: %C"),
ior_file_.c_str (),
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Server entering the event loop\n")));
orb->run ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Server exiting the event loop\n")));
root_poa->destroy (1, 1);
// During normal test execution the ORB would have been destroyed
// by a request from the client.
// orb->shutdown (0);
orb->destroy ();
}
catch (const ::CORBA::Exception &e)
{
e._tao_print_exception("Server_Worker::test_main");
return 1;
}
return 0;
}
示例5: 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 AVStreams 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);
// Make sure we have a valid <output_file>
output_file = ACE_OS::fopen (output_file_name,
"w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_DEBUG,
"Cannot open output file %s\n",
output_file_name),
-1);
else
ACE_DEBUG ((LM_DEBUG,
"File Opened Successfully\n"));
// Start sending data.
result = SENDER::instance ()->pace_data ();
ACE_Time_Value tv(3,0);
orb->run (tv);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Sender Failed\n");
return -1;
}
SENDER::close (); // Explicitly finalize the Unmanaged_Singleton.
return 0;
}
示例6: client
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int retval = 0;
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var tmp =
orb->string_to_object(ior);
Test::Hello_var hello =
Test::Hello::_narrow(tmp.in ());
if (CORBA::is_nil (hello.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
"Nil Test::Hello reference <%s>\n",
ior),
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 ();
poa_manager->activate ();
// Let the client perform the test in a separate thread
Client_Task client (hello.in (),
orb.in (),
ACE_Thread_Manager::instance ());
if (client.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR - Cannot activate client threads\n"),
1);
}
ACE_Time_Value thread_deadline = ACE_OS::gettimeofday();
thread_deadline += 30;
if(client.thr_mgr ()->wait (&thread_deadline) == -1)
{
ACE_ERROR((LM_ERROR,
"ERROR - Timeout waiting for client threads\n"));
retval = 1;
}
root_poa->destroy (1, // ethernalize objects
0); // wait for completion
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return retval;
}
示例7: 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;
}
// Create a bidirectional POA
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
// Policies for the childPOA to be created.
CORBA::PolicyList policies(1);
policies.length(1);
CORBA::Any pol;
pol <<= BiDirPolicy::BOTH;
policies[0] =
orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, pol);
// 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 poa = root_poa->create_POA("bidirPOA", poa_manager.in(), policies);
// Creation of bidirPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0; i < policies.length (); ++i) {
policies[i]->destroy ();
}
poa_manager->activate ();
PortableServer::Servant_var<Simple_i> svt = new Simple_i(orb.in(), callback_count);
// Register and activate Simple servant
PortableServer::ObjectId_var id = poa->activate_object(svt.in());
obj = poa->id_to_reference(id.in());
Simple_var server = Simple::_narrow(obj.in());
CORBA::String_var ior = orb->object_to_string(server.in());
if (ior_output_file != ACE_TEXT("")) {
std::ofstream outfile(ACE_TEXT_ALWAYS_CHAR(ior_output_file.c_str()));
outfile << ior.in();
}
std::cout << "Activated as " << ior.in() << std::endl;
// Our own special orb->run() that knows how to callback clients
while (true) {
// returns 1 as soon as it has successfully called back.
if (svt->call_client()) {
break;
}
// We don't want to check for work pending, because we really want
// to simulate a normal orb->run() while adding the ability to call
// our routine which calls back to the client.
orb->perform_work();
}
std::cout << "Event loop finished." << std::endl;
CORBA::Boolean etherealize = true, wait = true;
poa->destroy(etherealize, wait);
orb->destroy();
return 0;
}
catch(const CORBA::Exception& ex) {
std::cerr << "Caught CORBA::Exception: " << std::endl << ex << std::endl;
}
return 1;
}
示例8: tv
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Create the ORB initializer.
Server_ORBInitializer *temp_initializer = 0;
ACE_NEW_RETURN (temp_initializer,
Server_ORBInitializer,
-1);
PortableInterceptor::ORBInitializer_var initializer =
temp_initializer;
PortableInterceptor::register_orb_initializer (initializer.in ());
// Now initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv,
"Remote_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 ();
poa_manager->activate ();
if (parse_args (argc, argv) != 0)
{
return 1;
}
// Create the interceptor.
Echo_Server_Request_Interceptor * server_interceptor =
temp_initializer->server_interceptor();
if (server_interceptor == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Could not obtain reference to "
"server request interceptor.\n"),
-1);
}
// Pull in the ior from the remote server to use as the forward location.
CORBA::Object_var forward_location = orb->string_to_object (ior_input_file);
if (CORBA::is_nil (forward_location.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil\n",
ior_input_file),
1);
}
server_interceptor->forward_reference (forward_location.in ());
Bug1495_i server_impl (orb.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (&server_impl);
CORBA::Object_var test_obj =
root_poa->id_to_reference (id.in ());
Bug1495_Regression::Bug1495_var server =
Bug1495_Regression::Bug1495::_narrow (test_obj.in ());
CORBA::String_var ior =
orb->object_to_string (server.in ());
// Output the server IOR to a file
if (ior_output_file != 0)
{
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 the "
"server IOR: %s", ior_output_file),
1);
}
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
ACE_Time_Value tv (15, 0);
//.........这里部分代码省略.........
示例9: owner_transfer
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
PortableInterceptor::ORBInitializer_ptr temp_initializer = 0;
ACE_NEW_RETURN (temp_initializer,
Server_ORBInitializer (),
-1); // No exceptions yet!
PortableInterceptor::ORBInitializer_var initializer =
temp_initializer;
PortableInterceptor::register_orb_initializer (initializer.in ());
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 ());
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 (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 ());
Test::Hello_var hello = Test::Hello::_narrow (object.in ());
CORBA::String_var ior = orb->object_to_string (hello.in ());
// Output the IOR to the <output_filename>
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", 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;
}
示例10: policies
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 ();
// Make all oneways "reliable."
{
CORBA::Object_var manager_object =
orb->resolve_initial_references("ORBPolicyManager");
CORBA::PolicyManager_var policy_manager =
CORBA::PolicyManager::_narrow(manager_object.in());
if (CORBA::is_nil (policy_manager.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil PolicyManager\n"),
1);
CORBA::Any policy_value;
policy_value <<= Messaging::SYNC_WITH_SERVER;
CORBA::PolicyList policies(1); policies.length(1);
policies[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
policy_value);
policy_manager->set_policy_overrides (policies,
CORBA::ADD_OVERRIDE);
policies[0]->destroy ();
}
if (parse_args (argc, argv) != 0)
return 1;
Service *service_impl;
ACE_NEW_RETURN (service_impl,
Service(orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(service_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (service_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Test::Service_var service =
Test::Service::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (service.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, "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;
}
示例11: safe
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");
if (CORBA::is_nil (poa_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("SERVER: 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;
// Servant
test_i *servant = 0;
ACE_NEW_RETURN (servant,
test_i (0, orb.in ()),
-1);
PortableServer::ServantBase_var safe (servant);
PortableServer::ObjectId_var oid =
root_poa->activate_object (servant);
CORBA::Object_var obj =
root_poa->servant_to_reference (servant);
CORBA::String_var ior =
orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("SERVER: test_i servant: <%C>\n"),
ior.in ()));
poa_manager->activate ();
// IOR
FILE *output_file= ACE_OS::fopen (ior_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("SERVER: Cannot open output file <%s> ")
ACE_TEXT ("for writting IOR: %C"),
ior_file,
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
// Run the ORB event loop.
orb->run ();
root_poa->destroy (1, 1);
orb->destroy ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SERVER: Event loop finished.\n")));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return -1;
}
return 0;
}
示例12: owner_transfer
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);
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;
Roundtrip *roundtrip_impl;
ACE_NEW_RETURN (roundtrip_impl,
Roundtrip (orb.in ()),
1);
PortableServer::ServantBase_var owner_transfer(roundtrip_impl);
Test::Roundtrip_var roundtrip =
roundtrip_impl->_this ();
CORBA::String_var ior =
orb->object_to_string (roundtrip.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 ());
if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
nthreads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot activate server threads\n"),
1);
server_task.thr_mgr ()->wait ();
ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
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: EventSequenceConsumer_i
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("NameService");
CosNaming::NamingContextExt_var naming_context =
CosNaming::NamingContextExt::_narrow(obj.in());
obj = naming_context->resolve_str("MyEventChannel");
CosNotifyChannelAdmin::EventChannel_var ec =
CosNotifyChannelAdmin::EventChannel::_narrow(obj.in());
CosNotifyChannelAdmin::AdminID adminid;
CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
CosNotifyChannelAdmin::AND_OP;
CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
ec->new_for_consumers(ifgop,
adminid);
obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in());
PortableServer::Servant_var<EventSequenceConsumer_i> servant =
new EventSequenceConsumer_i(orb.in());
PortableServer::ObjectId_var objectId = poa->activate_object(servant.in());
obj = poa->id_to_reference (objectId.in());
CosNotifyComm::SequencePushConsumer_var consumer =
CosNotifyComm::SequencePushConsumer::_narrow(obj.in());
CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;
CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
consumer_admin->obtain_notification_push_supplier(
CosNotifyChannelAdmin::SEQUENCE_EVENT,
consumeradmin_proxy_id);
CosNotifyChannelAdmin::SequenceProxyPushSupplier_var supplier_proxy =
CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow(proxy_supplier.in());
supplier_proxy->connect_sequence_push_consumer(consumer.in());
CosNotification::EventTypeSeq added (1);
CosNotification::EventTypeSeq removed (1);
added.length (1);
removed.length (1);
added[0].domain_name = CORBA::string_dup ("OCI_TAO");
added[0].type_name = CORBA::string_dup ("examples");
removed[0].domain_name = CORBA::string_dup ("*");
removed[0].type_name = CORBA::string_dup ("*");
supplier_proxy->subscription_change(added, removed);
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
orb->run();
orb->destroy();
return 0;
}
catch(const CORBA::Exception& ex)
{
std::cerr << "Caught exception: " << ex << std::endl;
}
return 1;
}
示例14: main
int main(int argc, char** argv)
{
ProgOptions po;
initProgOptions(po,argc,argv);
const char* name;
const char* passwd;
const char* alias;
name=po.argument("name");
passwd=po.argument("passwd");
alias=po.argument("alias");
if (alias==NULL) alias = "";
if (name==NULL || passwd==NULL) {
cerr << "please, use name and password" << endl;
return 1;
}
try {
#ifdef CORBA_ORB_INIT_HAVE_3_ARGS
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, CORBA_ORB_INIT_THIRD_ARG);
#else
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
#endif
initUAKGQueryService(orb.in());
CORBA::Object_var obj;
try {
obj = orb->resolve_initial_references("UAKGQueryService");
}catch(const CORBA::ORB::InvalidName&){
cerr << argv[0] << ": can't resolve UAKGQueryService" << endl;
return 1;
}
if(CORBA::is_nil(obj)) {
cerr << argv[0] << ": UAKGQueryService is a nil object reference" << endl;
return 1;
}
DBConnectionManager_var dbManager = DBConnectionManager::_narrow(obj);
if (CORBA::is_nil(dbManager)) {
cerr << argv[0] << ": can't narrow dbManager to correct type" << endl;
return 1;
}
QueryManager_var queryManager;
try {
queryManager =
dbManager->createQueryManager(name,passwd,alias,"Oracle8","");
}catch(QueryManagerNotFound){
cerr << argv[0] <<": can't find query manager." << endl;
return 1;
}
cout << "\t BEGIN TESTS." << endl;
run_tests(queryManager);
cout << "\t END TESTS." << endl;
//time to disconnect.
//
cout << "disconnecting." << endl;
queryManager->destroy();
orb -> destroy();
}catch(const CORBA::SystemException& ex){
printSystemException(cerr,ex);
return 1;
}
return 0;
}
示例15: svc
int TestTask::svc()
{
try {
// 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 ();
// Find the Naming Service
obj = orb_->string_to_object (
"corbaloc:iiop:[email protected]:9932/NameService");
CosNaming::NamingContext_var rootB =
CosNaming::NamingContext::_narrow (obj.in ());
if (CORBA::is_nil (rootB.in ())) {
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Error, Nil Naming Context reference\n")));
return 1;
}
// Bind the example Naming Context, if necessary
CosNaming::NamingContext_var example_nc;
CosNaming::Name name;
name.length(1);
name[0].id = CORBA::string_dup( "example");
try
{
obj = rootB->resolve (name);
example_nc =
CosNaming::NamingContext::_narrow (obj.in ());
}
catch (const CosNaming::NamingContext::NotFound&)
{
example_nc = rootB->bind_new_context (name);
}
// Bind the Test object
name.length (2);
name[1].id = CORBA::string_dup ("Hello");
// Create an object
Hello servant (orb_.in ());
PortableServer::ObjectId_var oid = poa->activate_object (&servant);
obj = poa->id_to_reference (oid.in ());
rootB->rebind (name, obj.in ());
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("Hello object bound in Naming Service B\n")));
name.length (1);
name[0].id = CORBA::string_dup ("nsB");
obj = orb_->string_to_object (
"corbaloc:iiop:[email protected]:9931/NameService");
CosNaming::NamingContext_var rootA =
CosNaming::NamingContext::_narrow (obj.in ());
rootA->bind_context (name, rootB.in ());
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("Root context of NS B bound in Naming Service A ")
ACE_TEXT ("under name 'nsB'\n")));
CORBA::String_var ior =
orb_->object_to_string (obj.in ());
// 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,
ACE_TEXT ("Cannot open output file %s for writing ")
ACE_TEXT ("IOR: %C\n"),
ior_output_file,
ior.in ()),
1);
ACE_OS::fprintf (output_file, ACE_TEXT ("%s"), ior.in ());
ACE_OS::fclose (output_file);
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("Wrote IOR file\n")));
// Normally we run the orb and the orb is shutdown by
// calling TestTask::end().
// Accept requests
orb_->run();
orb_->destroy();
return 0;
}
catch (CORBA::Exception& ex)
{
ex._tao_print_exception (ACE_TEXT ("CORBA exception: "));
}
//.........这里部分代码省略.........