poa.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,826 行 · 第 1/5 页
CPP
1,826 行
#include "tao/PortableServer/POA.h"
ACE_RCSID (PortableServer,
POA,
"POA.cpp,v 1.107 2003/11/25 22:10:36 bala Exp")
//
// ImplRepo related.
//
#if (TAO_HAS_MINIMUM_CORBA == 0)
# include "tao/PortableServer/ImR_LocatorC.h"
# include "tao/PortableServer/ImplRepo_i.h"
#endif /* TAO_HAS_MINIMUM_CORBA */
#include "tao/StringSeqC.h"
#include "tao/PortableServer/IORInfo.h"
#include "tao/PortableServer/ObjectReferenceTemplate.h"
#include "tao/PortableServer/Default_Acceptor_Filter.h"
#include "tao/ORB_Core.h"
#include "tao/ORB.h"
#include "tao/Server_Strategy_Factory.h"
#include "tao/Acceptor_Registry.h"
#include "tao/Thread_Lane_Resources.h"
#include "tao/Environment.h"
#include "tao/Exception.h"
#include "tao/Stub.h"
#include "tao/Profile.h"
#include "tao/TSS_Resources.h"
#include "tao/debug.h"
#include "tao/IORInterceptor/IORInterceptor_List.h"
#include "Default_Acceptor_Filter.h"
#include "ace/OS_NS_wchar.h"
#include "ace/OS_NS_sys_time.h"
#include "ace/OS_NS_netdb.h"
#include "PortableGroup_Hooks.h"
// auto_ptr class
#include "ace/Auto_Ptr.h"
#if !defined (__ACE_INLINE__)
# include "POA.i"
#endif /* ! __ACE_INLINE__ */
// This is the TAO_Object_key-prefix that is appended to all TAO Object keys.
// It's an array of octets representing ^t^a^o/0 in octal.
CORBA::Octet
TAO_POA::objectkey_prefix [TAO_POA::TAO_OBJECTKEY_PREFIX_SIZE] = {
024, // octal for ^t
001, // octal for ^a
017, // octal for ^o
000
};
TAO_POA*
TAO_POA::_tao_poa_downcast(void)
{
return this;
}
#if (TAO_HAS_MINIMUM_POA == 0)
PortableServer::ThreadPolicy_ptr
TAO_POA::create_thread_policy (PortableServer::ThreadPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Thread_Policy *thread_policy = 0;
ACE_NEW_THROW_EX (thread_policy,
TAO_Thread_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::ThreadPolicy::_nil ());
return thread_policy;
}
#endif /* TAO_HAS_MINIMUM_POA == 0 */
PortableServer::LifespanPolicy_ptr
TAO_POA::create_lifespan_policy (PortableServer::LifespanPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Lifespan_Policy *lifespan_policy = 0;
ACE_NEW_THROW_EX (lifespan_policy,
TAO_Lifespan_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::LifespanPolicy::_nil ());
return lifespan_policy;
}
PortableServer::IdUniquenessPolicy_ptr
TAO_POA::create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Id_Uniqueness_Policy *id_uniqueness_policy = 0;
ACE_NEW_THROW_EX (id_uniqueness_policy,
TAO_Id_Uniqueness_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::IdUniquenessPolicy::_nil ());
return id_uniqueness_policy;
}
PortableServer::IdAssignmentPolicy_ptr
TAO_POA::create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Id_Assignment_Policy *id_assignment_policy = 0;
ACE_NEW_THROW_EX (id_assignment_policy,
TAO_Id_Assignment_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::IdAssignmentPolicy::_nil ());
return id_assignment_policy;
}
#if (TAO_HAS_MINIMUM_POA == 0)
PortableServer::ImplicitActivationPolicy_ptr
TAO_POA::create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Implicit_Activation_Policy *implicit_activation_policy = 0;
ACE_NEW_THROW_EX (implicit_activation_policy,
TAO_Implicit_Activation_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::ImplicitActivationPolicy::_nil ());
return implicit_activation_policy;
}
PortableServer::ServantRetentionPolicy_ptr
TAO_POA::create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Servant_Retention_Policy *servant_retention_policy = 0;
ACE_NEW_THROW_EX (servant_retention_policy,
TAO_Servant_Retention_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::ServantRetentionPolicy::_nil ());
return servant_retention_policy;
}
PortableServer::RequestProcessingPolicy_ptr
TAO_POA::create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_Request_Processing_Policy *request_processing_policy = 0;
ACE_NEW_THROW_EX (request_processing_policy,
TAO_Request_Processing_Policy (value),
CORBA::NO_MEMORY ());
ACE_CHECK_RETURN (PortableServer::RequestProcessingPolicy::_nil ());
return request_processing_policy;
}
#endif /* TAO_HAS_MINIMUM_POA == 0 */
void
TAO_POA::set_obj_ref_factory (
PortableInterceptor::ObjectReferenceFactory *current_factory
ACE_ENV_ARG_DECL_NOT_USED)
{
CORBA::add_ref (current_factory);
this->obj_ref_factory_ = current_factory;
}
TAO_POA::TAO_POA (const TAO_POA::String &name,
TAO_POA_Manager &poa_manager,
const TAO_POA_Policy_Set &policies,
TAO_POA *parent,
ACE_Lock &lock,
TAO_SYNCH_MUTEX &thread_lock,
TAO_ORB_Core &orb_core,
TAO_Object_Adapter *object_adapter
ACE_ENV_ARG_DECL)
: name_ (name),
poa_manager_ (poa_manager),
tagged_component_ (),
tagged_component_id_ (),
profile_id_array_ (0),
policies_ (policies),
parent_ (parent),
active_object_map_ (0),
adapter_state_ (PortableInterceptor::HOLDING),
#if (TAO_HAS_MINIMUM_POA == 0)
adapter_activator_ (),
servant_activator_ (),
servant_locator_ (),
default_servant_ (),
#endif /* TAO_HAS_MINIMUM_POA == 0 */
//
// ImplRepo related.
//
#if (TAO_HAS_MINIMUM_CORBA == 0)
server_object_ (0),
use_imr_ (1),
#endif /* TAO_HAS_MINIMUM_CORBA */
children_ (),
lock_ (lock),
creation_time_ (ACE_OS::gettimeofday ()),
orb_core_ (orb_core),
object_adapter_ (object_adapter),
cleanup_in_progress_ (0),
etherealize_objects_ (1),
outstanding_requests_ (0),
outstanding_requests_condition_ (thread_lock),
wait_for_completion_pending_ (0),
waiting_destruction_ (0),
servant_deactivation_condition_ (thread_lock),
waiting_servant_deactivation_ (0),
single_threaded_lock_ (0),
caller_key_to_object_ (0),
servant_for_key_to_object_ (0)
{
// Parse the policies that are used in the critical path in
// a cache.
this->cached_policies_.update (this->policies_
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
#if (TAO_HAS_MINIMUM_POA == 1)
// If this is the RootPOA, set the value of the ImplicitActivationPolicy
// to IMPLICIT_ACTIVATION since it is impossible to pass the policy
// as it is not compiled into the library.
//
// If the ImplicitActivationPolicy policy is ever compiled in the
// minimum POA builds, remove this code and remove the guards
// in Object_Adapter.cpp when changing the default policy for the
// RootPOA.
if (ACE_OS::strcmp (this->name_.c_str (),
TAO_DEFAULT_ROOTPOA_NAME) == 0)
{
this->cached_policies_.implicit_activation
(PortableServer::IMPLICIT_ACTIVATION);
}
#endif /* TAO_HAS_MINIMUM_POA == 1 */
// Set the folded name of this POA.
this->set_folded_name ();
// Create the active object map.
TAO_Active_Object_Map *active_object_map = 0;
ACE_NEW_THROW_EX (active_object_map,
TAO_Active_Object_Map (!this->system_id (),
this->cached_policies_.id_uniqueness () == PortableServer::UNIQUE_ID,
this->persistent (),
this->orb_core_.server_factory ()->active_object_map_creation_parameters ()
ACE_ENV_ARG_PARAMETER),
CORBA::NO_MEMORY ());
// Give ownership of the new map to the auto pointer. Note, that it
// is important for the auto pointer to take ownership before
// checking for exception since we may need to delete the new map.
auto_ptr<TAO_Active_Object_Map> new_active_object_map (active_object_map);
// Check for exception in construction of the active object map.
ACE_CHECK;
#if (TAO_HAS_MINIMUM_POA == 0)
// Setup lock if POA is single threaded.
if (this->cached_policies_.thread () == PortableServer::SINGLE_THREAD_MODEL)
{
ACE_NEW_THROW_EX (this->single_threaded_lock_,
TAO_SYNCH_RECURSIVE_MUTEX,
CORBA::NO_MEMORY ());
}
#endif /* TAO_HAS_MINIMUM_POA == 0 */
// Register self with manager.
int result = this->poa_manager_.register_poa (this);
if (result != 0)
{
ACE_THROW (CORBA::OBJ_ADAPTER ());
}
// Add self to Object Adapter class.
result =
this->object_adapter ().bind_poa (this->folded_name_,
this,
this->system_name_.out ());
if (result != 0)
{
// Remove from POA Manager in case of errors. No checks of
// further errors...
this->poa_manager_.remove_poa (this);
ACE_THROW (CORBA::OBJ_ADAPTER ());
}
// Set the id for this POA.
this->set_id ();
// Finally everything is fine. Make sure to take ownership away
// from the auto pointer.
this->active_object_map_ = new_active_object_map.release ();
//
// ImplRepo related.
//
#if (TAO_HAS_MINIMUM_CORBA == 0)
if (this->cached_policies_.lifespan () == PortableServer::PERSISTENT)
{
int temp = this->use_imr_;
this->use_imr_ = 0;
ACE_TRY
{
this->imr_notify_startup (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
this->poa_manager_.remove_poa (this);
this->object_adapter ().unbind_poa (this,
this->folded_name_,
this->system_name_.in ());
ACE_RE_THROW;
}
ACE_ENDTRY;
ACE_CHECK;
this->use_imr_ = temp;
}
#endif /* TAO_HAS_MINIMUM_CORBA */
// Create an ObjectReferenceTemplate for this POA.
ACE_NEW_THROW_EX (this->def_ort_template_,
TAO_ObjectReferenceTemplate (
this->orb_core_.server_id (),
this->orb_core_.orbid (),
this),
CORBA::NO_MEMORY ());
ACE_CHECK;
this->ort_template_ = this->def_ort_template_;
// Must increase ref count since this->obj_ref_factory_ will
// descrease it upon destruction.
CORBA::add_ref (this->ort_template_.in ());
this->obj_ref_factory_ = this->ort_template_;
}
TAO_POA::~TAO_POA (void)
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?