本文整理汇总了C++中Simple_Server_var::test_method方法的典型用法代码示例。如果您正苦于以下问题:C++ Simple_Server_var::test_method方法的具体用法?C++ Simple_Server_var::test_method怎么用?C++ Simple_Server_var::test_method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simple_Server_var
的用法示例。
在下文中一共展示了Simple_Server_var::test_method方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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");
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 ();
// 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 child_poa =
root_poa->create_POA ("childPOA", poa_manager.in (), policies);
// Creation of childPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
policies[i]->destroy ();
}
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 <%C> is nil\n",
ior),
1);
}
Callback_i callback_impl (orb.in ());
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId ("client_callback");
child_poa->activate_object_with_id (id.in (), &callback_impl);
CORBA::Object_var callback_object =
child_poa->id_to_reference (id.in ());
Callback_var callback = Callback::_narrow (callback_object.in ());
CORBA::String_var ior = orb->object_to_string (callback.in ());
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client callback activated as <%C>\n",
ior.in ()));
// Send the calback object to the server
server->callback_object (callback.in ());
int pre_call_connections =
orb->orb_core ()->lane_resources ().transport_cache ().current_size ();
// A method to kickstart callbacks from the server
CORBA::Long r = server->test_method (1);
if (r != 0)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d ",
r));
}
orb->run ();
int cur_connections =
orb->orb_core ()->lane_resources ().transport_cache ().current_size ();
if (cur_connections > pre_call_connections)
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) Expected %d "
//.........这里部分代码省略.........
示例2: svc
int svc ()
{
CORBA::String_var str = CORBA::string_alloc (200*2000 + 1);
if (str.in () == 0) return 1;
str.inout ()[0] = CORBA::Char ('\0');
for (int i=0; i < 2000; ++i)
{
ACE_OS::strcat (str.inout (), twohundredbytes);
}
while (1)
{
try
{
CORBA::String_var ret = srv_->test_method (str.in ());
if (0 != ACE_OS::strcmp (str.in (), ret.in ())) return 1;
}
catch (const CORBA::Exception& ex)
{
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("(%P|%t) Exception caught: \n%C\n"),
ex._info ().c_str ()));
return 1;
}
}
return 0;
}
示例3: thread
int
Worker::svc (void)
{
const char * name = 0;
/*
ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to sleep for %d sec\n", sleep_time_));
ACE_OS::sleep (sleep_time_);
ACE_DEBUG ((LM_DEBUG, "(%t|%T):woke up from sleep for %d sec\n", sleep_time_));
*/
ACE_hthread_t thr_handle;
ACE_Thread::self (thr_handle);
int prio;
if (ACE_Thread::getprio (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|%T) worker activated with prio %d\n", prio));
if (enable_dynamic_scheduling)
{
MIF_Scheduling::SchedulingParameter sched_param;
CORBA::Policy_var sched_param_policy;
sched_param.importance = importance_;
sched_param_policy = scheduler_->create_scheduling_parameter (sched_param);
CORBA::Policy_ptr implicit_sched_param = 0;
ACE_DEBUG ((LM_DEBUG, "(%t|%T):before begin_sched_segment\n"));
scheduler_current_->begin_scheduling_segment (name,
sched_param_policy.in (),
implicit_sched_param);
ACE_DEBUG ((LM_DEBUG, "(%t|%T):after begin_sched_segment\n"));
}
ACE_DEBUG ((LM_DEBUG, "(%t|%T):about to make two way call\n"));
server_->test_method (server_load_);
ACE_DEBUG ((LM_DEBUG, "(%t|%T):two way call done\n"));
if (enable_dynamic_scheduling)
{
scheduler_current_->end_scheduling_segment (name);
}
ACE_DEBUG ((LM_DEBUG, "client worker thread (%t) done\n"));
return 0;
}
示例4: catch
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);
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);
}
for (int i = 0; i != niterations; ++i)
{
CORBA::Long r =
server->test_method (i);
if (r != i)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d for %d",
r, i));
}
}
if (do_shutdown)
{
server->shutdown ();
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例5: catch
int
Client::svc (void)
{
try
{
for (int i = 0; i < this->niterations_; ++i)
{
// If we are using a global ORB this is a nop, otherwise it
// initializes the ORB resources for this thread.
int argc = 0;
CORBA::String_var argv0 = CORBA::string_dup ("dummy_argv");
char* argv[1] = { argv0.inout () };
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var object =
orb->string_to_object (this->ior_);
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Object reference <%s> is nil\n",
ior),
1);
}
server->test_method ();
if (TAO_debug_level > 0 && i % 100 == 0)
ACE_DEBUG ((LM_DEBUG, "(%P|%t) iteration = %d\n", i));
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("MT_Client: exception raised");
}
return 0;
}
示例6: if
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);
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);
}
Structure the_in_structure;
the_in_structure.seq.length (10);
if (test_user_exception == 1)
{
server->raise_user_exception ();
}
else if (test_system_exception == 1)
{
server->raise_system_exception ();
}
else
{
for (int i = 0; i != niterations; ++i)
{
CORBA::Long const tv = i + 100;
server->test_val(tv);
CORBA::Long const rtv = server->test_val ();
if (TAO_debug_level > 0)
{
ACE_DEBUG ((LM_DEBUG,
"DSI_Simpler_Server ==== Expected result = %d for %d\n",
rtv, tv));
}
if (rtv != tv)
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) ERROR: unexpected result = %d for %d\n",
rtv, tv));
}
the_in_structure.i = i;
CORBA::String_var name = CORBA::string_dup ("the name");
Structure_var the_out_structure;
CORBA::Long const r =
server->test_method (i,
the_in_structure,
the_out_structure.out (),
name.inout ());
if (TAO_debug_level > 0)
{
ACE_DEBUG ((LM_DEBUG,
"DSI_Simpler_Server ====\n"
" x = %d\n"
" i = %d\n"
" length = %d\n"
" name = <%C>\n",
r,
the_out_structure->i,
the_out_structure->seq.length (),
name.in ()));
}
if (r != i)
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) ERROR: unexpected result = %d for %d",
r, i));
}
}
}
if (do_shutdown)
{
server->shutdown ();
}
}
catch (const test_exception& ex)
//.........这里部分代码省略.........
示例7: 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)
//.........这里部分代码省略.........
示例8: policies
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
CORBA::ORB_var orb = CORBA::ORB::_nil();
PortableServer::POA_var root_poa = PortableServer::POA::_nil();
Callback_i *servant = 0;
try
{
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 ();
// 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 child_poa =
root_poa->create_POA ("childPOA",
poa_manager.in (),
policies);
// Creation of childPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
policies[i]->destroy ();
}
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);
}
servant = new Callback_i (orb.in ());
Callback_var callback =
servant->_this ();
// Send the calback object to the server
server->callback_object (callback.in ());
// A method to kickstart callbacks from the server
CORBA::Long r =
server->test_method (1);
if (r != 0)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) unexpected result = %d ",
r));
}
orb->run ();
root_poa->destroy (1, 1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return 1;
}
//.........这里部分代码省略.........