本文整理汇总了C++中portableserver::POA_var::set_servant方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_var::set_servant方法的具体用法?C++ POA_var::set_servant怎么用?C++ POA_var::set_servant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portableserver::POA_var
的用法示例。
在下文中一共展示了POA_var::set_servant方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: policies
CORBA::Boolean
ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent,
const char *name)
{
ACE_ASSERT (! CORBA::is_nil(parent));
ACE_ASSERT (name != 0);
CORBA::PolicyList policies (3);
const char *exception_message = "Null Message";
policies.length (3);
try
{
// Servant Retention Policy
exception_message = "While PortableServer::POA::create_servant_retention_policy";
policies[0] =
parent->create_servant_retention_policy (PortableServer::NON_RETAIN);
// Request Processing Policy
exception_message = "While PortableServer::POA::create_request_processing_policy";
policies[1] =
parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);
policies[2] =
parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);
PortableServer::POAManager_var poa_manager =
parent->the_POAManager ();
exception_message = "While create_POA";
PortableServer::POA_var child =
parent->create_POA (name,
poa_manager.in (),
policies);
exception_message = "While policy->destroy";
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
exception_message = "While child->the_activator";
child->the_activator (this);
exception_message = "While set_servant";
child->set_servant (this->default_servant_);
}
catch (const CORBA::Exception& ex)
{
ORBSVCS_ERROR ((LM_ERROR,
"IMR_Adapter_Activator::unknown_adapter - %s\n",
exception_message));
ex._tao_print_exception ("System Exception");
return 0;
}
// Finally, now everything is fine
return 1;
}
示例2: reference_counted_test_i
CORBA::Boolean
Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent,
const char *name)
{
if (ACE_OS::strcmp (name, "firstPOA") == 0)
{
PortableServer::POA_var child = parent->create_POA (name,
this->poa_manager_.in (),
this->first_poa_policies_);
// Creation of firstPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < this->first_poa_policies_.length ();
++i)
{
this->first_poa_policies_[i]->destroy ();
}
child->the_activator (this);
reference_counted_test_i *servant =
new reference_counted_test_i (this->orb_.in (),
child.in ());
child->set_servant (servant);
// This means that the ownership of <servant> now belongs to the
// POA.
servant->_remove_ref ();
// Finally everything is fine
return 1;
}
else if (ACE_OS::strcmp (name, "secondPOA") == 0)
{
PortableServer::POA_var child = parent->create_POA (name,
this->poa_manager_.in (),
this->second_poa_policies_);
// Creation of secondPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < this->second_poa_policies_.length ();
++i)
{
this->second_poa_policies_[i]->destroy ();
}
reference_counted_test_i *servant =
new reference_counted_test_i (this->orb_.in (),
child.in ());
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("third test");
child->activate_object_with_id (oid.in (),
servant);
// This means that the ownership of <servant> now belongs to the
// POA.
servant->_remove_ref ();
// Finally everything is fine
return 1;
}
else
{
// Unknown POA.
return 0;
}
}
示例3: main
//.........这里部分代码省略.........
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in());
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
示例4: 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());
//.........这里部分代码省略.........