rt_policy_i.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,410 行 · 第 1/3 页
CPP
1,410 行
CORBA::Policy_ptr
TAO_ServerProtocolPolicy::create (const CORBA::Any &val
ACE_ENV_ARG_DECL)
{
RTCORBA::ProtocolList *value = 0;
if ((val >>= value) == 0)
ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_VALUE),
CORBA::Policy::_nil ());
TAO_ServerProtocolPolicy *tmp = 0;
ACE_NEW_THROW_EX (tmp,
TAO_ServerProtocolPolicy (*value),
CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (CORBA::Policy::_nil ());
return tmp;
}
RTCORBA::ProtocolList *
TAO_ServerProtocolPolicy::protocols (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
RTCORBA::ProtocolList *tmp;
ACE_NEW_THROW_EX (tmp,
RTCORBA::ProtocolList (this->protocols_),
CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (0);
return tmp;
}
CORBA::PolicyType
TAO_ServerProtocolPolicy::policy_type (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return RTCORBA::SERVER_PROTOCOL_POLICY_TYPE;
}
CORBA::Policy_ptr
TAO_ServerProtocolPolicy::copy (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_ServerProtocolPolicy* tmp;
ACE_NEW_THROW_EX (tmp,
TAO_ServerProtocolPolicy (*this),
CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (CORBA::Policy::_nil ());
return tmp;
}
void
TAO_ServerProtocolPolicy::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
}
int
TAO_ServerProtocolPolicy::hook (TAO_ORB_Core *orb_core,
int &send_buffer_size,
int &recv_buffer_size,
int &no_delay,
int &enable_network_priority,
const char *protocol_type)
{
RTCORBA::ProtocolProperties_var properties =
RTCORBA::ProtocolProperties::_nil ();
// ServerProtocolProperties policy controls protocols configuration.
// Look for protocol properties in the effective ServerProtocolPolicy.
CORBA::Policy_var policy =
orb_core->get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL);
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
RTCORBA::ServerProtocolPolicy_var server_protocols_policy;
TAO_ServerProtocolPolicy *server_protocols = 0;
if (!CORBA::is_nil (policy.in ()))
{
server_protocols_policy =
RTCORBA::ServerProtocolPolicy::_narrow (policy.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
server_protocols =
ACE_dynamic_cast (TAO_ServerProtocolPolicy *,
server_protocols_policy.in ());
if (server_protocols != 0)
{
RTCORBA::ProtocolList & protocols =
server_protocols->protocols_rep ();
// Find protocol properties.
for (CORBA::ULong j = 0; j < protocols.length (); ++j)
{
if (protocols[j].protocol_type == IOP::TAG_INTERNET_IOP)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type,
"iiop") == 0)
break;
}
else if (protocols[j].protocol_type == TAO_TAG_UIOP_PROFILE)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "uiop") == 0)
break;
}
}
}
}
if (CORBA::is_nil (properties.in ()))
{
// TCP/UIOP/SHMIOP Properties were not specified in the
// effective policy.
// We must use ORB defaults.
policy = orb_core->get_default_policies ()->get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL);
if (!CORBA::is_nil (policy.in ()))
{
server_protocols_policy =
RTCORBA::ServerProtocolPolicy::_narrow (policy.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
server_protocols =
ACE_dynamic_cast (TAO_ServerProtocolPolicy *,
server_protocols_policy.in ());
if (!CORBA::is_nil (server_protocols))
{
// Find protocol properties for IIOP.
RTCORBA::ProtocolList & protocols =
server_protocols->protocols_rep ();
for (CORBA::ULong j = 0; j < protocols.length (); ++j)
{
if (protocols[j].protocol_type == IOP::TAG_INTERNET_IOP)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "iiop") == 0)
break;
}
else if (protocols[j].protocol_type ==
TAO_TAG_UIOP_PROFILE)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "uiop") == 0)
break;
}
}
}
}
}
if (ACE_OS::strcmp (protocol_type, "iiop") == 0)
{
RTCORBA::TCPProtocolProperties_var tcp_properties =
RTCORBA::TCPProtocolProperties::_narrow (properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
send_buffer_size =
tcp_properties->send_buffer_size (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
recv_buffer_size =
tcp_properties->recv_buffer_size (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
no_delay = tcp_properties->no_delay (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
enable_network_priority =
tcp_properties->enable_network_priority (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
if (ACE_OS::strcmp (protocol_type, "uiop") == 0)
{
RTCORBA::UnixDomainProtocolProperties_var uiop_properties =
RTCORBA::UnixDomainProtocolProperties::_narrow (properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (!CORBA::is_nil (uiop_properties.in ()))
{
// Extract and locally store properties of interest.
send_buffer_size =
uiop_properties->send_buffer_size (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
recv_buffer_size =
uiop_properties->recv_buffer_size (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
}
}
ACE_CATCHANY
{
if (TAO_debug_level > 4)
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"TAO_ServerProtocolPolicy::hook");
return -1;
}
ACE_ENDTRY;
return 0;
}
TAO_Cached_Policy_Type
TAO_ServerProtocolPolicy::_tao_cached_type (void) const
{
return TAO_CACHED_POLICY_RT_SERVER_PROTOCOL;
}
TAO_Policy_Scope
TAO_ServerProtocolPolicy::_tao_scope (void) const
{
return ACE_static_cast (TAO_Policy_Scope,
TAO_POLICY_ORB_SCOPE |
TAO_POLICY_POA_SCOPE);
}
RTCORBA::ProtocolList &
TAO_ServerProtocolPolicy::protocols_rep (void)
{
return protocols_;
}
// ****************************************************************
TAO_ClientProtocolPolicy::TAO_ClientProtocolPolicy (void)
{
}
TAO_ClientProtocolPolicy::TAO_ClientProtocolPolicy (const RTCORBA::ProtocolList &protocols)
: ACE_NESTED_CLASS (CORBA, Object) ()
, ACE_NESTED_CLASS (CORBA, Policy) ()
, ACE_NESTED_CLASS (CORBA, LocalObject) ()
, RTCORBA::ClientProtocolPolicy ()
, TAO_Local_RefCounted_Object ()
, protocols_ (protocols)
{
}
TAO_ClientProtocolPolicy::TAO_ClientProtocolPolicy (const TAO_ClientProtocolPolicy &rhs)
: ACE_NESTED_CLASS (CORBA, Object) ()
, ACE_NESTED_CLASS (CORBA, Policy) ()
, ACE_NESTED_CLASS (CORBA, LocalObject) ()
, RTCORBA::ClientProtocolPolicy ()
, TAO_Local_RefCounted_Object ()
, protocols_ (rhs.protocols_)
{
}
TAO_ClientProtocolPolicy::~TAO_ClientProtocolPolicy ()
{
}
CORBA::Policy_ptr
TAO_ClientProtocolPolicy::create (const CORBA::Any &val
ACE_ENV_ARG_DECL)
{
RTCORBA::ProtocolList *value = 0;
if ((val >>= value) == 0)
ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_VALUE),
CORBA::Policy::_nil ());
TAO_ClientProtocolPolicy *tmp = 0;
ACE_NEW_THROW_EX (tmp,
TAO_ClientProtocolPolicy (*value),
CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (CORBA::Policy::_nil ());
return tmp;
}
RTCORBA::ProtocolList *
TAO_ClientProtocolPolicy::protocols (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
RTCORBA::ProtocolList *tmp;
ACE_NEW_THROW_EX (tmp,
RTCORBA::ProtocolList (this->protocols_),
CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (0);
return tmp;
}
CORBA::PolicyType
TAO_ClientProtocolPolicy::policy_type (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
return RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE;
}
CORBA::Policy_ptr
TAO_ClientProtocolPolicy::copy (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_ClientProtocolPolicy* tmp;
ACE_NEW_THROW_EX (tmp,
TAO_ClientProtocolPolicy (*this),
CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
CORBA::COMPLETED_NO));
ACE_CHECK_RETURN (CORBA::Policy::_nil ());
return tmp;
}
void
TAO_ClientProtocolPolicy::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
}
int
TAO_ClientProtocolPolicy::hook (TAO_ORB_Core *orb_core,
int &send_buffer_size,
int &recv_buffer_size,
int &no_delay,
int &enable_network_priority,
const char *protocol_type)
{
RTCORBA::ProtocolProperties_var properties =
RTCORBA::ProtocolProperties::_nil ();
// Check ORB-level override for properties.
CORBA::Policy_var policy =
orb_core->policy_manager ()->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL);
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
RTCORBA::ClientProtocolPolicy_var client_protocols_policy;
TAO_ClientProtocolPolicy *client_protocols = 0;
if (!CORBA::is_nil (policy.in ()))
{
client_protocols_policy =
RTCORBA::ClientProtocolPolicy::_narrow (policy.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
client_protocols =
ACE_dynamic_cast (TAO_ClientProtocolPolicy *,
client_protocols_policy.in ());
if (client_protocols != 0)
{
//TAO_ClientProtocolPolicy
RTCORBA::ProtocolList & protocols =
client_protocols->protocols_rep ();
for (CORBA::ULong j = 0; j < protocols.length (); ++j)
{
if (protocols[j].protocol_type == IOP::TAG_INTERNET_IOP)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "iiop") == 0)
break;
}
else if (protocols[j].protocol_type == TAO_TAG_UIOP_PROFILE)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "uiop") == 0)
break;
}
}
}
}
if (CORBA::is_nil (properties.in ()))
{
// No tcp/uiop properties in ORB-level override. Use ORB
// defaults. ORB defaults should never be null - they were
// initialized by the ORB_Core.
policy =
orb_core->get_default_policies ()->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL);
if (!CORBA::is_nil (policy.in ()))
{
client_protocols_policy =
RTCORBA::ClientProtocolPolicy::_narrow (policy.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
client_protocols =
ACE_dynamic_cast (TAO_ClientProtocolPolicy *,
client_protocols_policy.in ());
if (client_protocols != 0)
{
RTCORBA::ProtocolList & protocols =
client_protocols->protocols_rep ();
for (CORBA::ULong j = 0; j < protocols.length (); ++j)
{
if (protocols[j].protocol_type == IOP::TAG_INTERNET_IOP)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "iiop") == 0)
break;
}
else if (protocols[j].protocol_type ==
TAO_TAG_UIOP_PROFILE)
{
properties =
RTCORBA::ProtocolProperties::_narrow (
protocols[j].transport_protocol_properties.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (ACE_OS::strcmp (protocol_type, "uiop") == 0)
break;
}
}
}
}
}
if (ACE_OS::strcmp (protocol_type, "iiop") == 0)
{
RTCORBA::TCPProtocolProperties_var tcp_properties =
RTCORBA::TCPProtocolProperties::_narrow (properties.in ()
ACE_ENV_ARG_PARAMETER);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?