本文整理汇总了C++中iortable::Table_var::in方法的典型用法代码示例。如果您正苦于以下问题:C++ Table_var::in方法的具体用法?C++ Table_var::in怎么用?C++ Table_var::in使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iortable::Table_var
的用法示例。
在下文中一共展示了Table_var::in方法的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: 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;
}
示例4: directory
int
TAO_Naming_Server::init_new_naming (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
const ACE_TCHAR *persistence_location,
void *base_addr,
size_t context_size,
int enable_multicast,
int use_storable_context,
int round_trip_timeout,
int use_round_trip_timeout)
{
try
{
#if defined (CORBA_E_MICRO)
ACE_UNUSED_ARG (persistence_location);
ACE_UNUSED_ARG (base_addr);
ACE_UNUSED_ARG (use_storable_context);
#else
if (use_storable_context)
{
// In lieu of a fully implemented service configurator version
// of this Reader and Writer, let's just take something off the
// command line for now.
TAO::Storable_Factory* pf = 0;
ACE_CString directory (ACE_TEXT_ALWAYS_CHAR (persistence_location));
ACE_NEW_RETURN (pf, TAO::Storable_FlatFileFactory (directory), -1);
auto_ptr<TAO::Storable_Factory> persFactory(pf);
// Use an auto_ptr to ensure that we clean up the factory in the case
// of a failure in creating and registering the Activator.
TAO_Storable_Naming_Context_Factory* cf =
this->storable_naming_context_factory (context_size);
// Make sure we got a factory
if (cf == 0) return -1;
auto_ptr<TAO_Storable_Naming_Context_Factory> contextFactory (cf);
// This instance will either get deleted after recreate all or,
// in the case of a servant activator's use, on destruction of the
// activator.
// Was a location specified?
if (persistence_location == 0)
{
// No, assign the default location "NameService"
persistence_location = ACE_TEXT ("NameService");
}
// Now make sure this directory exists
if (ACE_OS::access (persistence_location, W_OK|X_OK))
{
ORBSVCS_ERROR_RETURN ((LM_ERROR, "Invalid persistence directory\n"), -1);
}
#if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
if (this->use_servant_activator_)
{
ACE_NEW_THROW_EX (this->servant_activator_,
TAO_Storable_Naming_Context_Activator (orb,
persFactory.get(),
contextFactory.get (),
persistence_location),
CORBA::NO_MEMORY ());
this->ns_poa_->set_servant_manager(this->servant_activator_);
}
#endif /* TAO_HAS_MINIMUM_POA */
try { // The following might throw an exception.
this->naming_context_ =
TAO_Storable_Naming_Context::recreate_all (orb,
poa,
TAO_ROOT_NAMING_CONTEXT,
context_size,
0,
contextFactory.get (),
persFactory.get (),
use_redundancy_);
}
catch (const CORBA::Exception& ex)
{
// The activator already took over the factories so we need to release the auto_ptr
if (this->use_servant_activator_)
{
// The context factory is now owned by the activator
// so we should release it
contextFactory.release ();
// If using a servant activator, the activator now owns the
// factory, so we should release it
persFactory.release ();
}
// Print out the exception and return failure
ex._tao_print_exception (
"TAO_Naming_Server::init_new_naming");
return -1;
}
// Kind of a duplicate of the above here, but we must also release the
// factory autoptrs in the good case as well.
if (this->use_servant_activator_)
{
// The context factory is now owned by the activator
// so we should release it
//.........这里部分代码省略.........
示例5: 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;
}
示例6: safe_svt
CORBA::Object_ptr
DAnCE_TargetManager_Module::init (CORBA::ORB_ptr orb,
int argc,
ACE_TCHAR *argv[])
{
DANCE_TRACE ("DAnCE_TargetManager_Module::init");
try
{
if (CORBA::is_nil(orb))
{
DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("Attempted to create Target Manager with a nil orb.\n")));
return CORBA::Object::_nil();
}
else
{
this->orb_ = CORBA::ORB::_duplicate (orb);
}
if (ACE_OS::strcmp(orb->id(), this->orb_->id()) != 0)
{
DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("Resetting TM's orb.\n")));
this->orb_ = CORBA::ORB::_duplicate (orb);
this->domain_nc_ = CosNaming::NamingContext::_nil();
}
if (!this->parse_args (argc, argv))
{
return CORBA::Object::_nil ();
}
this->create_poas ();
if (this->options_.domain_nc_)
{
try
{
DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("Resolving DomainNC.\n")));
CORBA::Object_var domain_obj = this->orb_->string_to_object (this->options_.domain_nc_);
if (!CORBA::is_nil (domain_obj.in ()))
{
this->domain_nc_ = CosNaming::NamingContext::_narrow (domain_obj.in());
if (CORBA::is_nil (this->domain_nc_.in ()))
{
DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR,DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("Narrow to NamingContext return nil for DomainNC.\n")));
return CORBA::Object::_nil ();
}
}
}
catch (CORBA::Exception&)
{
DANCE_DEBUG (DANCE_LOG_ERROR,
(LM_WARNING, DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("DomainNC context not found!\n")));
}
}
DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("Initializing the IOR Table\n")));
// Initialize IOR table
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 ()))
{
DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_TargetManager_Module::init - ")
ACE_TEXT ("Unable to RIR the IORTable.\n")));
return CORBA::Object::_nil ();
}
//Creating repository manager servant
DAnCE::TargetManagerDaemon_i * rm = new DAnCE::TargetManagerDaemon_i (orb);
PortableServer::ServantBase_var safe_svt (rm);
ACE_CString repository_manager_oid;
if (this->options_.name_ == 0)
{
repository_manager_oid = "TargetManager";
}
else
{
repository_manager_oid = ACE_TEXT_ALWAYS_CHAR (this->options_.name_);
repository_manager_oid += ".TargetManager";
}
// Registering servant in poa
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId (repository_manager_oid.c_str());
this->rm_poa_->activate_object_with_id (oid, rm);
// Getting repository manager ior
//.........这里部分代码省略.........
示例7: 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"));
// If expect_servant_calls is 0, it means it's the request forward looping case so the
// servant continue receiving calls from a single request. We can not determine how many
// servant calls but it should be more than the number of requests.
if ((expect_servant_calls == 0 && (server_impl.ncalls () > num_requests))
|| (expect_servant_calls > 0 && (server_impl.ncalls () == expect_servant_calls)))
{
return 0;
}
else
ACE_ERROR_RETURN ((LM_ERROR,
"server: Test failed - expected %d servant calls but got %d calls \n",
expect_servant_calls, server_impl.ncalls ()),
1);
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
示例8: 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());
//.........这里部分代码省略.........
示例9: 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 ());
//.........这里部分代码省略.........
示例10: 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;
MyInterfaceImpl *test_impl = 0;
ACE_NEW_RETURN (test_impl,
MyInterfaceImpl (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 ());
MyInterface_var test_ref =
MyInterface::_narrow (object.in ());
CORBA::String_var ior =
orb->object_to_string (test_ref.in ());
// Output the IOR to the <ior_output_file>
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file != 0)
{
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
poa_manager->activate ();
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 ((LM_ERROR, "Nil IORTable\n"));
}
else
{
adapter->bind ("collocated_ior_bound_in_remote_iortable",
ACE_TEXT_ALWAYS_CHAR(client_ior));
}
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: 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 =
//.........这里部分代码省略.........
示例12: 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 ()))
//.........这里部分代码省略.........
示例13: policies
int
Airplane_Server_i::init (int argc, ACE_TCHAR** argv)
{
try
{
// Initialize the ORB
this->orb_ = CORBA::ORB_init (argc, argv);
// Save pointers to the command line arguments
this->argc_ = argc;
this->argv_ = argv;
// Now check the arguments for our options
int retval = this->parse_args ();
if (retval != 0)
return retval;
// Get the POA from the ORB.
CORBA::Object_var obj =
this->orb_->resolve_initial_references ("RootPOA");
ACE_ASSERT(! CORBA::is_nil (obj.in ()));
// Narrow the object to a POA.
root_poa_ = PortableServer::POA::_narrow (obj.in ());
// Get the POA_Manager.
this->poa_manager_ = this->root_poa_->the_POAManager ();
// We now need to create a POA with the persistent and user_id policies,
// since they are need for use with the Implementation Repository.
CORBA::PolicyList policies (2);
policies.length (2);
policies[0] =
this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID);
policies[1] =
this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT);
// Since the Implementation Repository keys off of the POA name, we need
// to use the server_name_ as the POA's name.
this->airplane_poa_ =
this->root_poa_->create_POA (this->server_name_.c_str(),
this->poa_manager_.in (),
policies);
// Creation of the new POA is over, so destroy the Policy_ptr's.
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
ACE_NEW_RETURN (this->server_impl_, Airplane_i, -1);
PortableServer::ObjectId_var server_id =
PortableServer::string_to_ObjectId ("server");
this->airplane_poa_->activate_object_with_id (server_id.in (),
this->server_impl_);
obj = this->airplane_poa_->id_to_reference (server_id.in ());
CORBA::String_var ior =
this->orb_->object_to_string (obj.in ());
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "The ImRified IOR is: <%C>\n", ior.in ()));
TAO_Root_POA* tmp_poa = dynamic_cast<TAO_Root_POA*>(airplane_poa_.in());
obj = tmp_poa->id_to_reference_i (server_id.in (), false);
CORBA::String_var plain_ior =
this->orb_->object_to_string (obj.in ());
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "The plain IOR is: <%C>\n", plain_ior.in ()));
// Note : The IORTable will only be used for those clients who try to
// invoke indirectly using a simple object_key reference
// like "corbaloc::localhost:8888/airplane_server".
obj = this->orb_->resolve_initial_references ("IORTable");
IORTable::Table_var adapter =
IORTable::Table::_narrow (obj.in ());
ACE_ASSERT(! CORBA::is_nil (adapter.in ()));
adapter->bind (this->server_name_.c_str(), plain_ior.in ());
this->poa_manager_->activate ();
if (this->ior_output_file_)
{
ACE_OS::fprintf (this->ior_output_file_, "%s", ior.in ());
ACE_OS::fclose (this->ior_output_file_);
}
if (this->pid_output_file_)
{
int pid = static_cast<int> (ACE_OS::getpid ());
ACE_OS::fprintf (this->pid_output_file_, "%d\n", pid);
ACE_OS::fclose (this->pid_output_file_);
}
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
CosNaming::NamingContext_var naming_context;
int nargc=0;
char **nargv=0;
const char *hn=ACSPorts::getIP();
ACE_CString iorFile;
if (argc>=2 && !ACE_OS_String::strcmp(argv[1], "-?")) {
ACE_OS::printf ("USAGE: acsLogSvc [-ORBInitRef NameService=iiop://yyy:xxxx/NameService] [-ORBEndpoint iiop://ip:port] [-o iorfile] [-silent]\n");
return -1;
}
// here we have to unset ACS_LOG_CENTRAL that we prevent filtering of log messages
char *logCent=getenv("ACS_LOG_CENTRAL");
if (logCent)
{
unsetenv("ACS_LOG_CENTRAL");
printf("Unset ACS_LOG_CENTRAL which was previously set to %s\n", logCent);
}//if
// create logging proxy
LoggingProxy::ProcessName(argv[0]);
ACE_Log_Msg::instance()->local_host(hn);
LoggingProxy m_logger (0, 0, 31, 0);
LoggingProxy::init (&m_logger);
ACS_SHORT_LOG((LM_INFO, "Logging proxy successfully created !"));
ACE_CString argStr;
for(int i=1; i<argc; i++)
{
argStr += argv[i];
argStr += " ";
if (!ACE_OS_String::strcmp(argv[i], "-o") && (i+1)<argc)
{
iorFile = argv[i+1];
}//if
}//for
if (argStr.find ("-ORBEndpoint")==ACE_CString::npos)
{
argStr = argStr + "-ORBEndpoint iiop://" + hn + ":" + ACSPorts::getLogPort().c_str();
}
ACS_SHORT_LOG((LM_INFO, "New command line is: %s", argStr.c_str()));
ACE_OS::string_to_argv ((ACE_TCHAR*)argStr.c_str(), nargc, nargv);
ACE_OS::signal(SIGINT, TerminationSignalHandler); // Ctrl+C
ACE_OS::signal(SIGTERM, TerminationSignalHandler); // termination request
try
{
// Initialize the ORB
ACE_OS::printf ("Initialising ORB ... \n");
orb = CORBA::ORB_init (nargc, nargv, 0);
ACE_OS::printf ("ORB initialsed !\n");
}
catch( CORBA::Exception &ex )
{
ex._tao_print_exception("Failed to initalise ORB");
return -1;
}
if (!ACSError::init(orb.in()))
{
ACS_SHORT_LOG ((LM_ERROR, "Failed to initalise the ACS Error System"));
return -1;
}
// resolve naming service
try
{
ACS_SHORT_LOG((LM_INFO, "Trying to connect to the Naming Service ...."));
CORBA::Object_var naming_obj = orb->resolve_initial_references ("NameService");
if (!CORBA::is_nil (naming_obj.in ()))
{
naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ());
ACS_SHORT_LOG((LM_INFO, "Connected to the Name Service"));
}
else
{
ACS_SHORT_LOG((LM_ERROR, "Could not connect the Name Service!"));
return -1;
}//if-else
}
catch( CORBA::Exception &_ex )
{
ACS_SHORT_LOG((LM_ERROR, "Could not connect the Name Service!"));
return -1;
}
// logging service
try
//.........这里部分代码省略.........
示例15: bindServiceObject
bool ServiceOptions::bindServiceObject(CORBA::ORB_ptr orb,
CORBA::Object_ptr object,
PortableServer::Servant p_servant,
const char* objName,
bool rebind)
{
if(is_set("with-naming")) {
CosNaming::Name name;
name.length(1);
name[0].id=CORBA::string_dup(objName);
name[0].kind=CORBA::string_dup("");
CORBA::Object_var obj ;
try {
obj = orb->resolve_initial_references("NameService");
}catch(const CORBA::ORB::InvalidName& ex){
std::cerr << argv()[0] << ": can't resolve `NameService'" << std::endl;
return false;
}
CosNaming::NamingContext_var nc;
try {
nc = CosNaming::NamingContext::_narrow(obj.in());
}catch(const CORBA::SystemException& ex){
std::cerr << argv()[0] << ": can't narrow naming service" << std::endl;
return false;
}
try {
if(rebind){
nc->rebind(name,object);
}else{
try{
nc->bind(name,object);
}catch(const CosNaming::NamingContext::AlreadyBound&){
std::cerr<<argv()[0]<<":can't bind "<<objName<<" (AlreadyBound)"<< std::endl;
return false;
}
}
}catch(const CosNaming::NamingContext::CannotProceed&){
std::cerr<<argv()[0]<<": can't bind "<<objName<<" (CannotProceed)"<< std::endl;
return false;
}catch(const CosNaming::NamingContext::InvalidName&){
std::cerr<<argv()[0]<<":can't bind "<<objName<<" (InvalidName)"<< std::endl;
return false;
}
std::cout<<argv()[0]<<": binding completed successfully"<<std::endl;
}
CORBA::String_var ior ;
try {
ior = orb->object_to_string(object);
}catch(const CORBA::SystemException& ex){
#ifdef CORBA_SYSTEM_EXCEPTION_IS_STREAMBLE
std::cerr << ex << std::endl;
#else
std::cerr << "CORBA::SystemException" << std::endl;
#endif
return false;
}
const char* fname = get_ior_fname(objName);
if (fname!=NULL && strcmp(fname,"")!=0) {
std::ofstream ofs (fname);
if (ofs.bad()) {
std::cerr << argv()[0] << ": can't open file " << fname << std::endl;
perror(argv()[0]);
return false;
}
ofs << ior.in();
ofs.close();
}
if (is_set("ior-stdout")) {
std::cout << ior << std::flush;
}
#ifdef ORBACUS
CORBA::Object_var bmgrObj = orb->resolve_initial_references("BootManager");
OB::BootManager_var bootManager = OB::BootManager::_narrow(bmgrObj);
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId(objName);
bootManager -> add_binding(oid.in(),object);
#elif defined(OMNIORB)
PortableServer::POA_var objPOA = p_servant->_default_POA();
CORBA::String_var objPOAName = objPOA->the_name();
if (strcmp(objPOAName.in(),"omniINSPOA")!=0) {
CORBA::Object_var insPOAObj = orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var insPOA = PortableServer::POA::_narrow(insPOAObj);
PortableServer::POAManager_var insPOAManager=insPOA->the_POAManager();
insPOAManager->activate();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId(objName);
insPOA->activate_object_with_id(oid.in(),p_servant);
}
#elif defined(RSSH_TAO)
#ifdef TAO_HAVE_IORTABLE_ADAPTER
CORBA::Object_var table = orb->resolve_initial_references ("IORTable");
IORTable::Table_var adapter = IORTable::Table::_narrow (table.in());
if (CORBA::is_nil(adapter.in())) {
cerr<<argv()[0]<<": nil IORTable reference"<<endl;
} else {
adapter->bind (objName, ior.in ());
}
#else
ACE_CString ins(objName);
if (orb->_tao_add_to_IOR_table(ins,object)!=0) {
return false;
//.........这里部分代码省略.........