本文整理汇总了C++中portableserver::POA_ptr::activate_object方法的典型用法代码示例。如果您正苦于以下问题:C++ POA_ptr::activate_object方法的具体用法?C++ POA_ptr::activate_object怎么用?C++ POA_ptr::activate_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portableserver::POA_ptr
的用法示例。
在下文中一共展示了POA_ptr::activate_object方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: INTERNAL
void
activate (T & obj_ref,
PortableServer::POA_ptr poa,
PortableServer::ServantBase * servant,
TAO_EC_Object_Deactivator & suggested_object_deactivator)
{
// Activate the servant into the POA.
PortableServer::ObjectId_var obj_id =
poa->activate_object (servant);
suggested_object_deactivator.set_values (poa, obj_id.in ());
// Get the object reference of the activated object.
CORBA::Object_var obj =
poa->id_to_reference (obj_id.in ());
// Don't try to use T::_obj_type::_narrow, some compilers don't like it so
// do this in two steps
typedef typename T::_obj_type my_object_type;
obj_ref =
my_object_type::_narrow (obj.in());
if (CORBA::is_nil (obj_ref.in ()))
{
throw CORBA::INTERNAL ();
}
}
示例2:
int
create_object (PortableServer::POA_ptr poa,
CORBA::ORB_ptr orb,
Test_i *server_impl,
const ACE_TCHAR *filename)
{
// Register with poa.
PortableServer::ObjectId_var id =
poa->activate_object (server_impl);
CORBA::Object_var server =
poa->id_to_reference (id.in ());
// Print out the IOR.
CORBA::String_var ior =
orb->object_to_string (server.in ());
ACE_DEBUG ((LM_DEBUG, "<%C>\n\n", ior.in ()));
// Print ior to the file.
if (filename != 0)
{
FILE *output_file= ACE_OS::fopen (filename, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
filename),
-1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
return 0;
}
示例3: PingReceiver
void
LiveEntry::do_ping (PortableServer::POA_ptr poa)
{
this->callback_ = new PingReceiver (this, poa);
PortableServer::ObjectId_var oid = poa->activate_object (this->callback_.in());
CORBA::Object_var obj = poa->id_to_reference (oid.in());
ImplementationRepository::AMI_ServerObjectHandler_var cb =
ImplementationRepository::AMI_ServerObjectHandler::_narrow (obj.in());
{
ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
this->liveliness_ = LS_PING_AWAY;
}
try
{
this->ref_->sendc_ping (cb.in());
if (ImR_Locator_i::debug () > 3)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
ACE_TEXT ("sendc_ping returned OK\n")));
}
}
catch (const CORBA::Exception &ex)
{
if (ImR_Locator_i::debug () > 3)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
ACE_TEXT ("sendc_ping threw %C\n"), ex._name()));
}
this->status (LS_DEAD);
}
}
示例4: catch
CosNotifyFilter::FilterFactory_ptr
TAO_Notify_ETCL_FilterFactory::create (PortableServer::POA_ptr filter_poa)
{
this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa);
CORBA::Object_var object = CORBA::Object::_nil();
try
{
PortableServer::ObjectId_var id = filter_poa->activate_object (this);
object = filter_poa->id_to_reference (id.in());
}
catch (PortableServer::POA::ServantAlreadyActive&)
{
try
{
object = filter_poa->servant_to_reference (this);
}
catch (CORBA::Exception& )
{
return CosNotifyFilter::FilterFactory::_nil();
}
}
return CosNotifyFilter::FilterFactory::_narrow (object.in ());
}
示例5:
int
make_ior (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
Hello * servant,
const ACE_TCHAR *ior_file)
{
CORBA::String_var poa_name = poa->the_name();
ACE_DEBUG ((LM_DEBUG, "Creating IOR from %C\n", poa_name.in()));
PortableServer::ObjectId_var oid = poa->activate_object (servant);
CORBA::Object_var o = poa->id_to_reference (oid.in ());
if (host_form == from_hostname || host_form == use_localhost)
{
CORBA::String_var ior =
orb->object_to_string (o.in ());
FILE *output_file= ACE_OS::fopen (ior_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file %s for writing IOR: %C",
ior_file,
ior.in ()),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
return 0;
}
示例6:
void
test_reference_to_servant_active_object(PortableServer::POA_ptr root_poa)
{
test_i test;
CORBA::ULong expected_refcount = 1;
PortableServer::ObjectId_var id =
root_poa->activate_object (&test);
expected_refcount++;
CORBA::Object_var object =
root_poa->id_to_reference (id.in ());
PortableServer::ServantBase_var servant =
root_poa->reference_to_servant (object.in ());
++expected_refcount;
root_poa->deactivate_object (id.in ());
--expected_refcount;
CORBA::ULong refcount =
test._refcount_value ();
ACE_UNUSED_ARG (refcount);
ACE_UNUSED_ARG (expected_refcount);
ACE_ASSERT (expected_refcount == refcount);
}
示例7:
CosNotifyFilter::FilterFactory_ptr
TAO_Notify_Tests_RT_Test_FilterFactory::create (PortableServer::POA_ptr filter_poa)
{
this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa); // save the filter poa.
PortableServer::ObjectId_var id = filter_poa->activate_object (this);
CORBA::Object_var object = filter_poa->id_to_reference (id.in ());
CosNotifyFilter::FilterFactory_var filter = CosNotifyFilter::FilterFactory::_narrow (object.in ());
return filter._retn();
}
示例8: temp
CosNaming::NamingContext_ptr
TAO_Transient_Naming_Context::make_new_context (PortableServer::POA_ptr poa,
const char *poa_id,
size_t context_size)
{
// Put together a servant for the new Naming Context.
TAO_Transient_Naming_Context *context_impl = 0;
ACE_NEW_THROW_EX (context_impl,
TAO_Transient_Naming_Context (poa,
poa_id,
context_size),
CORBA::NO_MEMORY ());
// Put <context_impl> into the auto pointer temporarily, in case next
// allocation fails.
ACE_Auto_Basic_Ptr<TAO_Transient_Naming_Context> temp (context_impl);
TAO_Naming_Context *context = 0;
ACE_NEW_THROW_EX (context,
TAO_Naming_Context (context_impl),
CORBA::NO_MEMORY ());
// Let <implementation> know about it's <interface>.
context_impl->interface (context);
// Release auto pointer, and start using reference counting to
// control our servant.
temp.release ();
PortableServer::ServantBase_var s = context;
// Register the new context with the POA.
#if defined (CORBA_E_MICRO)
PortableServer::ObjectId_var id = poa->activate_object (context);
#else
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId (poa_id);
poa->activate_object_with_id (id.in (), context);
#endif /* CORBA_E_MICRO */
CosNaming::NamingContext_var result = context->_this ();
return result._retn ();
}
示例9: TestAppException
CORBA::Object_ptr
AppHelper::activate_servant(PortableServer::POA_ptr poa,
PortableServer::Servant servant)
{
// Activate the servant using the Child POA.
PortableServer::ObjectId_var oid
= poa->activate_object(servant);
CORBA::Object_var obj
= poa->servant_to_reference(servant);
if (CORBA::is_nil(obj.in()))
{
ACE_ERROR((LM_ERROR,
"(%P|%t) Failed to convert servant_to_ref.\n"));
throw TestAppException();
}
return obj._retn();
}
示例10:
void
create_object (PortableServer::POA_ptr poa,
CORBA::ORB_ptr orb,
PortableServer::Servant servant,
const ACE_TCHAR *filename)
{
// Register with poa.
PortableServer::ObjectId_var id =
poa->activate_object (servant);
CORBA::Object_var object =
poa->id_to_reference (id.in ());
CORBA::String_var ior =
orb->object_to_string (object.in ());
FILE *output_file= ACE_OS::fopen (filename, "w");
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
}
示例11:
void
ReconnectionCallback_i::init (
PortableServer::POA_ptr poa,
CosNotifyChannelAdmin::EventChannelFactory_ptr ecf)
{
this->ecf_ = CosNotifyChannelAdmin::EventChannelFactory::_duplicate (ecf);
PortableServer::ObjectId_var reconnection_callback_id =
poa->activate_object (this);
CORBA::Object_var obj =
poa->id_to_reference (reconnection_callback_id.in ());
NotifyExt::ReconnectionCallback_var callback =
NotifyExt::ReconnectionCallback::_narrow (obj.in ());
NotifyExt::ReconnectionRegistry_var registry =
NotifyExt::ReconnectionRegistry::_narrow (ecf);
this->callback_id_ = registry->register_callback (callback.in ());
this->id_is_valid_ = true;
}
示例12: payload
int
run_buffer_size (CORBA::ORB_ptr orb,
PortableServer::POA_ptr root_poa,
Test::AMI_Buffering_ptr ami_buffering,
Test::AMI_Buffering_Admin_ptr ami_buffering_admin)
{
TAO::BufferingConstraint buffering_constraint;
buffering_constraint.mode = TAO::BUFFER_MESSAGE_BYTES;
buffering_constraint.message_count = 0;
buffering_constraint.message_bytes = BUFFER_SIZE;
buffering_constraint.timeout = 0;
Test::AMI_Buffering_var flusher;
int test_failed =
configure_policies (orb, buffering_constraint,
ami_buffering, flusher.out ());
if (test_failed != 0)
return test_failed;
Test::Payload payload (PAYLOAD_LENGTH);
payload.length (PAYLOAD_LENGTH);
Reply_Handler *reply_handler_impl;
ACE_NEW_RETURN (reply_handler_impl,
Reply_Handler,
1);
PortableServer::ServantBase_var owner_transfer(reply_handler_impl);
PortableServer::ObjectId_var id =
root_poa->activate_object (reply_handler_impl);
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Test::AMI_AMI_BufferingHandler_var reply_handler =
Test::AMI_AMI_BufferingHandler::_narrow (object_act.in ());
CORBA::ULong bytes_sent = 0;
for (int i = 0; i != iterations; ++i)
{
sync_server (orb, flusher.in ());
CORBA::ULong initial_bytes_received =
ami_buffering_admin->bytes_received_count ();
if (initial_bytes_received != bytes_sent)
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d data lost (%u != %u)\n",
i, initial_bytes_received, bytes_sent));
}
while (1)
{
ami_buffering->sendc_receive_data (reply_handler.in (),
payload);
bytes_sent += PAYLOAD_LENGTH;
CORBA::ULong bytes_received =
ami_buffering_admin->bytes_received_count ();
ACE_Time_Value tv (0, 10 * 1000);
orb->run (tv);
CORBA::ULong payload_delta =
bytes_sent - initial_bytes_received;
if (bytes_received != initial_bytes_received)
{
// The queue has been flushed, check that enough data
// has been sent. The check cannot be precise because
// the ORB counts the GIOP message overhead, in this
// test we assume the overhead to be less than 10%
if (payload_delta < CORBA::ULong (GIOP_OVERHEAD * BUFFER_SIZE))
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d flush before "
"minimum buffer size was reached. "
"Sent = %u, Minimum buffer = %u bytes\n",
i,
payload_delta, BUFFER_SIZE));
}
break;
}
if (payload_delta > 2 * BUFFER_SIZE)
{
test_failed = 1;
ACE_DEBUG ((LM_DEBUG,
"DEBUG: Iteration %d no flush past "
"buffer size threshold. "
"Sent = %u, Minimum buffer = %u bytes\n",
i,
payload_delta, BUFFER_SIZE));
break;
}
}
}
//.........这里部分代码省略.........
示例13: servant
void
test_poas (CORBA::ORB_ptr orb,
PortableServer::POA_ptr root_poa,
PortableServer::POA_ptr first_poa,
PortableServer::POA_ptr second_poa,
PortableServer::POA_ptr third_poa,
PortableServer::POA_ptr forth_poa,
int perform_deactivation_test)
{
{
test_i servant (root_poa);
CORBA::Object_var obj = root_poa->create_reference ("IDL:test:1.0");
CORBA::String_var string = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));
PortableServer::ObjectId_var id = root_poa->reference_to_id (obj.in ());
root_poa->activate_object_with_id (id.in (),
&servant);
obj = root_poa->id_to_reference (id.in ());
string = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));
PortableServer::ServantBase_var servant_from_reference =
root_poa->reference_to_servant (obj.in ());
PortableServer::ServantBase_var servant_from_id =
root_poa->id_to_servant (id.in ());
if (servant_from_reference.in () != servant_from_id.in ()
|| servant_from_reference.in () != &servant)
{
ACE_ERROR ((LM_ERROR,
"Mismatched servant_from_reference, "
"servant_from_id and &servant\n"));
}
obj = root_poa->servant_to_reference (&servant);
string = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));
obj = servant._this ();
string = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));
PortableServer::ObjectId_var id_from_servant = root_poa->servant_to_id (&servant);
ACE_ASSERT (id_from_servant.in () == id.in ());
root_poa->deactivate_object (id.in ());
if (perform_deactivation_test)
{
root_poa->activate_object_with_id (id.in (),
&servant);
servant_from_reference = root_poa->reference_to_servant (obj.in ());
ACE_ASSERT (servant_from_reference.in () == &servant);
root_poa->deactivate_object (id.in ());
}
}
{
test_i servant (root_poa);
PortableServer::ObjectId_var id = root_poa->activate_object (&servant);
CORBA::Object_var obj = root_poa->id_to_reference (id.in ());
CORBA::String_var string = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));
obj = root_poa->create_reference_with_id (id.in (),
"IDL:test:1.0");
string = orb->object_to_string (obj.in ());
ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ()));
root_poa->deactivate_object (id.in ());
}
{
test_i servant (first_poa);
CORBA::Object_var obj = first_poa->create_reference ("IDL:test:1.0");
//.........这里部分代码省略.........