本文整理汇总了C++中iortable::Table_var类的典型用法代码示例。如果您正苦于以下问题:C++ Table_var类的具体用法?C++ Table_var怎么用?C++ Table_var使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table_var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: catch
// Add the ObjectID:IOR mapping to the IOR table of
// the ORB. Ignore this method if you are not testing for
// the InterOperable Naming Service.
template <class Servant> int
Server<Servant>::test_for_ins (const char *ior)
{
CORBA::ORB_var orb = this->orb_manager_.orb ();
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Adding (KEY:IOR) %s:%C\n"),
this->ins_,
ior));
try
{
CORBA::Object_var table_object =
orb->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Nil IORTable\n")),
-1);
}
adapter->bind (ACE_TEXT_ALWAYS_CHAR (this->ins_), ior);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("ERROR: test_for_ins failed\n");
return -1;
}
return 0;
}
示例3: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
// Get the POA from the ORB.
CORBA::Object_var poa_obj = orb->resolve_initial_references ("RootPOA");
// Narrow to the POA interface
PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_obj.in ());
// Create a Stock Quoter implementation object
Stock_Quoter_i* stock_quoter = new Stock_Quoter_i (orb.in ());
UDPTest_i* UDP = new UDPTest_i ();
// Activate the Stock Quoter in the RootPOA.
PortableServer::ObjectId_var oid = root_poa->activate_object (stock_quoter);
CORBA::Object_var sq_obj = root_poa->id_to_reference (oid.in());
PortableServer::ObjectId_var oid1 = root_poa->activate_object (UDP);
CORBA::Object_var udp_obj1 = root_poa->id_to_reference (oid1.in());
CORBA::String_var ior =
orb->object_to_string (udp_obj1.in ());
ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));
// Also make the Stock Quoter object available via corbaloc
// ObjectURL by binding it to a simple ObjectKey in the IORTable.
CORBA::Object_var table_obj = orb->resolve_initial_references ("IORTable");
IORTable::Table_var table = IORTable::Table::_narrow (table_obj.in());
CORBA::String_var quoter_ior_string = orb->object_to_string (sq_obj.in());
CORBA::String_var UDP_ior_string = orb->object_to_string (udp_obj1.in());
table->bind ("UDPTest", UDP_ior_string.in());
table->bind ("MyStockQuoter", quoter_ior_string.in());
// Activate the POA Manager
PortableServer::POAManager_var poa_mgr = root_poa->the_POAManager ();
poa_mgr->activate ();
cout << "Server ready" << endl;
orb->run ();
if (!UDP->received_send_)
{
ACE_ERROR_RETURN ((LM_ERROR, "Not received send\n"), 1);
}
}
catch (const CORBA::Exception& e)
{
e._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例4: Test_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("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
PortableServer::POAManager_var mgr = root_poa->the_POAManager();
const char* poa_name = "TestService";
PortableServer::POA_var test_poa = createPOA(root_poa.in(), poa_name);
Terminator terminator;
if (terminator.open (0) == -1)
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT ("main Error opening terminator\n")),-1);
PortableServer::Servant_var<Test_i> test_servant =
new Test_i(terminator);
PortableServer::ObjectId_var object_id =
PortableServer::string_to_ObjectId("test_object");
test_poa->activate_object_with_id(object_id.in(), test_servant.in());
TAO_Root_POA* tpoa = dynamic_cast<TAO_Root_POA*>(test_poa.in());
obj = tpoa->id_to_reference_i(object_id.in(), false);
CORBA::String_var test_ior = orb->object_to_string(obj.in());
obj = orb->resolve_initial_references("IORTable");
IORTable::Table_var table = IORTable::Table::_narrow(obj.in());
table->bind(poa_name, test_ior.in());
mgr->activate();
std::cout << "Test server ready." << std::endl;
orb->run();
std::cout << "Test server shutting down." << std::endl;
root_poa->destroy(1,1);
orb->destroy();
ACE_Message_Block *mb;
ACE_NEW_RETURN(mb, ACE_Message_Block(0, ACE_Message_Block::MB_HANGUP), -1);
terminator.putq(mb);
terminator.wait();
}
catch(const CORBA::Exception& ex) {
std::cerr << "Server main() Caught CORBA::Exception" << ex << std::endl;
return 1;
}
return 0;
}
示例5: catch
int
TAO_Naming_Server::fini (void)
{
// First get rid of the multi cast handler
if (this->ior_multicast_)
{
orb_->orb_core()->reactor ()->remove_handler (this->ior_multicast_,
ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL);
delete this->ior_multicast_;
this->ior_multicast_ = 0;
}
// Destroy the child POA ns_poa that is created when initializing
// the Naming Service
try
{
if (!CORBA::is_nil (this->ns_poa_.in ()))
this->ns_poa_->destroy (1, 1);
CORBA::Object_var table_object =
this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n"));
}
else
{
adapter->unbind ("NameService");
}
#if !defined (CORBA_E_MICRO)
CORBA::Object_var svc =
this->orb_->unregister_initial_reference ("NameService");
#endif /* CORBA_E_MICRO */
}
catch (const CORBA::Exception&)
{
// Ignore
}
naming_context_ = CosNaming::NamingContext::_nil ();
ns_poa_ = PortableServer::POA::_nil ();
root_poa_ = PortableServer::POA::_nil ();
orb_ = CORBA::ORB::_nil ();
#if !defined (CORBA_E_MICRO)
delete this->context_index_;
#endif /* CORBA_E_MICRO */
return 0;
}
示例6: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
//init the orb
CORBA::ORB_var orb=CORBA::ORB_init(argc, argv);
//get the root poa
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 ();
if (parse_args (argc, argv) != 0)
return 1;
poa_manager->activate ();
// Get a reference to the IOR Table
CORBA::Object_var tobj = orb->resolve_initial_references("IORTable");
IORTable::Table_var table = IORTable::Table::_narrow(tobj.in());
//get an object id for the name
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("Messenger");
//activate the object for the given id
Messenger_i messenger (orb.in ());
poa->activate_object_with_id(oid.in (), &messenger);
CORBA::Object_var messenger_obj = poa->id_to_reference (oid.in ());
//bind the ior string to the name
CORBA::String_var messenger_ior_string = orb->object_to_string(messenger_obj.in());
table->bind("Messenger", messenger_ior_string.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\n",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", messenger_ior_string.in ());
ACE_OS::fclose (output_file);
orb->run ();
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例7: tie_safety
int
TAO_IFR_Server::create_repository (void)
{
TAO_ComponentRepository_i *impl = 0;
ACE_NEW_THROW_EX (
impl,
TAO_ComponentRepository_i (
this->orb_.in (),
this->root_poa_,
this->config_
),
CORBA::NO_MEMORY ()
);
auto_ptr<TAO_ComponentRepository_i> safety (impl);
TAO_IFR_Service_Utils::repo_ = impl;
POA_CORBA::ComponentIR::Repository_tie<TAO_ComponentRepository_i> *impl_tie
= 0;
ACE_NEW_THROW_EX (
impl_tie,
POA_CORBA::ComponentIR::Repository_tie<TAO_ComponentRepository_i> (
impl,
this->repo_poa_,
1
),
CORBA::NO_MEMORY ()
);
PortableServer::ServantBase_var tie_safety (impl_tie);
safety.release ();
this->repo_poa_->set_servant (impl_tie);
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("");
CORBA::Object_var obj =
this->repo_poa_->create_reference_with_id (
oid.in (),
"IDL:omg.org/CORBA/ComponentIR/ComponentRepository:1.0"
);
CORBA::Repository_ptr repo_ref =
CORBA::Repository::_narrow (obj.in ());
// Initialize the repository.
int status = impl->repo_init (repo_ref,
this->repo_poa_);
if (status != 0)
{
return -1;
}
// Save and output the IOR string.
this->ifr_ior_ =
this->orb_->object_to_string (repo_ref);
CORBA::Object_var table_object =
this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
ORBSVCS_ERROR_RETURN ((LM_ERROR, "Nil IORTable\n"), -1);
}
else
{
adapter->bind ("InterfaceRepository",
this->ifr_ior_.in ());
}
// Add the repository to the ORB's table of initialized object references.
this->orb_->register_initial_reference ("InterfaceRepository",
repo_ref);
// Write our IOR to a file.
FILE *output_file_ =
ACE_OS::fopen (OPTIONS::instance ()->ior_output_file (),
ACE_TEXT ("w"));
if (output_file_ == 0)
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("TAO_IFR_Server::create_repository - ")
ACE_TEXT ("can't open IOR output ")
ACE_TEXT ("file for writing\n")),
-1);
}
ACE_OS::fprintf (output_file_,
"%s\n",
this->ifr_ior_.in ());
//.........这里部分代码省略.........
示例8: if
int
TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[])
{
// Check if -ORBDaemon is specified and if so, daemonize at this moment,
// -ORBDaemon in the ORB core is faulty, see bugzilla 3335
TAO_Daemon_Utility::check_for_daemon (argc, argv);
if (this->parse_args(argc, argv) != 0)
return -1;
// initalize the ORB.
if (this->init_ORB (argc, argv) != 0)
return -1;
this->notify_service_ = TAO_Notify_Service::load_default ();
if (this->notify_service_ == 0)
{
if (TAO_debug_level > 0)
{
ORBSVCS_ERROR ((LM_ERROR,
ACE_TEXT ("Service not found. Check service ")
ACE_TEXT ("configurator file.\n")));
}
return -1;
}
if (this->separate_dispatching_orb_)
{
if (this->init_dispatching_ORB (argc, argv) != 0)
{
return -1;
}
this->notify_service_->init_service2 (this->orb_.in (), this->dispatching_orb_.in());
}
else
{
this->notify_service_->init_service (this->orb_.in ());
}
this->logging_worker_.start();
if (this->nthreads_ > 0) // we have chosen to run in a thread pool.
{
if (TAO_debug_level > 0)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT("Running %d ORB threads\n"),
this->nthreads_));
}
worker_.orb (this->orb_.in ());
// Task activation flags.
long const flags =
THR_NEW_LWP |
THR_JOINABLE |
this->orb_->orb_core ()->orb_params ()->thread_creation_flags ();
int const priority =
ACE_Sched_Params::priority_min (ACE_Utils::truncate_cast<ACE_Sched_Params::Policy> (this->orb_->orb_core ()->orb_params ()->sched_policy ()),
ACE_Utils::truncate_cast<int> (this->orb_->orb_core ()->orb_params ()->scope_policy ()));
if (worker_.activate (flags,
this->nthreads_, 0, priority) != 0)
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"Cannot activate client threads\n"), -1);
}
}
// Check first if the naming service
if (this->use_name_svc_)
{
// Resolve the naming service.
int const ns_ret = this->resolve_naming_service ();
if (ns_ret != 0)
return -1;
}
if (TAO_debug_level > 0)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT("\nStarting up the Notification Service...\n")));
}
// Activate the factory
this->notify_factory_ =
notify_service_->create (this->poa_.in (),
this->notify_factory_name_.c_str ());
ACE_ASSERT (!CORBA::is_nil (this->notify_factory_.in ()));
if (this->bootstrap_) // Enable corbaloc usage
{
CORBA::Object_var table_object =
this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
//.........这里部分代码省略.........
示例9: main
int main(int argc, char *argv[])
{
int c, instance = -1;
ACE_CString daemonRef;
ACE_CString hostName;
ACE_CString additional;
for (;;) {
int option_index = 0;
c = getopt_long(argc, argv, "hi:d:H:a:",
long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 'h':
usage(argv[0]);
return 0;
case 'i':
instance = ACE_OS::atoi(optarg);
break;
case 'd':
daemonRef = optarg;
break;
case 'H':
hostName = optarg;
break;
case 'a':
additional = optarg;
break;
}
}
if (instance == -1) {
ACE_OS::printf("Error: instance is a mandatory option try %s -h\n",
argv[0]);
return -1;
}
#define DEFAULT_LOG_FILE_NAME "acs_local_log"
ACE_CString daemonsLogFileName = getTempFileName(0, DEFAULT_LOG_FILE_NAME);
// replace "ACS_INSTANCE.x" with "acsdaemonStartAcs_" + <timestamp>
ACE_CString daemonsDir = "acsdaemonStartAcs_" + getStringifiedTimeStamp();
ACE_CString instancePart("ACS_INSTANCE.");
ACE_CString::size_type pos = daemonsLogFileName.find(instancePart);
daemonsLogFileName =
daemonsLogFileName.substring(0, pos) +
daemonsDir +
daemonsLogFileName.substring(pos + instancePart.length() + 1); // +1 for skipping instance number
ACE_OS::setenv("ACS_LOG_FILE", daemonsLogFileName.c_str(), 1);
LoggingProxy *logger = new LoggingProxy(0, 0, 31);
if (logger) {
LoggingProxy::init(logger);
LoggingProxy::ProcessName(argv[0]);
LoggingProxy::ThreadName("main");
} else
ACS_SHORT_LOG((LM_INFO, "Failed to initialize logging."));
StartCallback* sc = new StartCallback();
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "TAO");
// get a reference to the RootPOA
CORBA::Object_var pobj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(pobj.in());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
// create policies
CORBA::PolicyList policy_list;
policy_list.length(5);
policy_list[0] = root_poa->create_request_processing_policy(PortableServer::USE_DEFAULT_SERVANT);
policy_list[1] = root_poa->create_id_uniqueness_policy(PortableServer::MULTIPLE_ID);
policy_list[2] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
policy_list[3] = root_poa->create_servant_retention_policy(PortableServer::NON_RETAIN);
policy_list[4] = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
// create a ACSDaemon POA with policies
PortableServer::POA_var poa = root_poa->create_POA("DaemonCallback", poa_manager.in(), policy_list);
// destroy policies
for (CORBA::ULong i = 0; i < policy_list.length(); ++i)
{
CORBA::Policy_ptr policy = policy_list[i];
policy->destroy();
}
// set as default servant
poa->set_servant(sc);
// create reference
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId("DaemonCallback");
pobj = poa->create_reference_with_id (oid.in(), sc->_interface_repository_id());
CORBA::String_var m_ior = orb->object_to_string(pobj.in());
// bind to IOR table
CORBA::Object_var table_object = orb->resolve_initial_references("IORTable");
IORTable::Table_var adapter = IORTable::Table::_narrow(table_object.in());
//.........这里部分代码省略.........
示例10: server_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");
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) Unable to initialize the POA.\n"),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
if (parse_args (argc, argv) != 0)
return 1;
Simple_Server_i server_impl (orb.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (&server_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Simple_Server_var server =
Simple_Server::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (server.in ());
CORBA::Object_var table_object =
orb->resolve_initial_references("IORTable");
IORTable::Table_var table =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (table.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize the IORTable.\n"),
1);
table->bind ("Simple_Server", ior.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);
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;
}
示例11: 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;
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 ());
CORBA::Object_var tmp = orb->resolve_initial_references("IORTable");
IORTable::Table_var iorTable = IORTable::Table::_narrow(tmp.in ());
if (CORBA::is_nil(iorTable.in ()))
{
ACE_ERROR ((LM_ERROR, "could not get the IORTable, will not register\n"));
}
else
{
iorTable->rebind("Hello", ior.in());
}
// try and access the object with its friendly name
ACE_CString full_corbaloc (ior.in (), 0, 1);
CORBA::ULong first_slash = full_corbaloc.find ("/", 0);
ACE_CString friendly_corbaloc =
full_corbaloc.substring (0,
first_slash);
friendly_corbaloc += "/Hello";
// 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\n",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", friendly_corbaloc.c_str ());
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;
}
示例12: Hello
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);
Hello *hello_impl = 0;
ACE_NEW_RETURN (hello_impl,
Hello (orb.in ()),
1);
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::Object_var table_obj = orb->resolve_initial_references("IORTable");
IORTable::Table_var table = IORTable::Table::_narrow(table_obj.in());
for (int i = 1; i <= cache_size; ++i)
{
CORBA::String_var ior_string = orb->object_to_string (object.in());
ACE_DEBUG((LM_DEBUG, ACE_TEXT("Registering object %d with IOR string: %C\n"),
i, ior_string.in ()));
char identifier[256];
ACE_OS::sprintf (identifier, "TransportCacheTest%d", i);
table->bind(identifier, ior_string.in());
}
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
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;
}
示例13: directory
//.........这里部分代码省略.........
// Set the root Naming Context reference.
this->naming_context_ =
this->context_index_->root_context ();
}
else
#endif /* CORBA_E_MICRO */
{
//
// Initialize Transient Naming Service.
//
this->naming_context_ =
TAO_Transient_Naming_Context::make_new_context (poa,
TAO_ROOT_NAMING_CONTEXT,
context_size);
}
#if !defined (CORBA_E_MICRO)
// Register with the ORB's resolve_initial_references()
// mechanism. Primarily useful for dynamically loaded Name
// Services.
orb->register_initial_reference ("NameService",
this->naming_context_.in ());
#endif /* CORBA_E_MICRO */
// Set the ior of the root Naming Context.
this->naming_service_ior_=
orb->object_to_string (this->naming_context_.in ());
CORBA::Object_var table_object =
orb->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n"));
}
else
{
CORBA::String_var ior =
orb->object_to_string (this->naming_context_.in ());
adapter->bind ("NameService", ior.in ());
}
#if defined (ACE_HAS_IP_MULTICAST)
if (enable_multicast)
{
// @@ Marina: is there anyway to implement this stuff
// without using ORB_Core_instance()? For example can you
// pass the ORB as an argument?
//
// Install ior multicast handler.
//
// Get reactor instance from TAO.
ACE_Reactor *reactor = orb->orb_core()->reactor ();
// See if the -ORBMulticastDiscoveryEndpoint option was specified.
ACE_CString mde (orb->orb_core ()->orb_params ()->mcast_discovery_endpoint ());
// First, see if the user has given us a multicast port number
// on the command-line;
u_short port =
orb->orb_core ()->orb_params ()->service_port (TAO::MCAST_NAMESERVICE);
示例14: owner_transfer
int
TAO_MonitorManager::ORBTask::svc (void)
{
try
{
if (CORBA::is_nil (this->orb_.in ()))
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"(%P|%t) TAO_MonitorManager: Unable to "
"initialize the ORB\n"),
1);
}
PortableServer::POA_var poa;
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->mutex_, -1);
CORBA::Object_var obj =
this->orb_->resolve_initial_references ("RootPOA");
poa = PortableServer::POA::_narrow (obj.in ());
if (CORBA::is_nil (poa.in ()))
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"(%P|%t) TAO_MonitorManager: Unable to "
"resolve the RootPOA\n"),
1);
}
PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
poa_manager->activate ();
// Activate the object
NotificationServiceMonitor_i* servant;
ACE_NEW_RETURN (servant,
NotificationServiceMonitor_i (this->orb_.in ()), 1);
PortableServer::ServantBase_var owner_transfer(servant);
PortableServer::ObjectId_var id = poa->activate_object (servant);
// Register the object with the IORTable
obj = poa->id_to_reference (id.in ());
CosNotification::NotificationServiceMonitorControl_var monitor =
CosNotification::NotificationServiceMonitorControl::_narrow (obj.in ());
CORBA::String_var ior = this->orb_->object_to_string (monitor.in ());
obj = this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var iortable = IORTable::Table::_narrow (obj.in ());
if (CORBA::is_nil (iortable.in ()))
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"(%P|%t) TAO_MonitorManager: Unable to "
"resolve the IORTable\n"),
1);
}
iortable->bind(ACE_TEXT_ALWAYS_CHAR(mc_orb_name_.c_str()), ior.in ());
if (this->use_name_svc_)
{
TAO_Naming_Client nc;
nc.init (this->orb_.in ());
CosNaming::Name name (1);
name.length (1);
name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(mc_orb_name_.c_str()));
nc->rebind (name, monitor.in ());
}
if (this->ior_output_.length () > 0)
{
FILE* fp = ACE_OS::fopen (this->ior_output_.c_str (), "w");
if (fp == 0)
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) TAO_MonitorManager: "
ACE_TEXT ("Unable to write to %s\n")),
this->ior_output_.c_str ()),
1);
}
else
{
ACE_OS::fprintf (fp, "%s", ior.in ());
ACE_OS::fclose (fp);
}
}
}
// R1: race condition (partially fixed):
// TAO_MonitorManager::fini() is called directly after
// TAO_MonitorManager::run(), the shutdown call on the ORB could
// happen but the ORB::run() loop won't exit.
startup_barrier_.wait ();
this->orb_->run ();
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->mutex_, -1);
// Destroy the POA and ORB
if (!CORBA::is_nil (poa.in ()))
//.........这里部分代码省略.........
示例15: INTERNAL
int
Server_i::init (int &argc,
ACE_TCHAR **argv)
{
this->argc_ = argc;
this->argv_ = argv;
try
{
// First initialize the ORB, that will remove some arguments...
this->orb_ =
CORBA::ORB_init (this->argc_, this->argv_);
// Get a reference to the RootPOA.
CORBA::Object_var poa_object =
this->orb_->resolve_initial_references ("RootPOA");
// Narrow down to the correct reference.
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in ());
// Set a POA Manager.
PortableServer::POAManager_var poa_manager =
poa->the_POAManager ();
// Activate the POA Manager.
poa_manager->activate ();
CORBA::String_var ior;
// Create the servant
MCast_Server_i server_i;
// Activate it to obtain the reference
MCast::Server_var mcast_server =
server_i._this ();
CORBA::Object_var table_object =
this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
IORTable::Table::_narrow (table_object.in ());
if (CORBA::is_nil (adapter.in ()))
{
ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
}
else
{
ior =
this->orb_->object_to_string (mcast_server.in ());
adapter->bind ("MCASTServer", ior.in ());
}
// Enable such that the server can listen for multicast requests
// at the specified address.
if (this->enable_multicast (ior.in ()) != 0)
{
ACE_ERROR ((LM_ERROR,
"ERROR: Unable to enable multicast "
"on specified address.\n"));
throw CORBA::INTERNAL ();
}
// Run the ORB
this->orb_->run ();
//Destroy the POA, waiting until the destruction terminates.
poa->destroy (1, 1);
this->orb_->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("client");
return 1;
}
return 0;
}