本文整理汇总了C++中portableserver::ObjectId_var类 的典型用法代码示例。如果您正苦于以下问题:C++ ObjectId_var类的具体用法?C++ ObjectId_var怎么用?C++ ObjectId_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectId_var类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 "
//.........这里部分代码省略.........
开发者ID:asdlei00, 项目名称:ACE, 代码行数:101, 代码来源:client.cpp
示例2: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
try {
// Initialze the ORB.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
// Get a reference to the RootPOA.
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 ());
// Get the POAManager of the RootPOA.
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
// Policies for the childPOA to be created.
CORBA::PolicyList policies;
policies.length (2);
policies[0] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID);
policies[1] =
root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
// Create the childPOA under the RootPOA.
PortableServer::POA_var child_poa =
root_poa->create_POA ("childPOA",
poa_manager.in (),
policies);
// Destroy the policy objects
for (CORBA::ULong i = 0; i != policies.length (); ++i) {
policies[i]->destroy ();
}
// Create an instance of class Quoter_Stock_Factory_i.
Quoter_Stock_Factory_i stock_factory_i;
// Get the Object ID.
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("Stock_Factory");
// Activate the Stock_Factory object.
child_poa->activate_object_with_id (oid.in (),
&stock_factory_i);
// Get the object reference.
CORBA::Object_var stock_factory =
child_poa->id_to_reference (oid.in ());
CORBA::Object_var table_object =
orb->resolve_initial_references ("IORTable");
// Stringify all the object referencs.
CORBA::String_var ior = orb->object_to_string (stock_factory.in ());
IORTable::Table_var adapter =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
}
else
{
CORBA::String_var ior =
orb->object_to_string (stock_factory.in ());
adapter->bind ("childPOA", ior.in ());
}
orb->run ();
// Destroy POA, waiting until the destruction terminates.
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception &) {
cerr << "CORBA exception raised !" << endl;
}
return 0;
}
开发者ID:CCJY, 项目名称:ATCD, 代码行数:87, 代码来源:server.cpp
示例3: middle
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
ACE_DEBUG ((LM_DEBUG,
"Middle (%P|%t) started\n"));
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc,
argv);
if ( ! parse_args (argc, argv))
{
return -1;
}
///////////////////////////////
// Prepare to be a CORBA server
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 ();
///////////////////////////////
// Prepare to be a CORBA client
FILE *input_file = ACE_OS::fopen (ior_input_file, "r");
if (input_file == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open input IOR file: %s",
ior_input_file),
-1);
}
ACE_OS::fread (input_ior, 1, sizeof(input_ior), input_file);
ACE_OS::fclose (input_file);
// Convert the IOR to an object reference.
CORBA::Object_var object =
orb->string_to_object (input_ior);
// narrow the object reference to a ThreeTier reference
ThreeTier_var target = ThreeTier::_narrow (object.in ());
if (CORBA::is_nil (target.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"IOR does not refer to a ThreeTier implementation"),
-1);
}
// We should have a good connection now
// temporary: check it out
//target->tick();
//target->tock();
Middle_i middle (orb.in(), target.in ());
if (middle.parse_args (argc, argv) )
{
/////////////////////////////////
// Activate server side mechanism
PortableServer::ObjectId_var id =
root_poa->activate_object (&middle);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
ThreeTier_var server =
ThreeTier::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (server.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",
ior_output_file),
-1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
poa_manager->activate ();
orb->run ();
}
}
catch (const CORBA::UserException& userex)
{
userex._tao_print_exception ("Middle: User Exception in main");
return -1;
}
catch (const CORBA::SystemException& sysex)
{
sysex._tao_print_exception ("Middle: System Exception in main");
return -1;
}
//.........这里部分代码省略.........
开发者ID:OspreyHub, 项目名称:ATCD, 代码行数:101, 代码来源:middle.cpp
示例4: 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;
Simple_Server_i server_impl (orb.in (),
no_iterations);
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId ("simple_server");
child_poa->activate_object_with_id (id.in (),
&server_impl);
CORBA::Object_var obj =
child_poa->id_to_reference (id.in ());
CORBA::String_var ior =
orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));
// If the ior_output_file exists, output the ior to it
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 IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
int retval = 0;
while (retval == 0)
{
// Just process one upcall. We know that we would get the
// clients IOR in that call.
CORBA::Boolean pending =
orb->work_pending();
if (pending)
{
orb->perform_work();
}
// Now that hopefully we have the clients IOR, just start
// making remote calls to the client.
retval = server_impl.call_client ();
}
//.........这里部分代码省略.........
开发者ID:OspreyHub, 项目名称:ATCD, 代码行数:101, 代码来源:server.cpp
示例5: ACE_TMAIN
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();
// Find the Naming Service
obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var root =
CosNaming::NamingContextExt::_narrow(obj.in());
if (CORBA::is_nil(root.in())) {
std::cerr << "Nil Naming Context reference" << std::endl;
return 1;
}
// Bind a new context.
CosNaming::Name name;
name.length( 1 );
name[0].id = CORBA::string_dup( "root.esc-dot" );
name[0].kind = CORBA::string_dup( "kind1" );
try {
obj = root->resolve(name);
}
catch(const CosNaming::NamingContext::NotFound&) {
CosNaming::NamingContext_var dummy = root->bind_new_context(name);
}
name.length( 2 );
name[1].id = CORBA::string_dup( "leaf/esc-slash" );
name[1].kind = CORBA::string_dup( "kind2" );
// Create an object
PortableServer::Servant_var<Messenger_i> servant = new Messenger_i;
PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
CORBA::Object_var messenger_obj = poa->id_to_reference(oid.in());
root->rebind(name, messenger_obj.in());
// Also try rebinding to a simple path.
CosNaming::Name_var simp_name = root->to_name("Simple");
try {
obj = root->resolve(simp_name.in());
}
catch(const CosNaming::NamingContext::NotFound&) {
CosNaming::NamingContext_var dummy =
root->bind_new_context(simp_name.in());
}
simp_name = root->to_name("Simple/Messenger");
root->rebind(simp_name.in(), messenger_obj.in());
// Convert Name to String Name.
CORBA::String_var str_name = root->to_string(name);
std::cout << "str_name: " << str_name.in() << std::endl;
CORBA::String_var str_simple = root->to_string(simp_name.in());
std::cout << "simple: " << str_simple.in() << std::endl;
// Convert String Name to Name.
CosNaming::Name_var tname = root->to_name(str_name.in());
std::cout << "converted back to a CosNaming::Name: " << std::endl;
std::cout << " name[0] = " << (* tname)[0].id.in() << " , "
<< (* tname)[0].kind.in() << std::endl;
std::cout << " name[1] = " << (* tname)[1].id.in() << " , "
<< (* tname)[1].kind.in() << std::endl;
// Find the application object by resolve_str.
try {
obj = root->resolve_str(str_name.in());
}
catch(const CosNaming::NamingContext::NotFound&) {
std::cerr<<"Couldn't resolve the string name: " << str_name << std::endl;
return 1;
}
ACE_CString base_address (":");
base_address += ACE_TEXT_ALWAYS_CHAR (hostname);
base_address += ":";
base_address += ACE_TEXT_ALWAYS_CHAR (port);
ACE_CString addr ("");
addr = base_address + "/key/str";
// Create an URL string for application object.
CORBA::String_var address = CORBA::string_dup (addr.c_str());
std::cout << "call to_url(\"" << address.in() << "\"" << std::endl;
std::cout << " ,\"" << str_simple.in() << "\")"<< std::endl;
CORBA::String_var url_string = root->to_url(address.in(), str_simple.in());
//.........这里部分代码省略.........
开发者ID:svn2github, 项目名称:ACE-Middleware, 代码行数:101, 代码来源:MessengerServer.cpp
示例6: thread
int
Server::svc (void)
{
ACE_hthread_t current;
ACE_Thread::self (current);
int native_priority;
ACE_Thread::getprio (current, native_priority);
ACE_DEBUG ((LM_DEBUG,
"Server orb thread (%t): corba_priority = %d"
" actual native priority = %d\n",
priority_,
native_priority));
try
{
char orb_name[64];
ACE_OS::sprintf (orb_name, "%d", this->priority_);
CORBA::ORB_var orb =
CORBA::ORB_init (argc_, argv_, orb_name);
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 ();
PortableServer::ObjectId_var oid =
root_poa->activate_object (this->server_);
CORBA::Object_var obj =
root_poa->id_to_reference (oid.in ());
CORBA::String_var ior =
orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));
// Get the file name to store the ior.
char file_name[100];
ACE_OS::sprintf (file_name,
"%s_%d",
ACE_TEXT_ALWAYS_CHAR (ior_output_file_base),
this->priority_);
// Output the ior to a file.
FILE *output_file= ACE_OS::fopen (file_name, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
file_name),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
// Start orb event loop.
poa_manager->activate ();
orb->run ();
}
catch (const CORBA::Exception& ex)
{
char message[100];
ACE_OS::sprintf (message,
"ORB_per_Priority::server: Exception in thread with priority = %d",
this->priority_);
ex._tao_print_exception (message);
}
return 0;
}
开发者ID:OspreyHub, 项目名称:ATCD, 代码行数:81, 代码来源:server.cpp
示例7: servant
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 ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
poa_manager->activate ();
if (parse_args (argc, argv) != 0)
return -1;
test_i servant (orb.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (&servant);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
test_var server =
test::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (server.in ());
ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.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",
ior_output_file),
-1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
Event_Loop_Task event_loop_task (orb.in ());
if (event_loop_task.activate (THR_NEW_LWP | THR_JOINABLE,
number_of_event_loop_threads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot activate event_loop threads\n"),
-1);
event_loop_task.thr_mgr ()->wait ();
ACE_DEBUG ((LM_DEBUG, "Server: Event loop finished\n"));
root_poa->destroy (1,
1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return -1;
}
return 0;
}
开发者ID:OspreyHub, 项目名称:ATCD, 代码行数:70, 代码来源:server.cpp
示例8:
void
TAO_Offer_Iterator_Collection::destroy (void)
{
// Destroy all iterators in the collection.
for (Offer_Iters::ITERATOR iters_iter (this->iters_);
! iters_iter.done ();
iters_iter.advance ())
{
CosTrading::OfferIterator** iter = 0;
iters_iter.next (iter);
(*iter)->destroy ();
}
// Remove self from POA
PortableServer::POA_var poa =
this->_default_POA ();
PortableServer::ObjectId_var id =
poa->servant_to_id (this);
poa->deactivate_object (id.in ());
}
开发者ID:CCJY, 项目名称:ATCD, 代码行数:24, 代码来源:Offer_Iterators.cpp
示例9: assert
static CCS::Thermometer_ptr
make_dref (PortableServer::POA_ptr poa, CCS::AssetType anum)
{
// Convert asset number to OID.
ostrstream ostr;
ostr << anum << ends;
char * anum_str = ostr.str ();
PortableServer::ObjectId_var oid
= PortableServer::string_to_ObjectId (anum_str);
delete[] anum_str;
// Look at the model via the network to determine
// the repository ID.
char buf[32];
assert (ICP_get (anum, "model", buf, sizeof (buf)) == 0);
const char * rep_id = ACE_OS::strcmp (buf, "Sens-A-Temp") == 0
? "IDL:acme.com/CCS/Thermometer:1.0"
: "IDL:acme.com/CCS/Thermostat:1.0";
// Make a new reference.
CORBA::Object_var obj
= poa->create_reference_with_id (oid.in (), rep_id);
return CCS::Thermometer::_narrow (obj.in ());
}
开发者ID:asdlei00, 项目名称:ACE, 代码行数:24, 代码来源:server.cpp
示例10:
void
test_i::deactivate_self (void)
{
PortableServer::POA_var poa = this->_default_POA ();
PortableServer::ObjectId_var id = poa->servant_to_id (this);
if (debug)
ACE_DEBUG ((LM_DEBUG, "(%t) Deactivating servant\n"));
poa->deactivate_object (id.in ());
if (debug)
ACE_DEBUG ((LM_DEBUG, "(%t) Deactivation complete: signaling main thread and going to sleep\n"));
int result = this->event_.signal ();
ACE_ASSERT (result == 0);
ACE_UNUSED_ARG (result);
ACE_OS::sleep (3);
if (debug)
ACE_DEBUG ((LM_DEBUG, "(%t) test_i::deactivate_self complete\n"));
}
开发者ID:OspreyHub, 项目名称:ATCD, 代码行数:24, 代码来源:Object_Reactivation.cpp
示例11: 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 object =
orb->string_to_object (ior);
A::AMI_Test_var server = A::AMI_Test::_narrow (object.in ());
if (CORBA::is_nil (server.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 ();
// Let the client perform the test in a separate thread
Handler* handler = 0;
ACE_NEW_RETURN (handler,
Handler,
1);
PortableServer::ServantBase_var owner_transfer(handler);
PortableServer::ObjectId_var id =
root_poa->activate_object (handler);
CORBA::Object_var object2 = root_poa->id_to_reference (id.in ());
A::AMI_AMI_TestHandler_var hello = A::AMI_AMI_TestHandler::_narrow (object2.in ());
object2 = CORBA::Object::_nil ();
server->shutdown (); // oneway, so returns here immediately but server waits 5 sec
Client client (server.in (), niterations, hello.in ());
if (client.activate (THR_NEW_LWP | THR_JOINABLE,
nthreads) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot activate client threads\n"),
1);
// Main thread collects replies. It needs to collect
// <nthreads*niterations> replies.
number_of_replies = nthreads *niterations;
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) : Entering perform_work loop to receive <%d> replies\n",
number_of_replies));
}
// ORB loop.
ACE_Time_Value tv (1,0);
orb->run (tv);
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) : Exited perform_work loop Received <%d> replies\n",
(nthreads*niterations) - number_of_replies));
}
ACE_DEBUG ((LM_DEBUG, "threads finished\n"));
client.wait ();
tv = ACE_Time_Value (1,0);
orb->run (tv);
root_poa->deactivate_object (id.in ());
root_poa->destroy (1, // ethernalize objects
0); // wait for completion
hello = A::AMI_AMI_TestHandler::_nil ();
root_poa = PortableServer::POA::_nil ();
//.........这里部分代码省略.........
开发者ID:OspreyHub, 项目名称:ATCD, 代码行数:101, 代码来源:client.cpp
示例12: payload
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var object_var =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa_var =
PortableServer::POA::_narrow (object_var.in ());
PortableServer::POAManager_var poa_manager_var =
poa_var->the_POAManager ();
poa_manager_var->activate ();
if (parse_args (argc, argv) != 0)
return 1;
// We reuse the object_var smart pointer!
CORBA::Object_var ior_object = orb->string_to_object (ior);
A::AMI_Test_var ami_test_var =
A::AMI_Test::_narrow (ior_object.in ());
if (CORBA::is_nil (ami_test_var.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Object reference <%s> is nil.\n",
ior),
1);
}
// Instantiate the ReplyHandler and register that with the POA.
Handler handler;
PortableServer::ObjectId_var id =
poa_var->activate_object (&handler);
CORBA::Object_var object = poa_var->id_to_reference (id.in ());
A::AMI_AMI_TestHandler_var the_handler_var =
A::AMI_AMI_TestHandler::_narrow (object.in ());
CORBA::Long l = 931247;
A::Payload payload (payload_size);
payload.length (payload_size);
for (CORBA::ULong j = 0; j != payload_size; ++j)
{
payload[j] = j % 256;
}
for (ssize_t ni = 0; ni < niterations; ni++)
{
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"Sending asynch message: %d\n",
ni));
}
ami_test_var->sendc_foo (the_handler_var.in (),
l,
"Let's talk AMI.",
payload);
}
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"<%d> Asynchronous methods issued\n",
niterations));
}
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"Issuing a synchronous method to collect the AMI replies\n"));
}
CORBA::Long number = ami_test_var->foo (l,
l,
"Let's talk SMI.",
payload);
if (debug)
{
ACE_DEBUG ((LM_DEBUG,
"Received the following number: %d\n",
number));
}
if (shutdown_flag)
{
ami_test_var->shutdown ();
}
//.........这里部分代码省略.........
开发者ID:esohns, 项目名称:ATCD, 代码行数:101, 代码来源:client.cpp
示例13: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
CORBA::ORB_var orb;
try
{
orb = CORBA::ORB_init (argc, argv);
CORBA::Object_var root_poa_o =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow (root_poa_o.in ());
if (CORBA::is_nil (rootPOA.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"), 1);
}
PortableServer::POAManager_var poaMgr = rootPOA->the_POAManager ();
poaMgr->activate ();
CORBA::PolicyList policies;
policies.length (3);
policies[0] = rootPOA->create_id_assignment_policy (
PortableServer::SYSTEM_ID);
policies[1] = rootPOA->create_implicit_activation_policy (
PortableServer::NO_IMPLICIT_ACTIVATION);
policies[2] = rootPOA->create_lifespan_policy (
PortableServer::TRANSIENT);
PortableServer::POA_var fooPoa = rootPOA->create_POA (
"FOO_POA", poaMgr.in (), policies );
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
policies[i]->destroy ();
}
Foo_i servant;
PortableServer::ObjectId_var oid = fooPoa->activate_object( &servant );
CORBA::Object_var obj = fooPoa->id_to_reference (oid.in ());
foo_var client = foo::_narrow (obj.in());
client->check();
if (vc_check(client.in()))
{
orb->destroy();
return 1;
}
fooPoa->deactivate_object (oid.in () ); //servant is gone
if (vc_check(client.in(), false)) //exception expected
{
orb->destroy();
return 2;
}
}
catch(...)
{
return 3;
}
return 0;
}
开发者ID:chenbk85, 项目名称:ACE-Middleware, 代码行数:69, 代码来源:bug_2826_regression.cpp
示例14: destroy
void UAKGQueryBase::destroy() throw (CORBA::SystemException)
{
PortableServer::ObjectId_var oid = getPOA_()->servant_to_id(this);
getPOA_()->deactivate_object(oid.in());
}
开发者ID:rssh, 项目名称:UAKGQuery, 代码行数:5, 代码来源:UAKGQueryBase.cpp
示例15: main
int main (int argc, char* argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Find the Naming Service.
CORBA::Object_var obj = orb->resolve_initial_references("NameService");
CosNaming::NamingContextExt_var naming_client = CosNaming::NamingContextExt::_narrow(obj.in());
// Get the Event Channel using Naming Services
obj = naming_client->resolve_str("EventService");
// Downcast the object reference to an EventChannel reference.
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow(obj.in());
if (CORBA::is_nil(ec.in())) {
cerr << "Could not resolve EchoEventChannel." << endl;
return 1;
}
// Get a SupplierAdmin object from the EventChannel.
RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers();
// Get a ProxyPushConsumer from the SupplierAdmin.
RtecEventChannelAdmin::ProxyPushConsumer_var consumer =
admin->obtain_push_consumer();
// Get the RootPOA.
obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
// Instantiate an EchoEventConsumer_i servant.
EchoEventSupplier_i servant(orb.in());
// Register it with the RootPOA.
PortableServer::ObjectId_var oid = poa->activate_object(&servant);
CORBA::Object_var supplier_obj = poa->id_to_reference(oid.in());
RtecEventComm::PushSupplier_var supplier =
RtecEventComm::PushSupplier::_narrow(supplier_obj.in());
// Publish the events the supplier provides.
ACE_SupplierQOS_Factory qos;
qos.insert (MY_SOURCE_ID, // Supplier's unique id
MY_EVENT_TYPE, // Event type
0, // handle to the rt_info structure
1); // number of calls
// Connect as a supplier of the published events.
consumer->connect_push_supplier (supplier.in (),
qos.get_SupplierQOS ());
// Activate the POA via its POAManager.
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();
// Create an event (just a string in this case).
const CORBA::String_var eventData = CORBA::string_dup("Hello, world.");
// Create an event set for one event
RtecEventComm::EventSet events (1);
events.length (1);
// Initialize event header.
events[0].header.source = MY_SOURCE_ID;
events[0].header.type = MY_EVENT_TYPE;
// Initialize data fields in event.
events[0].data.any_value <<= eventData;
cout << "Supplier starting sending of events" << endl;
while (1) {
consumer->push (events);
ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS);
orb->run(tv);
}
orb->destroy();
return 0;
}
catch (CORBA::Exception& ex)
{
cerr << "Supplier::main() Caught CORBA::Exception" << endl << ex << endl;
}
return 1;
}
开发者ID:JnS-Software-LLC, 项目名称:iiop-net, 代码行数:90, 代码来源:EchoEventSupplierMain.cpp
示例16: orb_thr
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (parse_args (argc, argv) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ERROR: wrong arguments\n")),
-1);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableGroup::GOA_var root_goa =
PortableGroup::GOA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_goa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ERROR: nil RootPOA\n")),
-1);
PortableServer::POAManager_var poa_manager = root_goa->the_POAManager ();
// Create UIPMC reference.
CORBA::Object_var obj = orb->string_to_object (uipmc_url);
// Create id.
PortableServer::ObjectId_var id =
root_goa->create_id_for_reference (obj.in ());
// Activate UIPMC Object.
UIPMC_Object_Impl* uipmc_impl;
ACE_NEW_RETURN (uipmc_impl,
UIPMC_Object_Impl (orb.in (), threads),
-1);
PortableServer::ServantBase_var owner_transfer1 (uipmc_impl);
root_goa->activate_object_with_id (id.in (), uipmc_impl);
Test::UIPMC_Object_var uipmc_obj =
Test::UIPMC_Object::_unchecked_narrow (obj.in ());
if (CORBA::is_nil (uipmc_obj.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ERROR: nil Hello object\n")),
-1);
CORBA::String_var ior = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("MIOP object is <%C>\n"), ior.in ()));
//obj = hello_impl->_this ();
// If the ior_output_file exists, output the ior to it.
if (ior_output_file != 0)
{
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 ")
ACE_TEXT ("for writing IOR: %s"),
ior_output_file),
-1);
}
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
poa_manager->activate ();
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Starting %u thread, thread pool\n"), (unsigned) threads));
// start server thread pool
OrbThread orb_thr (orb.in ());
orb_thr.activate (THR_NEW_LWP | THR_JOINABLE, threads);
orb_thr.wait ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Stopping thread pool\n")));
}
root_goa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught in server main ():");
return -1;
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("\nServer finished successfully.\n")));
return 0;
}
开发者ID:esohns, 项目名称:ATCD, 代码行数:96, 代码来源:server.cpp
示例17: 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;
CORBA::Object_var tmp =
orb->string_to_object(ior);
Test::Oneway_Buffering_Admin_var admin =
Test::Oneway_Buffering_Admin::_narrow(tmp.in ());
if (CORBA::is_nil (admin.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
"Nil Oneway_Buffering_Admin reference <%s>\n",
ior),
1);
}
Oneway_Buffering *oneway_buffering_impl;
ACE_NEW_RETURN (oneway_buffering_impl,
Oneway_Buffering (orb.in (),
admin.in ()),
1);
PortableServer::ServantBase_var owner_transfer(oneway_buffering_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (oneway_buffering_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Test::Oneway_Buffering_var oneway_buffering =
Test::Oneway_Buffering::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (oneway_buffering.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 in server:");
return 1;
}
return 0;
}
开发者ID:asdlei00, 项目名称:ACE, 代码行数:85, 代码来源:server.cpp
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:17591| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9430| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8033| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8401| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8308| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9163| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8279| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7701| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8248| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7273| 2022-11-06
请发表评论