本文整理汇总了C++中portableserver::POA_var::create_reference_with_id方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_var::create_reference_with_id方法的具体用法?C++ POA_var::create_reference_with_id怎么用?C++ POA_var::create_reference_with_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portableserver::POA_var
的用法示例。
在下文中一共展示了POA_var::create_reference_with_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
CORBA::Object_ptr TIDorb::core::poa::CurrentImpl::get_reference()
throw (PortableServer::Current::NoContext)
{
PortableServer::POA_var poa = get_POA();
PortableServer::ObjectId_var oid = get_object_id();
return poa->create_reference_with_id(oid, (const ::CORBA::RepositoryId) "IDL:omg.org/CORBA/Object:1.0");
}
示例2: ServantLocator
int
Server_i::create_locator (PortableServer::POA_var second_poa)
{
try
{
// An Servant Locator object is created which will activate
// the servant on demand.
ServantLocator *temp_servant_locator = 0;
ACE_NEW_RETURN (temp_servant_locator,
ServantLocator (orb_.in (),
ACE_TEXT ("Generic_Servant"),
ACE_TEXT ("supply_servant"),
ACE_TEXT ("destroy_servant")),
0);
// Set ServantLocator object as the servant Manager of
// secondPOA.
this->servant_locator_ = temp_servant_locator;
second_poa->set_servant_manager (this->servant_locator_);
// For the code above, we're using the CORBA 3.0 servant manager
// semantics supported by TAO. For CORBA 2.x ORBs you'd need to
// use the following code in place of the previous lines:
//
// this->servant_locator_ = temp_servant_locator->_this ();
//
// Set ServantLocator object as the servant Manager of
// secondPOA.
// second_poa->set_servant_manager (this->servant_locator_.in ()
//);
// Try to create a reference with user created ID in second_poa
// which uses ServantLocator.
PortableServer::ObjectId_var second_test_oid =
PortableServer::string_to_ObjectId ("second test");
second_test_ =
second_poa->create_reference_with_id (second_test_oid.in (),
"IDL:test:1.0");
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Server_i:create_locator ()");
return 1;
}
return 0;
}
示例3: catch
int
Server_i::create_activator (PortableServer::POA_var first_poa)
{
try
{
// An Servant Activator object is created which will activate
// the servant on-demand.
ACE_NEW_RETURN (servant_activator_impl_,
ServantActivator_i (orb_.in ()),
0);
// Set ServantActivator_i object as the servant_manager of
// firstPOA.
first_poa->set_servant_manager (servant_activator_impl_);
// For the code above, we're using the CORBA 3.0 servant manager
// semantics supported by TAO. For CORBA 2.x ORBs you'd need to
// use the following code in place of the previous line:
//
// PortableServer::ServantManager_var servant_activator =
// servant_activator_impl_->_this ();
//
// first_poa->set_servant_manager (servant_activator.in (),
//);
// Create a reference with user created ID in firstPOA which
// uses the ServantActivator. The servant dll name as well as
// the factory function in the dll are used in creating the
// objectId.
PortableServer::ObjectId_var first_test_oid =
servant_activator_impl_->create_dll_object_id ("Generic_Servant",
"create_test_i");
first_test_ = first_poa->create_reference_with_id (first_test_oid.in (),
"IDL:test:1.0");
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Server_i:create_activator ()");
return 1;
}
return 0;
}
示例4: main
//.........这里部分代码省略.........
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
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);
printf("policies are created !\n");
PortableServer::POA_var poa = root_poa->create_POA("ACSLogSvc", poa_manager.in(), policy_list);
ACE_OS::printf("POA created !\n");
for (CORBA::ULong i = 0; i < policy_list.length (); ++i) {
CORBA::Policy_ptr policy = policy_list[i];
policy->destroy ();
}
printf("Policies are destroyed !\n");
ACSLogImpl acsLogSvc (m_logger);
poa->set_servant (&acsLogSvc);
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("ACSLogSvc");
obj = poa->create_reference_with_id (oid.in(), acsLogSvc._interface_repository_id());
CORBA::String_var ior = orb->object_to_string (obj.in());
// if ther is file name write ior in it
if (iorFile.length()!=0)
{
FILE *output_file = ACE_OS::fopen (iorFile.c_str(), "w");
if (output_file == 0)
{
ACS_SHORT_LOG ((LM_ERROR,
"Cannot open output files for writing IOR: ior.ior"));
return -1;
}//if
int result = ACE_OS::fprintf (output_file, "%s", ior.in());
if (result < 0)
{
ACS_SHORT_LOG ((LM_ERROR,
"ACE_OS::fprintf failed while writing %s to ior.ior", ior.in()));
return -1;
}//if
ACE_OS::fclose (output_file);
ACS_SHORT_LOG((LM_INFO, "ACSLogSvc's IOR has been written into: %s", iorFile.c_str()));
}//if
// adding ACSLog to NamingService
if (!CORBA::is_nil (naming_context.in ()))
{
// register cdb server in Naming service
示例5: 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());
//.........这里部分代码省略.........