本文整理汇总了C++中corba::ORB_var::string_to_object方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_var::string_to_object方法的具体用法?C++ ORB_var::string_to_object怎么用?C++ ORB_var::string_to_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::ORB_var
的用法示例。
在下文中一共展示了ORB_var::string_to_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: env
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
ACE_TString env (ACE_TEXT ("SSL_CERT_FILE="));
env += cert_file;
ACE_OS::putenv ( ACE_TEXT_ALWAYS_CHAR(env.c_str ()));
//
// Initialize the ORB
//
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
//
// Get the Root POA.
//
CORBA::Object_var obj =
orb->resolve_initial_references ( "RootPOA" );
PortableServer::POA_var poa =
PortableServer::POA::_narrow (obj.in ());
//
// Get a reference to the server.
//
obj = orb->string_to_object ( ior );
if (CORBA::is_nil (obj.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P) orb->string_to_object ")
ACE_TEXT ("(\"file://server.ior\") failed.\n")),
-1);
}
//
// Downcast the IOR to the appropriate object type.
//
server_var server_obj =
server::_narrow (obj.in ());
if (CORBA::is_nil (server_obj.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P) server::_narrow(obj) failed.\n")),
-1);
}
//
// Create and activate the client.
//
client_i *servant = 0;
ACE_NEW_RETURN (servant,
client_i (server_obj.in ()),
-1);
PortableServer::ServantBase_var theClient = servant;
client_var client_ref = servant->_this ();
//
// Activate the POA manager.
//
PortableServer::POAManager_var mgr =
poa->the_POAManager ();
mgr->activate ();
//
// Set the server's callback and invoke the test request.
//
server_obj->set_client (client_ref.in ());
server_obj->test_request ("first secure callback to client");
//
// Repeat the callback test.
//
server_obj->set_client (client_ref.in ());
server_obj->test_request ("second secure callback to client");
server_obj->shutdown ();
poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (ACE_TEXT ("Caught exception\n"));
return -1;
}
return 0;
}
示例2: env
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
bool set_cert_file = true;
try
{
// This has to be done before calling CORBA::ORB_init() and
// parse_args() has to be called after CORBA::ORB_init(), so we
// will look at argv manually.
for(int i = 0; i < argc; i++)
{
if (ACE_OS::strcmp(argv[i], ACE_TEXT("-n")) == 0)
{
set_cert_file = false;
break;
}
}
ACE_CString env ("SSL_CERT_FILE=");
env += cert_file;
if (set_cert_file)
{
ACE_OS::putenv (env.c_str ());
}
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
if (set_cert_file)
{
// This test sets creates a Security::QOPPolicy with the
// Quality-of-Protection set to "no protection." It then
// invokes a method on the server (insecurely), which should
// then result in a CORBA::NO_PERMISSION exception.
//
// The server is not shutdown by this test.
status = insecure_invocation_test (orb.in (), object.in ());
ACE_DEBUG ((LM_DEBUG,
"insecure_invocation_test returned <%d>\n",
status));
}
// This test uses the default secure SSLIOP settings to securely
// invoke a method on the server. No exception should occur.
//
// The server *is* shutdown by this test.
try
{
status = secure_invocation_test (object.in ());
ACE_DEBUG ((LM_DEBUG,
"secure_invocation_test returned <%d>\n",
status));
}
catch (CORBA::Exception const &ex)
{
if (set_cert_file)
{
ex._tao_print_exception ("Caught unexpected exception "
"(probable failure):");
status = 1;
}
else
{
ACE_DEBUG ((LM_DEBUG,
"Caught an exception as expected due "
"to the SSL_CERT_FILE environment "
"variable not being set.\n"));
}
}
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception in main:");
return 1;
}
if (status == 0)
{
ACE_DEBUG ((LM_DEBUG,
"\n"
"Bug_1107_Regression test passed.\n"));
}
return status;
}
示例3: callback_impl
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,
" (%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;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
Callback_i callback_impl (orb.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (&callback_impl);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Callback_var callback =
Callback::_narrow (object_act.in ());
for (int i = 0; i != niterations; ++i)
{
CORBA::Long r =
server->test_method (0, 0, callback.in ());
if (r != 0)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d for %d",
r, i));
}
}
if (do_abort)
{
try
{
server->shutdown_now (0);
}
catch (const CORBA::COMM_FAILURE&)
{
// Expected exception, continue....
}
}
else if (do_crash)
{
try
{
server->shutdown_now (1);
}
catch (const CORBA::COMM_FAILURE&)
{
// Expected exception, continue....
}
}
else if (do_suicide)
{
(void) server->test_method (1, 0, callback.in ());
// The shutdown callback could arrive after this twoway invocation
// returned. Wait for it shutdown callback and abort,
// otherwise it will timeout (in run_test.pl).
ACE_OS::sleep (120);
}
else if (do_self_shutdown)
{
(void) server->test_method (1, 1, callback.in ());
}
if (do_shutdown)
//.........这里部分代码省略.........
示例4: catch
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int status = 0;
try
{
#if TAO_HAS_INTERCEPTORS == 1
PortableInterceptor::ORBInitializer_ptr temp_initializer =
PortableInterceptor::ORBInitializer::_nil ();
ACE_NEW_RETURN (temp_initializer,
Client_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,
"Client ORB");
if (::parse_args (argc, argv) != 0)
return -1;
CORBA::Object_var object =
orb->string_to_object (ior1);
RedirectionTest::test_var server =
RedirectionTest::test::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior1),
1);
}
CORBA::Short number = 0;
for (int i = 1; i <= 9; ++i)
{
ACE_DEBUG ((LM_INFO,
"CLIENT: Issuing request %d.\n",
i));
number = server->number ();
ACE_DEBUG ((LM_INFO,
"CLIENT: Request %d handled by object %d.\n",
i,
number));
}
server->shutdown ();
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return -1;
}
if (status != -1)
ACE_DEBUG ((LM_INFO,
"PortableInterceptor::Redirection test passed.\n"));
return status;
}
示例5: 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;
Worker worker (orb.in ());
if (worker.activate (THR_NEW_LWP | THR_JOINABLE,
nthreads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Cannot activate worker threads\n"),
1);
int timeout = 30;
int now = 0;
while (now < timeout
&& ((expect_ex_kind != TAO::FOE_NON
&& worker.received_ex_kind () != expect_ex_kind
&& worker.num_received_ex () != expect_num_ex)
|| expect_ex_kind == TAO::FOE_NON))
{
std::cout << ".";
now += 1;
ACE_Time_Value tv (1, 0);
orb->run (tv);
}
std::cout << std::endl;
worker.done ();
if (do_shutdown)
{
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
server->shutdown ();
}
ACE_OS::sleep (1);
orb->destroy ();
worker.thr_mgr ()->wait ();
if (worker.received_ex_kind () != expect_ex_kind
|| worker.num_received_ex () != expect_num_ex)
{
ACE_ERROR_RETURN ((LM_ERROR,
("(%P|%t)client: test failed - expected is different from received. "
"expected %d/%d received %d/%d.\n"),
expect_ex_kind, expect_num_ex, worker.received_ex_kind (), worker.num_received_ex()),
1);
}
ACE_DEBUG ((LM_DEBUG, "(%P|%t)client: test passed.\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught in main:");
return 1;
}
return 0;
}
示例6: owner_transfer
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 ());
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;
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 <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 ();
CORBA::Object_var tmp =
orb->string_to_object(server_ior);
Test::Hello_var server =
Test::Hello::_narrow(tmp.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
"Nil Test::Hello reference <%s>\n",
ior.in ()),
1);
}
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Sending client obj ref to the server and requesting a callback.\n"));
server->request_callback (hello.in ());
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Test (client) Succeeded !!!\n"));
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ACE_DEBUG ((LM_ERROR, "(%P|%t) - Test (client) Failed !!!\n"));
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例7: sched_params
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Fixed_Priority_Scheduler* scheduler=0;
RTScheduling::Current_var current;
int prio;
int max_prio;
ACE_Sched_Params::Policy sched_policy = ACE_SCHED_RR;
int sched_scope = ACE_SCOPE_THREAD;
long flags;
if (sched_policy == ACE_SCHED_RR)
flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR;
else
flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO;
ACE_hthread_t main_thr_handle;
ACE_Thread::self (main_thr_handle);
max_prio = ACE_Sched_Params::priority_max (sched_policy,
sched_scope);
//FUZZ: disable check_for_lack_ACE_OS
ACE_Sched_Params sched_params (sched_policy, max_prio);
//FUZZ: enable check_for_lack_ACE_OS
ACE_OS::sched_params (sched_params);
if (ACE_Thread::getprio (main_thr_handle, prio) == -1)
{
if (errno == ENOTSUP)
{
ACE_ERROR((LM_ERROR,
ACE_TEXT ("getprio not supported\n")
));
}
else
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n")
ACE_TEXT ("thr_getprio failed")));
}
}
ACE_DEBUG ((LM_DEBUG, "(%t): main thread prio is %d\n", prio));
try
{
RTScheduling::Scheduler_var sched_owner;
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
orb->string_to_object (ior);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
if (enable_dynamic_scheduling)
{
ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n"));
CORBA::Object_var manager_obj =
orb->resolve_initial_references ("RTSchedulerManager");
TAO_RTScheduler_Manager_var manager =
TAO_RTScheduler_Manager::_narrow (manager_obj.in ());
Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type;
if (enable_yield)
{
disp_impl_type = Kokyu::DSRT_CV_BASED;
}
else
{
disp_impl_type = Kokyu::DSRT_OS_BASED;
}
ACE_NEW_RETURN (scheduler,
Fixed_Priority_Scheduler (orb.in (),
disp_impl_type,
sched_policy,
sched_scope), -1);
sched_owner = scheduler;
manager->rtscheduler (scheduler);
CORBA::Object_var object =
orb->resolve_initial_references ("RTScheduler_Current");
//.........这里部分代码省略.........
示例8: while
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) == -1)
return -1;
CORBA::Object_var obj =
orb->string_to_object (proxy_ior);
if (obj.in () == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"The received object is nil\n"),
-1);
}
Simple_Server_var server =
Simple_Server::_narrow (obj.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference is nil\n"),
-1);
}
try
{
while (true)
{
// Make a remote call
server->remote_call ();
ACE_OS::sleep (2);
}
}
catch (CORBA::TRANSIENT& ex)
{
CORBA::ULong m = ex.minor () & 0x00000F80u;
if (m == TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE &&
ex.completed () == CORBA::COMPLETED_NO)
{
ACE_DEBUG ((LM_DEBUG,
"TRANSIENT caught in client as it was expected.\n"));
}
else
{
ex._tao_print_exception ("Unexpected TRANSIENT caught in client:");
return 2;
}
}
obj =
orb->string_to_object (control_ior);
if (obj.in () == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"The received objref is NULL\n"),
-1);
}
server =
Simple_Server::_narrow (obj.in ());
server->shutdown ();
orb->destroy ();
}
catch (const CORBA::Exception & ex)
{
ex._tao_print_exception ("Exception caught in client:");
return 1;
}
return 0;
}
示例9: get_opt
RtecEventChannelAdmin::EventChannel_ptr
get_event_channel(int argc, ACE_TCHAR** argv)
{
FtRtecEventChannelAdmin::EventChannel_var channel;
ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("hi:nt:?"));
int opt;
int use_gateway = 1;
while ((opt = get_opt ()) != EOF)
{
switch (opt)
{
case 'i':
{
CORBA::Object_var obj = orb->string_to_object(get_opt.opt_arg ());
channel = FtRtecEventChannelAdmin::EventChannel::_narrow(obj.in());
}
break;
case 'n':
use_gateway = 0;
break;
case 't':
timer_interval.set(ACE_OS::atof(get_opt.opt_arg ()));
case 'h':
case '?':
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("Usage: %s ")
ACE_TEXT("-i ftrt_eventchannel_ior\n")
ACE_TEXT("-n do not use gateway\n")
ACE_TEXT("-t time Time interval in seconds between events (default 1.0)\n")
ACE_TEXT("\n"),
argv[0]));
return 0;
}
}
if (CORBA::is_nil(channel.in()))
{
/// Find the FTRTEC from the Naming Service
CosNaming::Name name(1);
name.length(1);
name[0].id = CORBA::string_dup("FT_EventService");
CosNaming::NamingContext_var naming_context =
resolve_init<CosNaming::NamingContext>(orb.in(), "NameService");
channel = resolve<FtRtecEventChannelAdmin::EventChannel> (naming_context.in (),
name);
}
if (use_gateway)
{
// use local gateway to communicate with FTRTEC
ACE_auto_ptr_reset (gateway, new TAO_FTRTEC::FTEC_Gateway (orb.in (), channel.in ()));
return gateway->_this ();
}
else
return channel._retn ();
}
示例10: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// initialize the ORB
_orb = CORBA::ORB_init (argc, argv);
// Get the "RootPOA"
CORBA::Object_var obj = _orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in ());
// activate its managers so it can handle incoming requests
poa->the_POAManager()->activate();
// get a thread going to handle incoming requests
ACE_Thread::spawn(RunFunc);
// we could also use the c_orbaloc syntax to get a reference to the
// object. This will cause the _orb to talk directly to the other
// _orb with no name service or common file involved.
obj = _orb->string_to_object("c_orbaloc::localhost:9999/Simple");
if (CORBA::is_nil(obj.in ()))
{
ACE_ERROR ((LM_ERROR, "could not get reference\n"));
return 1;
}
// narrow the reference to the particular type we wish to deal with
Simple_var simple = Simple::_narrow(obj.in ());
if (CORBA::is_nil(simple.in ()))
{
ACE_ERROR ((LM_ERROR, "could not get reference\n"));
return 1;
}
// create an object reference that has a bogus value for the first
// profile
obj = _orb->resolve_initial_references("IORManipulation");
TAO_IOP::TAO_IOR_Manipulation_var iorm =
TAO_IOP::TAO_IOR_Manipulation::_narrow(obj.in());
// Status: The following scenarios appear to work:
// - first profile invalid host name, second profile valid.
// - first profile invalid ip number, second profiel valid.
// - first profiel invalid port number, second profile valid.
//
// The following causes a core dump of the server:
// - first and second invalid
//
// Note that he iormanip is being used since it is not practical
// to have a test case that depends on a VPN being present.
//
CORBA::Object_var name1 =
_orb->string_to_object ("c_orbaloc:iiop:10.0.2.3:6060/xyz");
CORBA::Object_var name2 =
_orb->string_to_object ("c_orbaloc:iiop:daisnot:7070/xyz");
CORBA::String_var name1_ior = _orb->object_to_string(name1.in());
CORBA::String_var name2_ior = _orb->object_to_string(name2.in());
// create a callback object
Callee_i * callee_i = new Callee_i;
// get the CORBA reference
PortableServer::ObjectId_var id =
poa->activate_object (callee_i);
CORBA::Object_var object_act = poa->id_to_reference (id.in ());
Callee_var callee = Callee::_narrow (object_act.in ());
if (CORBA::is_nil(callee.in ()))
{
ACE_ERROR ((LM_ERROR, "could not get callback object\n"));
return 1;
}
else
{
CORBA::String_var str = _orb->object_to_string(callee.in ());
FILE *output_file= ACE_OS::fopen ("ior", "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: ior\n"),
1);
ACE_OS::fprintf (output_file, "%s", str.in ());
ACE_OS::fclose (output_file);
}
// create a reference with two profiles with the first on being
// bogus. If things work as they should the callback should be
// succesful with the ORB trying the second profile.
TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
iors.length (2);
iors [0] = name1;
iors [1] = name2;
CORBA::Object_var merged = iorm->merge_iors(iors);
Callee_var doubleCallee = Callee::_unchecked_narrow(merged.in());
ACE_DEBUG ((LM_DEBUG, "Profile count is %d\n",
iorm->get_profile_count(merged.in())));
//.........这里部分代码省略.........
示例11: employee_attributes
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
char str [255];
// Initialize the ORB
try
{
ACE_OS::strcpy (str,
"CORBA::ORB_init");
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
// Parse the command-line arguments to get the location of the
// IOR
if (parse_args (argc, argv) == -1)
return -1;
if (IOR == 0)
{
int result = read_IOR_from_file ();
if (result != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot read IOR from %s\n",
IOR_file),
-1);
}
ACE_OS::strcpy (str,
"CORBA::ORB::string_to_object");
// Get the object reference with the IOR
CORBA::Object_var object = orb->string_to_object (IOR);
ACE_OS::strcpy (str,
"Database::Agent::_narrow");
// Narrow the object reference to a Database::Agent
Database::Agent_var database_agent =
Database::Agent::_narrow (object.in ());
Database::NVPairSequence employee_attributes (2);
employee_attributes.length (2);
Database::NamedValue &first =
employee_attributes[0];
Database::NamedValue &second =
employee_attributes[1];
const char *name = "irfan";
CORBA::Long id = 555;
first.name = CORBA::string_dup ("name");
first.value <<= name;
second.name = CORBA::string_dup ("id");
second.value <<= id;
ACE_OS::strcpy (str,
"Database::Agent::create_entry");
// Create an employee
Database::Entry_var entry =
database_agent->create_entry ("irfan",
"Employee",
employee_attributes);
ACE_OS::strcpy (str, "Database::Employee::_narrow");
Database::Employee_var employee =
Database::Employee::_narrow (entry.in ());
/*
*
* NOT IMPLEMENTED YET
*
*
*/
#if 0
// Reset the id
ACE_OS::strcpy (str, "Database::Employee::id");
employee->id (666);
#endif /* 0 */
ACE_OS::strcpy (str, "Database::Entry::find");
// Find the employee
entry = database_agent->find_entry ("irfan",
"Employee");
ACE_OS::strcpy (str, "Database::Entry::destroy");
// Destroy the employee
database_agent->destroy_entry ("irfan",
"Employee");
ACE_OS::strcpy (str, "Shutdown server");
if (shutdown_server)
{
database_agent->shutdown ();
}
//.........这里部分代码省略.........
示例12: 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;
// Create client callback CORBA object
TestCallback *test_impl = 0;
ACE_NEW_RETURN (test_impl,
TestCallback (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 ());
Test::TestCallback_var client = Test::TestCallback::_narrow (object.in ());
poa_manager->activate ();
// Get server CORBA object and call it
CORBA::Object_var tmp = orb->string_to_object(ior);
Test::TestServer_var server = Test::TestServer::_narrow(tmp.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
"Nil Test::TestServer reference <%s>\n",
ior),
1);
}
ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - calling server\n"));
server->pass_callback (client.in());
ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - call failed to block\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - not stopped by server\n"));
return 1;
}
示例13: catch
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB, resolve references and parse arguments.
// ORB.
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
// Parse arguments.
if (parse_args (argc, argv) != 0)
return -1;
// Test object 1.
CORBA::Object_var object =
orb->string_to_object (ior1);
Test_var server1 = Test::_narrow (object.in ());
if (check_for_nil (server1.in (), "server1") == -1)
return -1;
// Test object 2.
object = orb->string_to_object (ior2);
Test_var server2 = Test::_narrow (object.in ());
if (check_for_nil (server2.in (), "server2") == -1)
return -1;
// Check that test objects are configured with SERVER_DECLARED
// PriorityModelPolicy, and get their server priorities.
// Test object 1.
CORBA::Short server1_priority =
check_policy (server1.in ());
if (server1_priority == -1)
return -1;
// Test object 2.
CORBA::Short server2_priority =
check_policy (server2.in ());
if (server2_priority == -1)
return -1;
// Testing: make several invocations on test objects.
for (int i = 0; i < 5; ++i)
{
server1->test_method (server1_priority);
server2->test_method (server2_priority);
}
// Testing over. Shut down Server ORB.
server1->shutdown ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (
"Unexpected exception in Server_Declared test client:");
return -1;
}
return 0;
}
示例14: udp_i
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->string_to_object (ior);
UDP_var udp_var =
UDP::_narrow (object.in ());
if (CORBA::is_nil (udp_var.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
// Activate POA to handle the call back.
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 ();
// Instantiate reply handler
UDP_i udp_i (orb.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (&udp_i);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
UDP_var udpHandler_var =
UDP::_narrow (object_act.in ());
// Instantiate client
UDP_Client_i *client = new UDP_Client_i (orb.in (),
udp_var.in (),
udpHandler_var.in (),
msec,
iterations);
// let the client run in a separate thread
client->activate ();
// ORB loop, will be shut down by our client thread
orb->run ();
ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
root_poa->destroy (1, // ethernalize objects
0); // wait for completion
orb->destroy ();
client->wait ();
// it is save to delete the client, because the client was actually
// the one calling orb->shutdown () triggering the end of the ORB
// event loop.
delete client;
}
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 {
// First initialize the ORB, that will remove some arguments...
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
// There must be at least two arguments, the first is the factory
// name, the rest are the names of the stock symbols we want to
// get quotes for.
if (argc < 3) {
cerr << "Usage: " << argv[0]
<< " Factory_IOR symbol symbol..." << endl;
return 1;
}
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
poa->the_POAManager ();
poa_manager->activate ();
// Use the first argument to create the factory object reference,
// in real applications we use the naming service, but let's do
// the easy part first!
CORBA::Object_var factory_object =
orb->string_to_object (argv[1]);
// Now downcast the object reference to the appropriate type
Quoter::Stock_Factory_var factory =
Quoter::Stock_Factory::_narrow (factory_object.in ());
// Create and activate the handler...
int response_count = 0;
Single_Query_Stock_Handler_i handler_i (&response_count);
Quoter::AMI_Single_Query_StockHandler_var handler =
handler_i._this ();
// Send all the requests, careful with error handling
int request_count = 0;
for (int i = 2; i != argc; ++i) {
try {
// Get the stock object
Quoter::Stock_var tmp =
factory->get_stock (ACE_TEXT_ALWAYS_CHAR (argv[i]));
Quoter::Single_Query_Stock_var stock =
Quoter::Single_Query_Stock::_narrow (tmp.in ());
if (CORBA::is_nil (stock.in ())) {
cerr << "Cannot get single query interface for <"
<< argv[i] << ">" << endl;
}
stock->sendc_get_price_and_names (handler.in ());
request_count++;
}
catch (Quoter::Invalid_Stock_Symbol &) {
cerr << "Invalid stock symbol <"
<< argv[i] << ">" << endl;
}
}
while (response_count < request_count
&& orb->work_pending ()) {
orb->perform_work ();
}
// Destroy the POA, waiting until the destruction terminates
poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception &) {
cerr << "CORBA exception raised!" << endl;
}
return 0;
}