本文整理汇总了C++中corba::Object_var::_set_policy_overrides方法的典型用法代码示例。如果您正苦于以下问题:C++ Object_var::_set_policy_overrides方法的具体用法?C++ Object_var::_set_policy_overrides怎么用?C++ Object_var::_set_policy_overrides使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::Object_var
的用法示例。
在下文中一共展示了Object_var::_set_policy_overrides方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OBJECT_NOT_EXIST
bool
TAO_PG_ObjectGroupManager::ping (CORBA::ORB_ptr orb,
CORBA::Object_var& obj,
const TimeBase::TimeT& tt)
{
bool status = true;
if (CORBA::is_nil (obj.in ()))
throw CORBA::OBJECT_NOT_EXIST ();
// The ping() is used by LoadBalancer which may use RW strategy.
// The validate thread invokes the _non_existent call to members
// sequencially. We have to put a timeout on the call in case
// the client side is not processing ORB requests at this time.
// In the event that the timeout exception occurs, we will assume
// that the peer is still around. If we get any other exception
// we will say that the member is not available anymore.
TimeBase::TimeT timeout = tt;
CORBA::Any timeout_any;
timeout_any <<= timeout;
CORBA::PolicyList policy_list (1);
policy_list.length (1);
policy_list[0] = orb->
create_policy (
Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
timeout_any);
CORBA::Object_var rtt_obj =
obj->_set_policy_overrides (policy_list,
CORBA::ADD_OVERRIDE);
// Clean up the policy that was allocated in the try/catch
for (CORBA::ULong i = 0; i < policy_list.length (); i++)
policy_list[i]->destroy ();
try {
status = ! rtt_obj->_non_existent ();
}
catch (const CORBA::TIMEOUT& ex)
{
if (TAO_debug_level > 8)
{
ex._tao_print_exception ("TAO_PG_ObjectGroupManager::ping");
}
}
catch (const CORBA::Exception& ex)
{
if (TAO_debug_level > 8)
{
ex._tao_print_exception ("TAO_PG_ObjectGroupManager::ping");
}
status = false;
}
return status;
}
示例2: policies
Test::Hello_var
create_policies (CORBA::ORB_ptr orb, bool add_zlib_compressor)
{
CORBA::PolicyList policies(4);
policies.length(4);
policies[0] = create_compressor_id_level_list_policy (orb, add_zlib_compressor);
policies[1] = create_low_value_policy (orb);
policies[2] = create_compression_enabled_policy (orb);
policies[3] = create_min_ratio_policy (orb);
CORBA::Object_var tmp = orb->string_to_object(ior);
CORBA::Object_var tmp2 = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
Test::Hello_var hello = Test::Hello::_narrow(tmp2.in ());
return hello._retn ();
}
示例3: catch
int
ORB_Task::svc (void)
{
try
{
CORBA::Object_var ncRef =
orb_->string_to_object(
"corbaloc:iiop:10.175.12.99:15025/NameService" );
CORBA::PolicyList policies;
TimeBase::TimeT timeout = 5000 * 10000;
CORBA::Any timeoutAny;
timeoutAny <<= timeout;
policies.length(1);
policies[0] = orb_->create_policy(
Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
timeoutAny );
CORBA::Object_var object = ncRef->_set_policy_overrides(
policies, CORBA::SET_OVERRIDE );
policies[0]->destroy();
CosNaming::NamingContext_var namingContext =
CosNaming::NamingContext::_narrow( object.in() );
namingContext->_non_existent();
}
catch ( const CORBA::TRANSIENT&)
{
ACE_DEBUG ((LM_DEBUG, "Caught transient\n"));
}
catch ( const CORBA::TIMEOUT&)
{
ACE_DEBUG ((LM_DEBUG, "Caught timeout\n"));
}
catch ( const CORBA::Exception& e )
{
e._tao_print_exception ("Exception caught");
}
return 0;
}
示例4: policy_list
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 obj =
orb->string_to_object( ior );
Messenger_var messenger =
Messenger::_narrow( obj.in() );
CORBA::String_var message =
CORBA::string_dup( "Terminating messenger service!" );
messenger->send_message( "Chief of Security",
"New Directive",
message.inout() );
messenger->shutdown("Chief of Security");
Security::QOP qop =
Security::SecQOPIntegrityAndConfidentiality;
CORBA::Any want_protection;
want_protection <<= qop;
CORBA::Policy_var policy =
orb->create_policy (Security::SecQOPPolicy,
want_protection);
Security::EstablishTrust establish_trust;
establish_trust.trust_in_client = 0;
establish_trust.trust_in_target = 1;
CORBA::Any want_trust;
want_trust <<= establish_trust;
CORBA::Policy_var policy2 =
orb->create_policy (Security::SecEstablishTrustPolicy,
want_trust);
CORBA::PolicyList policy_list (2);
policy_list.length (1);
policy_list[0] =
CORBA::Policy::_duplicate (policy.in ());
policy_list.length (2);
policy_list[1] =
CORBA::Policy::_duplicate (policy2.in ());
CORBA::Object_var object =
obj->_set_policy_overrides (policy_list,
CORBA::SET_OVERRIDE);
Messenger_var messenger2 =
Messenger::_narrow( object.in() );
message =
CORBA::string_dup( "Terminating messenger service!" );
messenger2->send_message( "Chief of Security",
"New Directive",
message.inout() );
messenger2->shutdown("Chief of Security");
orb->destroy();
}
catch(const CORBA::Exception& ex)
{
ex._tao_print_exception("Client: main block");
return 1;
}
return 0;
}
示例5: if
bool
TAO_Notify_Consumer::is_alive (bool allow_nil_consumer)
{
bool status = false;
CORBA::Object_var consumer = this->get_consumer ();
if (CORBA::is_nil (consumer.in ()))
{
// The consumer may not connected or the consumer did
// not provide a callback. In this case, the liveliness
// check should return true so it will be validated in
// next period.
if (allow_nil_consumer)
return true;
else
return status;
}
CORBA::PolicyList policy_list;
try
{
bool do_liveliness_check = false;
ACE_Time_Value now = ACE_OS::gettimeofday ();
if (CORBA::is_nil (this->rtt_obj_.in ()))
{
// We need to determine if the consumer on the other end is still
// alive. Since we may be in an upcall from the owner of the
// original consumer, we have to put a timeout on the call in case
// the client side is not processing ORB requests at this time. In
// the event that the timeout exception occurs, we will assume that
// the original consumer is still around. If we get any other
// exception we will say that the original consumer is not
// available anymore.
TimeBase::TimeT timeout = 10000000;
CORBA::Any timeout_any;
timeout_any <<= timeout;
policy_list.length (1);
policy_list[0] = TAO_Notify_PROPERTIES::instance()->orb()->
create_policy (
Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
timeout_any);
rtt_obj_ =
consumer->_set_policy_overrides (policy_list,
CORBA::ADD_OVERRIDE);
// Clean up the policy that was allocated in the try/catch
for (CORBA::ULong i = 0; i < policy_list.length (); i++)
policy_list[i]->destroy ();
do_liveliness_check
= (last_ping_ == ACE_Time_Value::zero ? true
: now - last_ping_.value () >= TAO_Notify_PROPERTIES::instance()->validate_client_delay ());
}
else
do_liveliness_check =
now - last_ping_.value () >= TAO_Notify_PROPERTIES::instance()->validate_client_interval ();
if (CORBA::is_nil (rtt_obj_.in ()))
status = false;
else if (do_liveliness_check || allow_nil_consumer)
{
last_ping_ = now;
status = !rtt_obj_->_non_existent ();
}
else
status = true;
}
catch (const CORBA::TIMEOUT&)
{
status = true;
}
catch (const CORBA::Exception& ex)
{
if (DEBUG_LEVEL > 0)
{
ex._tao_print_exception ("TAO_Notify_Consumer::is_alive: false");
}
}
return status;
}
示例6: orb
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
int exit_status = 0;
try
{
CORBA::ORB_var orb (CORBA::ORB_init (argc, argv));
CORBA::Object_var compression_manager_obj (
orb->resolve_initial_references("CompressionManager"));
::Compression::CompressionManager_var compression_manager (
::Compression::CompressionManager::_narrow (
compression_manager_obj.in ()));
if (CORBA::is_nil(compression_manager.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil compression manager\n"),
1);
//register Zlib compressor
::Compression::CompressorFactory_ptr compressor_factory;
ACE_NEW_RETURN (compressor_factory, TAO::Zlib_CompressorFactory (), 1);
::Compression::CompressorFactory_var compr_fact (compressor_factory);
compression_manager->register_factory (compr_fact.in ());
//Register Client ZIOP policies
CORBA::PolicyList policies(4);
policies.length(4);
::Compression::CompressorIdLevelList compressor_id_list;
compressor_id_list.length (1);
compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_ZLIB;
compressor_id_list[0].compression_level = 9;
CORBA::Any any;
any <<= compressor_id_list;
policies[0] = orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, any);
any <<= static_cast <CORBA::ULong> (190u); // shutdown is 180, send_forty_two is 192
policies[1] = orb->create_policy (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, any);
any <<= CORBA::Any::from_boolean (true);
policies[2] = orb->create_policy (ZIOP::COMPRESSION_ENABLING_POLICY_ID, any);
any <<= static_cast <Compression::CompressionRatio> (0.50); // send_forty_two is 0.66, send_large_octet_array is 0.06
policies[3] = orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, any);
// Parse our own client arguments
if (parse_args (argc, argv) != 0)
return 1;
// Obtain the servant reference with our active ZIOP policies.
CORBA::Object_var tmp (orb->string_to_object(ior));
tmp = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
/* Do an unchecked narrow since there's no way to do an is_a on
* a multicast reference (yet...).
*/
Test::McastHello_var hello =
TAO::Narrow_Utils<Test::McastHello>::unchecked_narrow (
tmp.in ());
if (CORBA::is_nil (hello.in ()))
{
ACE_ERROR_RETURN ((LM_DEBUG,
"Nil Test::Hello reference <%s>\n",
ior),
1);
}
// To enable us to check that we compress the correct messages.
::Compression::Compressor_var compressor (
compression_manager->get_compressor (
compressor_id_list[0].compressor_id,
compressor_id_list[0].compression_level));
if (CORBA::is_nil (compressor.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR : compressor not found!\n"),
1);
}
ACE_DEBUG ((LM_DEBUG,
"Client sending send_forty_two() message to server\n"));
hello->send_forty_two (42);
// Note we can't actually check that we did NOT compress the message,
// as the compressor is used to TRIAL the compression before it is
// rejected based upon the min ratio. The compressor thus records
// this trail compression data length. (ZIOP is almost completely
// transparrent in operation to the client and server when operating).
CORBA::ULong total_compressed_so_far= compressor->compressed_bytes ();
Test::Octets payload (MAX_MIOP_OCTET_SEQUENCE);
payload.length (MAX_MIOP_OCTET_SEQUENCE);
for (CORBA::ULong j = 0; j != MAX_MIOP_OCTET_SEQUENCE; ++j)
{
payload[j] = j % 256;
}
ACE_DEBUG ((LM_DEBUG,
"Client sending send_large_octet_array() message to server\n"));
//.........这里部分代码省略.........
示例7: if
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv, "test");
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var tmp = orb->string_to_object(ior);
if (CORBA::is_nil (tmp.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR, "Invalid IOR.\n")
,1);
}
{
// Set the Synch Scopes
CORBA::Any scope_as_any;
if (synch_none == true)
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Applying SYNC_NONE.\n"));
scope_as_any <<= Messaging::SYNC_NONE;
}
else if (synch_delayed == true)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) - Applying SYNC_DELAYED_BUFFERING.\n"));
scope_as_any <<= TAO::SYNC_DELAYED_BUFFERING;
}
CORBA::PolicyList policies (1);
policies.length (1);
policies[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
scope_as_any);
if (level_thread == true)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) - Applying Synch Scope at thread level.\n"));
CORBA::Object_var object =
orb->resolve_initial_references ("PolicyCurrent");
CORBA::PolicyCurrent_var policy_current =
CORBA::PolicyCurrent::_narrow (object.in ());
policy_current->set_policy_overrides (policies,
CORBA::ADD_OVERRIDE);
}
else if (level_orb == true)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) - Applying Synch Scope at orb level.\n"));
CORBA::Object_var obj =
orb->resolve_initial_references("ORBPolicyManager");
CORBA::PolicyManager_var policy_manager =
CORBA::PolicyManager::_narrow(obj.in());
policy_manager->set_policy_overrides (policies,
CORBA::ADD_OVERRIDE);
}
else if (level_obj == true)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) - Applying Synch Scope at Object level.\n"));
tmp = tmp->_set_policy_overrides (policies, CORBA::SET_OVERRIDE);
}
policies[0]->destroy ();
}
Test::Hello_var hello =
Test::Hello::_narrow(tmp.in ());
if (CORBA::is_nil (hello.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Nil Test::Hello reference <%s>\n",
ior),
1);
}
// If a blocking connection is initiated in the next step
// the test will get an exception indicating test failure.
// Be sure you IOR is for the localhost endpoint, else
// grab a book and wait around for timeout.
hello->get_string ();
TAO::Transport_Cache_Manager &tcm =
hello->orb_core ()->lane_resources ().transport_cache ();
TAO_Base_Transport_Property desc (hello->_stubobj ()->profile_in_use ()->endpoint ());
//.........这里部分代码省略.........
示例8: worker
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
static const int orb_threads = 5;
static const int total_threads = 15;
// It must be ensured that there are more total threads that there are
// that are dedicated to running the ORB.
ACE_ASSERT (total_threads > orb_threads);
Worker worker (orb_threads);
try
{
worker.orb_ =
CORBA::ORB_init (argc, argv, "test");
if (parse_args (argc, argv) != 0)
return 1;
ACE_DEBUG ((LM_DEBUG,"using ior = %s\n",ior));
CORBA::Object_var tmp = worker.orb_->string_to_object(ior);
if (CORBA::is_nil (tmp.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR, "Invalid IOR.\n")
,1);
}
worker.hello_ = Test::Hello::_narrow(tmp.in ());
if (CORBA::is_nil (worker.hello_.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Nil Test::Hello reference <%s>\n",
ior),
1);
}
// bool x = worker.hello_->_non_existent();
// ACE_DEBUG ((LM_DEBUG, "_non_existent returned %d\n",x));
{
// Set the Synch Scopes
CORBA::Any scope_as_any;
ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Applying SYNC_NONE.\n"));
scope_as_any <<= Messaging::SYNC_NONE;
CORBA::PolicyList policies (1);
policies.length (1);
policies[0] =
worker.orb_->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
scope_as_any);
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) - Applying Synch Scope at Object level.\n"));
tmp = tmp->_set_policy_overrides (policies, CORBA::SET_OVERRIDE);
policies[0]->destroy ();
}
worker.asynch_hello_ = Test::Hello::_narrow(tmp.in ());
if (CORBA::is_nil (worker.asynch_hello_.in ())) {
ACE_ERROR_RETURN ((LM_ERROR,
"Nil Test::Hello reference <%s>\n",
ior),
1);
}
init_callback(worker);
}
catch (CORBA::Exception &ex)
{
ACE_ERROR ((LM_ERROR, "Exception caught: %s\"%s\"\n"
, ex._name(), ex._rep_id ()));
return 1;
}
worker.activate (THR_NEW_LWP | THR_JOINABLE, total_threads);
worker.wait();
return 0;
}
示例9: owner_transfer
int
main (int argc, char *argv[])
{
try
{
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;
poa_manager->activate();
Hello *hello_impl;
ACE_NEW_RETURN (hello_impl,
Hello (shutdown_handler),
1);
PortableServer::ServantBase_var owner_transfer(hello_impl);
Test::Hello_var hello =
hello_impl->_this ();
ACE_DEBUG ((LM_DEBUG, "getting proxy reference\n"));
CORBA::Object_var obj =
orb->string_to_object (lorica_ior);
#if 0
Security::QOP qop = Security::SecQOPNoProtection;
CORBA::Any no_protection;
no_protection <<= qop;
// Create the Security::QOPPolicy.
CORBA::Policy_var policy =
orb->create_policy (Security::SecQOPPolicy,
no_protection);
CORBA::PolicyList policy_list (1);
policy_list.length (1);
policy_list[0] = CORBA::Policy::_duplicate (policy.in ());
// Create an object reference that uses plain IIOP (i.e. no
// protection).
obj =
obj->_set_policy_overrides (policy_list,
CORBA::SET_OVERRIDE);
#endif
ACE_DEBUG ((LM_DEBUG, "narrowing proxy reference\n"));
mapper = Lorica::ReferenceMapper::_narrow(obj.in());
if (CORBA::is_nil(mapper.in()))
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot get reference to Lorica "
"reference mapper\n"),1);
#if 1
obj = register_with_proxy (hello.in());
#else
obj = mapper->as_server (hello.in(),"Hello",
Lorica::ServerAgent::_nil());
#endif
ACE_DEBUG ((LM_DEBUG,"register_with_proxy() returned\n"));
if (CORBA::is_nil (obj.in()))
ACE_ERROR_RETURN ((LM_ERROR,
"Lorica reference mapper returned a nil "
"mapped reference.\n"),1);
mapped_hello = Test::Hello::_narrow(obj.in());
if (CORBA::is_nil(mapped_hello.in()))
ACE_ERROR_RETURN ((LM_ERROR,
"Lorica reference mapper returned an "
"incorrectly typed reference\n"),1);
CORBA::String_var orig_ior =
orb->object_to_string (hello.in ());
CORBA::String_var mapped_ior =
orb->object_to_string (mapped_hello.in());
if (ACE_OS::strcmp (orig_ior.in(), mapped_ior.in()) == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Lorica reference mapper returned "
"the original reference unmapped.\n"),1);
ACE_DEBUG ((LM_DEBUG,"writing original IOR to file %s\n",orig_file));
//.........这里部分代码省略.........