本文整理汇总了C++中corba::Policy_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Policy_ptr类的具体用法?C++ Policy_ptr怎么用?C++ Policy_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Policy_ptr类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: policies
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
Server_ORBInitializer2 *temp_initializer = 0;
ACE_NEW_RETURN (temp_initializer,
Server_ORBInitializer2,
-1); // No exceptions yet!
PortableInterceptor::ORBInitializer_var orb_initializer =
temp_initializer;
PortableInterceptor::register_orb_initializer (orb_initializer.in ());
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 ();
CORBA::PolicyList policies (2);
policies.length (2);
policies[0] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID);
policies[1] =
root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
PortableServer::POA_var my_poa =
root_poa->create_POA ("my_poa",
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 ();
}
if (parse_args (argc, argv) != 0)
return -1;
Hello *hello_impl = 0;
ACE_NEW_RETURN (hello_impl,
Hello (orb.in (), Test::Hello::_nil (), my_id_number),
-1);
PortableServer::ServantBase_var owner (hello_impl);
PortableServer::ObjectId_var server_id =
PortableServer::string_to_ObjectId ("server_id");
my_poa->activate_object_with_id (server_id.in (),
hello_impl);
CORBA::Object_var hello =
my_poa->id_to_reference (server_id.in ());
CORBA::String_var ior =
orb->object_to_string (hello.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", ior.in ());
ACE_OS::fclose (output_file);
poa_manager->activate ();
orb->run ();
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return -1;
}
return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:100,代码来源:server2.cpp
示例2: 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;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:59,代码来源:Adapter_Activator.cpp
示例3: policies
int
Manager::init (int argc, ACE_TCHAR *argv[])
{
this->orb_ = CORBA::ORB_init (argc, argv);
// Obtain the RootPOA.
CORBA::Object_var obj_var =
this->orb_->resolve_initial_references ("RootPOA");
// Get the POA_var object from Object_var.
PortableServer::POA_var root_poa_var =
PortableServer::POA::_narrow (obj_var.in ());
// Get the POAManager of the RootPOA.
PortableServer::POAManager_var poa_manager_var =
root_poa_var->the_POAManager ();
poa_manager_var->activate ();
// Policies for the childPOA to be created.
CORBA::PolicyList policies (4);
policies.length (4);
// The next two policies are common to both
// Id Assignment Policy
policies[0] =
root_poa_var->create_id_assignment_policy (PortableServer::USER_ID);
// Lifespan policy
policies[1] =
root_poa_var->create_lifespan_policy (PortableServer::PERSISTENT);
// Tell the POA to use a servant manager
policies[2] =
root_poa_var->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);
// Servant Retention Policy -> Use a locator
policies[3] =
root_poa_var->create_servant_retention_policy (PortableServer::NON_RETAIN);
ACE_CString name = "newPOA";
this->new_poa_var_ =
root_poa_var->create_POA (name.c_str (),
poa_manager_var.in (),
policies);
// Creation of childPOAs is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:58,代码来源:Manager.cpp
示例4: throw
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO::Utils::PolicyList_Destroyer::~PolicyList_Destroyer() throw ()
{
for (CORBA::ULong i = 0; i != length(); ++i)
{
CORBA::Policy_ptr policy = (*this)[i];
if (!CORBA::is_nil (policy))
{
try
{
policy->destroy ();
(*this)[i] = CORBA::Policy::_nil();
}
catch (...)
{
}
}
}
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:20,代码来源:PolicyList_Destroyer.cpp
示例5:
TAO_Stub *
TAO_RT_Stub::set_policy_overrides (const CORBA::PolicyList & policies,
CORBA::SetOverrideType set_add)
{
// Validity check. Make sure requested policies are allowed to be
// set at this scope.
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
CORBA::Policy_ptr policy = policies[i];
if (!CORBA::is_nil (policy))
{
CORBA::PolicyType const type = policy->policy_type ();
if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE ||
type == RTCORBA::THREADPOOL_POLICY_TYPE ||
type == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE)
throw ::CORBA::NO_PERMISSION ();
}
}
// We are not required to check for consistency of <policies> with
// overrides at other levels or with policies exported in the IOR.
return this->TAO_Stub::set_policy_overrides(policies, set_add);
}
开发者ID:CCJY,项目名称:ATCD,代码行数:24,代码来源:RT_Stub.cpp
示例6: 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_);
}
//.........这里部分代码省略.........
开发者ID:bjovke,项目名称:ACE_TAO,代码行数:101,代码来源:airplane_server_i.cpp
示例7: worker
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->resolve_initial_references ("RootPOA");
ORB_Task worker (orb.in ());
worker.activate (THR_NEW_LWP | THR_JOINABLE,
1);
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow (object.in ());
PortableServer::POAManager_var poa_manager =
rootPOA->the_POAManager ();
CORBA::PolicyList policies (5);
policies.length (5);
// Lifespan policy
policies[0] =
rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);
// Servant Retention Policy
policies[1] =
rootPOA->create_servant_retention_policy (PortableServer::RETAIN );
// ID Assignment Policy
policies[2] =
rootPOA->create_id_assignment_policy (PortableServer::USER_ID );
// Request Processing Policy
policies[3] =
rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );
// Threading policy
policies[4] =
rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
if (server_notify_delay > 0)
{
ACE_OS::sleep (server_notify_delay);
ACE_DEBUG ((LM_DEBUG, "(%P|%t)ServerB Now register with IMR \n"));
}
PortableServer::POA_var poa_a = rootPOA->create_POA ("poaB",
poa_manager.in (),
policies
);
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
Test_Dummy_i* dummy = new Test_Dummy_i();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("Server_B");
poa_a->activate_object_with_id (oid.in (), dummy);
CORBA::Object_var dummy_obj = poa_a->id_to_reference(oid.in());
CORBA::String_var ior =
orb->object_to_string (dummy_obj.in ());
poa_manager->activate ();
// 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",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
worker.wait ();
rootPOA->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception &ex)
{
ex._tao_print_exception ("Exception caught by serverB:");
return 1;
}
return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:100,代码来源:serverB.cpp
示例8: policies
int
TAO_Naming_Server::init_with_orb (int argc,
ACE_TCHAR *argv [],
CORBA::ORB_ptr orb)
{
int result;
try
{
// Duplicate the ORB
this->orb_ = CORBA::ORB::_duplicate (orb);
// Get the POA from the ORB.
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
{
ORBSVCS_ERROR_RETURN ((LM_ERROR,
ACE_TEXT(" (%P|%t) Unable to initialize the POA.\n")),
-1);
}
// Check the non-ORB arguments. this needs to come before we
// initialize my_naming_server so that we can pass on some of
// the command-line arguments.
result = this->parse_args (argc, argv);
if (result < 0)
return result;
// Get the POA object.
this->root_poa_ = PortableServer::POA::_narrow (poa_object.in ());
// Get the POA_Manager.
PortableServer::POAManager_var poa_manager =
this->root_poa_->the_POAManager ();
#if defined (CORBA_E_MICRO)
this->ns_poa_ = PortableServer::POA::_duplicate (this->root_poa_);
#else
int numPolicies = 2;
# if (TAO_HAS_MINIMUM_POA == 0)
if (this->use_storable_context_)
{
this->use_servant_activator_ = true;
}
if (this->use_servant_activator_) {
numPolicies += 2;
}
# endif /* TAO_HAS_MINIMUM_POA */
CORBA::PolicyList policies (numPolicies);
policies.length (numPolicies);
// Id Assignment policy
policies[0] =
this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID);
// Lifespan policy
policies[1] =
this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT);
# if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
if (this->use_servant_activator_)
{
// Request Processing Policy
policies[2] =
this->root_poa_->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);
// Servant Retention Policy
policies[3] =
this->root_poa_->create_servant_retention_policy (PortableServer::RETAIN);
}
# endif /* TAO_HAS_MINIMUM_POA */
// We use a different POA, otherwise the user would have to change
// the object key each time it invokes the server.
this->ns_poa_ = this->root_poa_->create_POA ("NameService",
poa_manager.in (),
policies);
// Warning! If create_POA fails, then the policies won't be
// destroyed and there will be hell to pay in memory leaks!
// Creation of the new POAs over, so destroy the Policy_ptr's.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
#endif /* CORBA_E_MICRO */
poa_manager->activate ();
#if defined (CORBA_E_MICRO)
result = this->init (orb,
this->ns_poa_.in (),
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:ATCD,代码行数:101,代码来源:Naming_Server.cpp
示例9: policies
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 rootPOA = PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager ();
// Policies for the firstPOA to be created.
CORBA::PolicyList policies (5);
policies.length (5);
// Lifespan policy
policies[0] =
rootPOA->create_lifespan_policy (PortableServer::PERSISTENT );
// Servant Retention Policy
policies[1] =
rootPOA->create_servant_retention_policy (PortableServer::RETAIN );
// ID Assignment Policy
policies[2] =
rootPOA->create_id_assignment_policy (PortableServer::USER_ID );
// Request Processing Policy
policies[3] =
rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );
// Threading policy
policies[4] =
rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL );
PortableServer::POA_var demoPOA
= rootPOA->create_POA ("HelloWorldServer",
poa_manager.in (),
policies
);
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
// Create object for shutdown commanded by client.
{
// create the object
Demo_HelloWorld_i * hello = new Demo_HelloWorld_i(orb.in());
// Get the Object ID.
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("shutdown");
demoPOA->activate_object_with_id (oid.in (), hello);
// Create an object reference.
CORBA::Object_var myhello = demoPOA->id_to_reference(oid.in());
// Put the object reference as an IOR string
ofstream out(ACE_TEXT_ALWAYS_CHAR (shutdown_ior_output_file));
CORBA::String_var ior = orb->object_to_string (myhello.in ());
out << ior.in();
// save the reference into a file
out.close();
}
// Create object to handle client sayHello requests.
{
// create the object
Demo_HelloWorld_i * hello = new Demo_HelloWorld_i(orb.in());
// Get the Object ID.
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("hello");
demoPOA->activate_object_with_id (oid.in (), hello);
// Create an object reference.
CORBA::Object_var myhello = demoPOA->id_to_reference(oid.in());
// Put the object reference as an IOR string
ofstream out(ACE_TEXT_ALWAYS_CHAR (ior_output_file));
CORBA::String_var ior = orb->object_to_string (myhello.in ());
out << ior.in();
// save the reference into a file
out.close();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
poa_manager->activate ();
std::cout << ior_output_file << " is ready " << std::endl;
//.........这里部分代码省略.........
开发者ID:manut,项目名称:TAO,代码行数:101,代码来源:server.cpp
示例10: policies
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
// Obtain the RootPOA.
CORBA::Object_var object =
orb->resolve_initial_references ("RootPOA");
// Narrow to POA.
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (object.in ());
// Get the POAManager of the RootPOA.
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
// Policies for the new POA.
CORBA::PolicyList policies (3);
policies.length (3);
// Request Processing Policy.
policies[0] =
root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);
// Id Uniqueness Policy.
policies[1] =
root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);
// Servant Retention Policy.
policies[2] =
root_poa->create_servant_retention_policy (PortableServer::NON_RETAIN);
// Create POA to host default servant.
ACE_CString name = "Default Servant";
PortableServer::POA_var default_servant_poa =
root_poa->create_POA (name.c_str (),
poa_manager.in (),
policies);
// Destroy policies.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
// Activate POA manager.
poa_manager->activate ();
test_reference_to_servant_active_object(root_poa.in ());
// Test servant.
test_i test;
CORBA::ULong expected_refcount = 1;
(void) test_get_servant_with_no_set (default_servant_poa.in());
(void) test_get_servant_manager (default_servant_poa.in());
(void) test_set_servant_manager (default_servant_poa.in());
// Register default servant.
default_servant_poa->set_servant (&test);
expected_refcount++;
// Create dummy id.
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId ("id");
// Create dummy object.
object =
default_servant_poa->create_reference ("IDL:test:1.0");
// Invoke id_to_servant(). Should retrieve default servant.
PortableServer::ServantBase_var servant =
default_servant_poa->id_to_servant (id.in ());
expected_refcount++;
// Assert correctness.
ACE_ASSERT (&test == servant.in());
// Invoke reference_to_servant(). Should retrieve default servant.
servant =
default_servant_poa->reference_to_servant (object.in ());
expected_refcount++;
// Assert correctness.
ACE_ASSERT (&test == servant.in());
// Report success.
ACE_DEBUG ((LM_DEBUG,
"Default_Servant test successful\n"));
//.........这里部分代码省略.........
开发者ID:OspreyHub,项目名称:ATCD,代码行数:101,代码来源:Default_Servant.cpp
示例11: policies
int
TAO_Repository_i::create_servants_and_poas (void)
{
CORBA::PolicyList policies (5);
policies.length (5);
// ID Assignment Policy.
policies[0] =
this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID);
// Lifespan Policy.
policies[1] =
this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT);
// Request Processing Policy.
policies[2] =
this->root_poa_->create_request_processing_policy (
PortableServer::USE_DEFAULT_SERVANT
);
// Servant Retention Policy.
policies[3] =
this->root_poa_->create_servant_retention_policy (
PortableServer::NON_RETAIN
);
// Id Uniqueness Policy.
policies[4] =
this->root_poa_->create_id_uniqueness_policy (
PortableServer::MULTIPLE_ID
);
PortableServer::POAManager_var poa_manager =
this->root_poa_->the_POAManager ();
#define GEN_IR_OBJECT(name) \
this-> name ## _poa_ = \
this->root_poa_->create_POA (#name "_poa", \
poa_manager.in (), \
policies); \
\
TAO_ ## name ## _i * name ## _impl = 0; \
ACE_NEW_RETURN (name ## _impl, \
TAO_ ## name ## _i (this), \
-1); \
ACE_NEW_RETURN (this-> name ## _servant_, \
POA_CORBA:: name ## _tie<TAO_ ## name ## _i> ( \
name ## _impl, \
this-> name ## _poa_.in (), \
1 \
), \
-1); \
PortableServer::ServantBase_var name ## _safety ( \
this-> name ## _servant_ \
); \
this-> name ## _poa_->set_servant (this-> name ## _servant_);
CONCRETE_IR_OBJECT_TYPES
#undef GEN_IR_OBJECT
#undef CONCRETE_IR_OBJECT_TYPES
CORBA::ULong length = policies.length ();
for (CORBA::ULong i = 0; i < length; ++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:72,代码来源:Repository_i.cpp
示例12: main
//.........这里部分代码省略.........
try
{
//Get a reference to the RootPOA
ACE_OS::printf("Creating POA ... \n");
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
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()));
开发者ID:jantogni,项目名称:ACS,代码行数:67,代码来源:acsLogSvc.cpp
示例13: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try {
// First initialize the ORB, that will remove some arguments...
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "TestORB");
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());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
poa_manager->activate ();
// Make policies for child POA
CORBA::PolicyList policies(2) ;
policies.length(2) ;
policies[0] = root_poa->create_lifespan_policy ( PortableServer::PERSISTENT ) ;
policies[1] = root_poa->create_id_assignment_policy ( PortableServer::USER_ID ) ;
PortableServer::POA_var poa = root_poa->create_POA ( "MyPOA", poa_manager.in(), policies );
// Creation of the new POAs over, so destroy the Policy_ptr's.
for ( CORBA::ULong i = 0 ; i < policies.length (); ++i ) {
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
// use this poa for making system objects
Quoter_Stock_i::set_default_POA ( poa.in() ) ;
// Create the servant
Quoter_Stock_Factory_i *stock_factory_i = 0;
ACE_NEW_RETURN (stock_factory_i,
Quoter_Stock_Factory_i,
-1);
PortableServer::ServantBase_var safe (stock_factory_i);
// Activate it to obtain the object reference
PortableServer::ObjectId_var id =
root_poa->activate_object (stock_factory_i);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Quoter::Stock_Factory_var stock_factory =
Quoter::Stock_Factory::_narrow (object_act.in ());
// Put the object reference as an IOR string
CORBA::String_var ior = orb->object_to_string (stock_factory.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", ior.in ());
ACE_OS::fclose (output_file);
ACE_Time_Value timeout (15);
orb->run (timeout);
// Destroy the POA, waiting until the destruction terminates
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception & e) {
cerr << "CORBA exception raised: " << e << endl;
}
return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:72,代码来源:server.cpp
示例14: policies
int
Server_Task::svc (void)
{
try
{
CORBA::Object_var poa_object =
this->sorb_->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 ();
CORBA::PolicyList policies (4);
policies.length (4);
// ID Assignment Policy
policies[0] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID);
// Lifespan Policy
policies[1] =
root_poa->create_lifespan_policy (PortableServer::PERSISTENT);
// Request Processing Policy
policies[2] =
root_poa->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER);
PortableServer::POA_var first_poa;
{
// Servant Retention Policy
policies[3] =
root_poa->create_servant_retention_policy (PortableServer::RETAIN);
ACE_CString name = "firstPOA";
// Create firstPOA as the child of RootPOA with the above policies
// firstPOA will use SERVANT_ACTIVATOR because of RETAIN policy.
first_poa = root_poa->create_POA (name.c_str (),
poa_manager.in (),
policies);
}
// Destroy the policy objects as they have been passed to
// create_POA and no longer needed.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
// Allocate the servant activator.
ServantActivator activator (this->sorb_.in (), ACE_Thread::self ());
// Set ServantActivator object as the servant_manager of
// firstPOA.
first_poa->set_servant_manager (&activator);
// Create a reference with user created ID in firstPOA which uses
// the ServantActivator.
PortableServer::ObjectId_var first_test_oid =
PortableServer::string_to_ObjectId ("first test");
CORBA::Object_var first_test =
first_poa->create_reference_with_id (first_test_oid.in (), "IDL:test:1.0");
// Invoke object_to_string on the references created in firstPOA
CORBA::String_var first_test_ior =
this->sorb_->object_to_string (first_test.in ());
// Print the ior's of first_test.
ACE_DEBUG((LM_DEBUG,"<%C>\n",
first_test_ior.in ()));
int write_result = write_iors_to_file (first_test_ior.in ());
if (write_result != 0)
return write_result;
// Set the poa_manager state to active, ready to process requests.
poa_manager->activate ();
this->me_.signal ();
// Run the ORB.
this->sorb_->run ();
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
//.........这里部分代码省略.........
开发者ID:asdlei00,项目名称:ACE,代码行数:101,代码来源:Server_Task.cpp
示例15: 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());
//.........这里部分代码省略.........
开发者ID:ACS-Community,项目名称:ACS,代码行数:101,代码来源:acsdaemonStartAcs.cpp
示例16: policies
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->resolve_initial_references ("RootPOA");
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow (object.in ());
PortableServer::POAManager_var poa_manager =
rootPOA->the_POAManager ();
CORBA::PolicyList policies (5);
policies.length (5);
// Lifespan policy
policies[0] =
rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);
// Servant Retention Policy
policies[1] =
rootPOA->create_servant_retention_policy (PortableServer::RETAIN );
// ID Assignment Policy
policies[2] =
rootPOA->create_id_assignment_policy (PortableServer::USER_ID );
// Request Processing Policy
policies[3] =
rootPOA->create_request_processing_policy (PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY );
// Threading policy
policies[4] =
rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
PortableServer::POA_var poa_a = rootPOA->create_POA ("poaA",
poa_manager.in (),
policies
);
PortableServer::POA_var poa_c = rootPOA->create_POA ("poaC",
poa_manager.in (),
policies
);
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
CORBA::Policy_ptr policy = policies[i];
policy->destroy ();
}
Test_Time_i* time = new Test_Time_i();
PortableServer::ObjectId_var oid =
PortableServer::string_to_ObjectId ("Server_A");
poa_a->activate_object_with_id (oid.in (), time);
CORBA::Object_var time_obj = poa_a->id_to_reference(oid.in());
CORBA::String_var ior =
orb->object_to_string (time_obj.in ());
poa_manager->activate ();
FILE *output_file = ACE_OS::fopen (pid_file, ACE_TEXT ("w"));
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Cannot open output file for writing IOR: %s\n"),
pid_file),
1);
int pid = static_cast<int> (ACE_OS::getpid ());
ACE_OS::fprintf (output_file, "%d\n", pid);
ACE_OS::fclose (output_file);
orb->run ();
rootPOA->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception &ex)
{
ex._tao_print_exception (ACE_TEXT ("server:"));
return 1;
}
return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:92,代码来源:server.cpp
|
请发表评论