本文整理汇总了C++中corba::ORB_ptr::create_policy方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_ptr::create_policy方法的具体用法?C++ ORB_ptr::create_policy怎么用?C++ ORB_ptr::create_policy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::ORB_ptr
的用法示例。
在下文中一共展示了ORB_ptr::create_policy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: policies
int
configure_policies (CORBA::ORB_ptr orb,
const TAO::BufferingConstraint &buffering_constraint,
Test::AMI_Buffering_ptr ami_buffering,
Test::AMI_Buffering_out flusher)
{
CORBA::Object_var object =
orb->resolve_initial_references ("PolicyCurrent");
CORBA::PolicyCurrent_var policy_current =
CORBA::PolicyCurrent::_narrow (object.in ());
if (CORBA::is_nil (policy_current.in ()))
{
ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n"));
return 1;
}
CORBA::Any scope_as_any;
scope_as_any <<= Messaging::SYNC_NONE;
CORBA::Any buffering_as_any;
buffering_as_any <<= buffering_constraint;
CORBA::PolicyList policies (2); policies.length (2);
policies[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
scope_as_any);
policies[1] =
orb->create_policy (TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
buffering_as_any);
policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);
policies[0]->destroy ();
policies[1]->destroy ();
TAO::BufferingConstraint flush_constraint;
flush_constraint.mode = TAO::BUFFER_FLUSH;
flush_constraint.message_count = 0;
flush_constraint.message_bytes = 0;
flush_constraint.timeout = 0;
buffering_as_any <<= flush_constraint;
policies.length (1);
policies[0] =
orb->create_policy (TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
buffering_as_any);
object =
ami_buffering->_set_policy_overrides (policies,
CORBA::ADD_OVERRIDE);
policies[0]->destroy ();
flusher =
Test::AMI_Buffering::_narrow (object.in ());
return 0;
}
示例2:
CORBA::Policy_ptr
create_compressor_id_level_list_policy (CORBA::ORB_ptr orb)
{
::Compression::CompressorIdLevelList compressor_id_list;
if (test == 2)
{
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("*** NOTE TestCompressor is EXPECTED to throw IDL:omg.org/Compression/CompressionException ***\n")));
compressor_id_list.length(1);
compressor_id_list[0].compressor_id = COMPRESSORID_FOR_TESTING;
compressor_id_list[0].compression_level = SERVER_COMPRESSION_LEVEL;
}
else
{
compressor_id_list.length(2);
compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_BZIP2;
compressor_id_list[0].compression_level = SERVER_COMPRESSION_LEVEL;
compressor_id_list[1].compressor_id = ::Compression::COMPRESSORID_ZLIB;
compressor_id_list[1].compression_level = SERVER_COMPRESSION_LEVEL;
//compressor_id_list[2].compressor_id = COMPRESSORID_FOR_TESTING;
//compressor_id_list[2].compression_level = SERVER_COMPRESSION_LEVEL;
}
CORBA::Any compressor_id_any;
compressor_id_any <<= compressor_id_list;
return orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, compressor_id_any);
}
示例3: policy_list
int
insecure_invocation_test (CORBA::ORB_ptr orb,
CORBA::Object_ptr obj)
{
// Disable protection for this insecure invocation test.
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).
CORBA::Object_var object =
obj->_set_policy_overrides (policy_list,
CORBA::SET_OVERRIDE);
Foo::Bar_var server =
Foo::Bar::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
ACE_ERROR ((LM_ERROR,
"(%P|%t) ERROR: Object reference <%s> is "
"nil.\n",
ior));
return 1;
}
try
{
// This invocation should result in a CORBA::NO_PERMISSION
// exception.
server->baz ();
}
catch (const CORBA::NO_PERMISSION&)
{
ACE_DEBUG ((LM_INFO,
"(%P|%t) Received CORBA::NO_PERMISSION from "
"server, as expected.\n"));
return 0;
}
ACE_ERROR ((LM_ERROR,
"(%P|%t) ERROR: CORBA::NO_PERMISSION was not thrown.\n"
"(%P|%t) ERROR: It should have been thrown.\n"));
return 1;
}
示例4: INTERNAL
void
TAO_Notify_Service_Driver::apply_timeout (CORBA::ORB_ptr orb)
{
#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
if (this->timeout_ != 0)
{
// convert from msec to "TimeT"
CORBA::Any timeout;
TimeBase::TimeT value = 10000 * this->timeout_;
timeout <<= value;
CORBA::Object_var object =
orb->resolve_initial_references ("ORBPolicyManager");
CORBA::PolicyManager_var policy_manager =
CORBA::PolicyManager::_narrow (object.in ());
if (CORBA::is_nil (policy_manager.in ()))
throw CORBA::INTERNAL ();
CORBA::PolicyList policy_list (1);
policy_list.length (1);
policy_list[0] = orb->create_policy (
Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
timeout);
policy_manager->set_policy_overrides (policy_list, CORBA::SET_OVERRIDE);
policy_list[0]->destroy ();
}
#else
ACE_UNUSED_ARG (orb);
#endif /* TAO_HAS_CORBA_MESSAGING != 0 */
}
示例5:
void
Lorica_MapperRegistry::init_mappers(PortableServer::POAManager_ptr outward,
PortableServer::POAManager_ptr inward,
CORBA::ORB_ptr orb,
bool has_security)
{
// first, prevent multiple activation
if (this->mappers_ready_)
return;
// consolidate the mapper list, to append first the generic mapper and
// then the null mapper.
if (this->generic_mapper_ != 0) {
if (Lorica_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%T) %N:%l - adding generic mapper\n")));
}
this->add_proxy_mapper(this->generic_mapper_);
this->generic_mapper_ = 0;
}
if (this->null_mapper_ != 0) {
if (Lorica_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%T) %N:%l - adding null mapper\n")));
}
this->add_proxy_mapper (this->null_mapper_);
this->null_mapper_ = 0;
}
if (this->mappers_ != 0) {
if (Lorica_debug_level > 0) {
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%T) %N:%l - calling mapper init on the root.\n")));
}
this->mappers_->proxy_mapper_init(outward, inward, orb);
}
this->has_security_ = has_security;
#if !defined (LORICA_LACKS_SSLIOP)
if (has_security) {
this->sec_policies_.length(1);
Security::QOP qop = Security::SecQOPIntegrityAndConfidentiality;
CORBA::Any i_and_c;
i_and_c <<= qop;
// Create the Security::QOPPolicy.
sec_policies_[0] = orb->create_policy(Security::SecQOPPolicy, i_and_c);
} else
#endif // LORICA_LACKS_SSLIOP
this->sec_policies_.length(0);
this->mappers_ready_ = true;
}
示例6:
CORBA::Policy_ptr
create_min_ratio_policy (CORBA::ORB_ptr orb)
{
CORBA::Any min_compression_ratio_any;
Compression::CompressionRatio min_compression_ratio = 0.50;
min_compression_ratio_any <<= min_compression_ratio;
return orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, min_compression_ratio_any);
}
示例7: switch
CORBA::Policy_ptr
create_compressor_id_level_list_policy (CORBA::ORB_ptr orb, bool add_zlib_for_test_1)
{
::Compression::CompressorIdLevelList compressor_id_list;
switch (test)
{
case 1:
if (add_zlib_for_test_1)
compressor_id_list.length(2);
else
compressor_id_list.length(1);
compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_LZO;
compressor_id_list[0].compression_level = CLIENT_COMPRESSION_LEVEL;
if (add_zlib_for_test_1)
{
compressor_id_list[1].compressor_id = ::Compression::COMPRESSORID_ZLIB;
compressor_id_list[1].compression_level = CLIENT_COMPRESSION_LEVEL;
}
break;
case 2:
compressor_id_list.length(1);
compressor_id_list[0].compressor_id = COMPRESSORID_FOR_TESTING;
compressor_id_list[0].compression_level = CLIENT_COMPRESSION_LEVEL;
break;
case 3:
case 4:
default:
compressor_id_list.length(2);
compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_ZLIB;
compressor_id_list[0].compression_level = CLIENT_COMPRESSION_LEVEL;
compressor_id_list[1].compressor_id = ::Compression::COMPRESSORID_BZIP2;
compressor_id_list[1].compression_level = CLIENT_COMPRESSION_LEVEL;
break;
}
CORBA::Any compressor_id_any;
compressor_id_any <<= compressor_id_list;
return orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, compressor_id_any);
}
示例8: policy_list
void
SyncScope_Setup::init (CORBA::ORB_ptr orb,
Messaging::SyncScope value)
{
CORBA::PolicyManager_var policy_manager =
RIR_Narrow<CORBA::PolicyManager>::resolve (orb,
"ORBPolicyManager");
CORBA::PolicyList policy_list (1);
policy_list.length (1);
CORBA::Any sync_scope;
sync_scope <<= value;
// @@ We need a helper class that automatically calls the
// destroy() method on each policy...
policy_list[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
sync_scope);
policy_manager->set_policy_overrides (policy_list,
CORBA::ADD_OVERRIDE);
policy_list[0]->destroy ();
}
示例9: directory
//.........这里部分代码省略.........
// on the command-line;
u_short port =
orb->orb_core ()->orb_params ()->service_port (TAO::MCAST_NAMESERVICE);
if (port == 0)
{
// Check environment var. for multicast port.
const char *port_number =
ACE_OS::getenv ("NameServicePort");
if (port_number != 0)
port = static_cast<u_short> (ACE_OS::atoi (port_number));
}
// Port wasn't specified on the command-line or in environment -
// use the default.
if (port == 0)
port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT;
// Instantiate a handler which will handle client requests for
// the root Naming Context ior, received on the multicast port.
ACE_NEW_RETURN (this->ior_multicast_,
TAO_IOR_Multicast (),
-1);
if (mde.length () != 0)
{
if (this->ior_multicast_->init (this->naming_service_ior_.in (),
mde.c_str (),
TAO_SERVICEID_NAMESERVICE) == -1)
return -1;
}
else
{
if (this->ior_multicast_->init (this->naming_service_ior_.in (),
port,
#if defined (ACE_HAS_IPV6)
ACE_DEFAULT_MULTICASTV6_ADDR,
#else
ACE_DEFAULT_MULTICAST_ADDR,
#endif /* ACE_HAS_IPV6 */
TAO_SERVICEID_NAMESERVICE) == -1)
return -1;
}
// Register event handler for the ior multicast.
if (reactor->register_handler (this->ior_multicast_,
ACE_Event_Handler::READ_MASK) == -1)
{
if (TAO_debug_level > 0)
ORBSVCS_DEBUG ((LM_DEBUG,
"TAO_Naming_Server: cannot register Event handler\n"));
return -1;
}
if (TAO_debug_level > 0)
ORBSVCS_DEBUG ((LM_DEBUG,
"TAO_Naming_Server: The multicast server setup is done.\n"));
}
#else
ACE_UNUSED_ARG (enable_multicast);
#endif /* ACE_HAS_IP_MULTICAST */
#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
if (use_round_trip_timeout == 1)
{
TimeBase::TimeT roundTripTimeoutVal = round_trip_timeout;
CORBA::Any anyObjectVal;
anyObjectVal <<= roundTripTimeoutVal;
CORBA::PolicyList polList (1);
polList.length (1);
polList[0] = orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
anyObjectVal);
// set a timeout on the orb
//
CORBA::Object_var orbPolicyManagerObj =
orb->resolve_initial_references ("ORBPolicyManager");
CORBA::PolicyManager_var orbPolicyManager =
CORBA::PolicyManager::_narrow (orbPolicyManagerObj.in ());
orbPolicyManager->set_policy_overrides (polList, CORBA::SET_OVERRIDE);
polList[0]->destroy ();
polList[0] = CORBA::Policy::_nil ();
}
#else
ACE_UNUSED_ARG (use_round_trip_timeout);
ACE_UNUSED_ARG (round_trip_timeout);
#endif /* TAO_HAS_CORBA_MESSAGING */
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception (
"TAO_Naming_Server::init_new_naming");
return -1;
}
return 0;
}
示例10: buffering_constraint_policy_list
void
setup_buffering_constraints (CORBA::ORB_ptr orb)
{
// Obtain PolicyCurrent.
CORBA::Object_var object = orb->resolve_initial_references ("PolicyCurrent");
// Narrow down to correct type.
CORBA::PolicyCurrent_var policy_current =
CORBA::PolicyCurrent::_narrow (object.in ());
// Start off with no constraints.
TAO::BufferingConstraint buffering_constraint;
buffering_constraint.mode = TAO::BUFFER_MESSAGE_COUNT;
buffering_constraint.message_count = message_count;
buffering_constraint.message_bytes = 0;
buffering_constraint.timeout = 0;
// Setup the buffering constraint any.
CORBA::Any buffering_constraint_any;
buffering_constraint_any <<= buffering_constraint;
// Setup the buffering constraint policy list.
CORBA::PolicyList buffering_constraint_policy_list (1);
buffering_constraint_policy_list.length (1);
// Setup the buffering constraint policy.
buffering_constraint_policy_list[0] =
orb->create_policy (TAO::BUFFERING_CONSTRAINT_POLICY_TYPE,
buffering_constraint_any);
// Setup the constraints (at the ORB level).
policy_current->set_policy_overrides (buffering_constraint_policy_list,
CORBA::ADD_OVERRIDE);
// We are done with the policy.
buffering_constraint_policy_list[0]->destroy ();
// Setup the none sync scope policy, i.e., the ORB will buffer AMI
// calls.
Messaging::SyncScope sync_none = Messaging::SYNC_NONE;
// Setup the none sync scope any.
CORBA::Any sync_none_any;
sync_none_any <<= sync_none;
// Setup the none sync scope policy list.
CORBA::PolicyList sync_none_policy_list (1);
sync_none_policy_list.length (1);
// Setup the none sync scope policy.
sync_none_policy_list[0] =
orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
sync_none_any);
// Setup the none sync scope (at the ORB level).
policy_current->set_policy_overrides (sync_none_policy_list,
CORBA::ADD_OVERRIDE);
// We are now done with these policies.
sync_none_policy_list[0]->destroy ();
}