object_adapter.h
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C头文件 代码 · 共 913 行 · 第 1/2 页
H
913 行
// -*- C++ -*-
//=============================================================================
/**
* @file Object_Adapter.h
*
* Object_Adapter.h,v 1.37 2003/08/17 20:31:38 ossama Exp
*
* @author Irfan Pyarali
*/
//=============================================================================
#ifndef TAO_OBJECT_ADAPTER_H
#define TAO_OBJECT_ADAPTER_H
#include /**/ "ace/pre.h"
#include "portableserver_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "Key_Adapters.h"
#include "poa_macros.h"
// Active Object Table
#include "Active_Object_Map.h"
#include "tao/Adapter.h"
#include "tao/Server_Strategy_Factory.h"
// Local Object
#include "tao/LocalObject.h"
#include "ace/Service_Config.h"
#include "ace/Reverse_Lock_T.h"
#include "ace/Condition_Thread_Mutex.h"
// Policy Validators
#include "Default_Policy_Validator.h"
// Policy Set
#include "POA_Policy_Set.h"
#if defined(_MSC_VER)
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif /* _MSC_VER >= 1200 */
#pragma warning(disable:4250)
#endif /* _MSC_VER */
// ****************************************************************
enum TAO_SERVANT_LOCATION
{
TAO_SERVANT_FOUND,
TAO_DEFAULT_SERVANT,
TAO_SERVANT_MANAGER,
TAO_SERVANT_NOT_FOUND
};
// ****************************************************************
// Forward declaration
class TAO_POA;
class TAO_POA_Manager;
class TAO_Temporary_Creation_Time;
class TAO_POA_Current_Impl;
class TAO_TSS_Resources;
class TAO_Transport;
class TAO_Servant_Dispatcher;
class TAO_PortableServer_Export TAO_POA_Current
: public PortableServer::Current,
public TAO_Local_RefCounted_Object
{
public:
/// Constructor
TAO_POA_Current (void);
/**
* Returns the POA on which the current request is being invoked.
* Can raise the <CORBA::NoContext> exception if this function is
* not invoked in the context of an upcall.
*/
PortableServer::POA_ptr get_POA (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext));
/**
* Returns the object id of the current request being invoked. Can
* raise the <CORBA::NoContext> exception if this function is not
* invoked in the context of an upcall.
*/
PortableServer::ObjectId *get_object_id (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext));
/// Returns the class that implements this interface.
TAO_POA_Current_Impl *implementation (void);
/// Sets the thread-specific pointer to the new POA Current state,
/// returning a pointer to the existing POA Current state.
TAO_POA_Current_Impl *implementation (TAO_POA_Current_Impl *new_current);
};
/**
* @class TAO_POA_Current_Impl
*
* @brief Implementation of the PortableServer::Current object.
*
* Objects of this class hold state information regarding the
* current POA invocation. Savvy readers will notice that this
* contains substantially more methods than the POA spec shows;
* they exist because the ORB either (a) needs them or (b) finds
* them useful for implementing a more efficient ORB.
* The intent is that instances of this class are held in
* Thread-Specific Storage so that upcalls can get context
* information regarding their invocation. The POA itself must
* insure that all <set_*> operations are performed in the
* execution thread so that the proper <TAO_POA_Current> pointer
* is obtained from TSS.
*/
class TAO_PortableServer_Export TAO_POA_Current_Impl
{
public:
friend class TAO_POA;
/// Return pointer to the invoking POA. Raises the
/// <CORBA::NoContext> exception.
PortableServer::POA_ptr get_POA (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext));
/**
* Return pointer to the object id through which this was invoked.
* This may be necessary in cases where a <Servant> is serving under
* the guise of multiple object ids. This has _out semantics Raises
* the <CORBA::NoContext> exception.
*/
PortableServer::ObjectId *get_object_id (ACE_ENV_SINGLE_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableServer::Current::NoContext));
/// Set the POA implementation.
void poa (TAO_POA *);
/// Get the POA implemantation
TAO_POA *poa (void) const;
/// ORB Core for this current.
TAO_ORB_Core &orb_core (void) const;
/// Set the object ID.
void object_id (const PortableServer::ObjectId &id);
/// Get the object ID.
const PortableServer::ObjectId &object_id (void) const;
/// Set the object key.
void object_key (const TAO::ObjectKey &key);
/// Get the object key.
const TAO::ObjectKey &object_key (void) const;
/// Set the servant for the current upcall.
void servant (PortableServer::Servant servant);
/// Get the servant for the current upcall.
PortableServer::Servant servant (void) const;
/// Set the priority for the current upcall.
void priority (CORBA::Short priority);
/// Get the priority for the current upcall.
CORBA::Short priority (void) const;
/// Convenience constructor combining construction & initialization.
TAO_POA_Current_Impl (void);
/// Return the previous current implementation.
TAO_POA_Current_Impl *previous (void) const;
/// Teardown the current for this request.
void teardown (void);
/// Setup the current.
void setup (TAO_POA *impl,
const TAO::ObjectKey &key);
protected:
/// The POA implementation invoking an upcall
TAO_POA *poa_;
/**
* The object ID of the current context. This is the user id and
* not the id the goes into the IOR. Note also that unlike the
* <object_key>, this field is stored by value.
*/
PortableServer::ObjectId object_id_;
/// The object key of the current context.
const TAO::ObjectKey *object_key_;
/// The servant for the current upcall.
PortableServer::Servant servant_;
/// The priority for the current upcall.
CORBA::Short priority_;
/// void *previous_current_impl_;
/// Current previous from <this>.
TAO_POA_Current_Impl *previous_current_impl_;
/// Is setup complete?
int setup_done_;
/// Pointer to tss resources.
TAO_TSS_Resources *tss_resources_;
// = Hidden because we don't allow these
TAO_POA_Current_Impl (const TAO_POA_Current_Impl &);
void operator= (const TAO_POA_Current_Impl &);
};
/**
* @class TAO_Object_Adapter
*
* @brief Defines the Object Adapter abstraction.
*
* This class will be used as a facade for the POAs in a server
*/
class TAO_PortableServer_Export TAO_Object_Adapter : public TAO_Adapter
{
public:
friend class TAO_POA;
typedef PortableServer::ObjectId poa_name;
typedef PortableServer::ObjectId_var poa_name_var;
typedef PortableServer::ObjectId_out poa_name_out;
/// Constructor.
TAO_Object_Adapter (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters,
TAO_ORB_Core &orb_core);
/// Destructor.
~TAO_Object_Adapter (void);
int dispatch_servant (const TAO::ObjectKey &key,
TAO_ServerRequest &req,
CORBA::Object_out forward_to
ACE_ENV_ARG_DECL);
int locate_servant (const TAO::ObjectKey &key
ACE_ENV_ARG_DECL);
TAO_SERVANT_LOCATION find_servant (const TAO::ObjectKey &key,
PortableServer::Servant &servant
ACE_ENV_ARG_DECL);
int find_poa (const poa_name &system_name,
CORBA::Boolean activate_it,
CORBA::Boolean root,
const TAO_Temporary_Creation_Time &poa_creation_time,
TAO_POA *&poa
ACE_ENV_ARG_DECL);
int bind_poa (const poa_name &folded_name,
TAO_POA *poa,
poa_name_out system_name);
int unbind_poa (TAO_POA *poa,
const poa_name &folded_name,
const poa_name &system_name);
int activate_poa (const poa_name &folded_name,
TAO_POA *&poa
ACE_ENV_ARG_DECL);
ACE_Lock &lock (void);
TAO_SYNCH_MUTEX &thread_lock (void);
ACE_Reverse_Lock<ACE_Lock> &reverse_lock (void);
/// Access the root poa.
TAO_POA *root_poa (void) const;
/// Access to ORB Core.
TAO_ORB_Core &orb_core (void) const;
/// Wait for non-servant upcalls to complete.
void wait_for_non_servant_upcalls_to_complete (CORBA::Environment &ACE_TRY_ENV);
/// Non-exception throwing version.
void wait_for_non_servant_upcalls_to_complete (void);
static CORBA::ULong transient_poa_name_size (void);
/// Return the validator.
TAO_Policy_Validator &validator (void);
/// Return the set of default policies.
TAO_POA_Policy_Set &default_poa_policies (void);
/// Set the servant dispatcher method. Ownership is transferred to
/// this Object Adapter. Note: This should only be called
/// at initialization.
void servant_dispatcher (TAO_Servant_Dispatcher *dispatcher);
/// Initialize the default set of POA policies.
void init_default_policies (TAO_POA_Policy_Set &policies
ACE_ENV_ARG_DECL);
// = The TAO_Adapter methods, please check tao/Adapter.h for the
// documentation
virtual void open (ACE_ENV_SINGLE_ARG_DECL);
virtual void close (int wait_for_completion
ACE_ENV_ARG_DECL);
virtual void check_close (int wait_for_completion
ACE_ENV_ARG_DECL);
virtual int priority (void) const;
virtual int dispatch (TAO::ObjectKey &key,
TAO_ServerRequest &request,
CORBA::Object_out foward_to
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException));
virtual const char *name (void) const;
virtual CORBA::Object_ptr root (void);
virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *,
const TAO_MProfile &);
virtual CORBA::Long initialize_collocated_object (TAO_Stub *,
CORBA::Object_ptr);
protected:
int locate_servant_i (const TAO::ObjectKey &key
ACE_ENV_ARG_DECL);
TAO_SERVANT_LOCATION find_servant_i (const TAO::ObjectKey &key,
PortableServer::Servant &servant
ACE_ENV_ARG_DECL);
void dispatch_servant_i (const TAO::ObjectKey &key,
TAO_ServerRequest &req,
void *context
ACE_ENV_ARG_DECL);
void locate_poa (const TAO::ObjectKey &key,
PortableServer::ObjectId &id,
TAO_POA *&poa
ACE_ENV_ARG_DECL);
int find_transient_poa (const poa_name &system_name,
CORBA::Boolean root,
const TAO_Temporary_Creation_Time &poa_creation_time,
TAO_POA *&poa
ACE_ENV_ARG_DECL);
int find_persistent_poa (const poa_name &system_name,
TAO_POA *&poa
ACE_ENV_ARG_DECL);
int bind_transient_poa (TAO_POA *poa,
poa_name_out system_name);
int bind_persistent_poa (const poa_name &folded_name,
TAO_POA *poa,
poa_name_out system_name);
int unbind_transient_poa (const poa_name &system_name);
int unbind_persistent_poa (const poa_name &folded_name,
const poa_name &system_name);
void set_default_server_protocol_policy (ACE_ENV_SINGLE_ARG_DECL);
static ACE_Lock *create_lock (int enable_locking,
TAO_SYNCH_MUTEX &thread_lock);
public:
/**
* @class Hint_Strategy
*
* @brief Base class for POA active hint strategy.
*
* This class also provides for common structures used by all
* the derived classes.
*/
class TAO_PortableServer_Export Hint_Strategy
{
public:
virtual ~Hint_Strategy (void);
virtual int find_persistent_poa (const poa_name &system_name,
TAO_POA *&poa
ACE_ENV_ARG_DECL) = 0;
virtual int bind_persistent_poa (const poa_name &folded_name,
TAO_POA *poa,
poa_name_out system_name) = 0;
virtual int unbind_persistent_poa (const poa_name &folded_name,
const poa_name &system_name) = 0;
void object_adapter (TAO_Object_Adapter *oa);
protected:
TAO_Object_Adapter *object_adapter_;
};
/**
* @class Active_Hint_Strategy
*
* @brief This class uses active demux hint for POA active hint
* strategy.
*
* This class will append an active hint to the POA name,
* making the POA lookups fast and predictable.
*/
class TAO_PortableServer_Export Active_Hint_Strategy : public Hint_Strategy
{
public:
Active_Hint_Strategy (CORBA::ULong map_size);
virtual ~Active_Hint_Strategy (void);
virtual int find_persistent_poa (const poa_name &system_name,
TAO_POA *&poa
ACE_ENV_ARG_DECL);
virtual int bind_persistent_poa (const poa_name &folded_name,
TAO_POA *poa,
poa_name_out system_name);
virtual int unbind_persistent_poa (const poa_name &folded_name,
const poa_name &system_name);
protected:
typedef ACE_Active_Map_Manager_Adapter<
poa_name,
TAO_POA *,
TAO_Preserve_Original_Key_Adapter> persistent_poa_system_map;
persistent_poa_system_map persistent_poa_system_map_;
};
/**
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?