From 93cb1e39a410dfb32d10ee82ef11b85a040dc36a Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 25 Jun 2001 12:57:34 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'bug_575_stage_1'. --- TAO/tao/GIOP_Message_State.inl | 46 ++ TAO/tao/Incoming_Message_Queue.cpp | 121 ++++ TAO/tao/Incoming_Message_Queue.h | 99 +++ TAO/tao/Incoming_Message_Queue.inl | 55 ++ TAO/tao/LIST_OF_TODO | 10 + TAO/tao/ORB_Core.h | 1376 ++++++++++++++++++++++++++++++++++++ TAO/tao/ORB_Core.i | 701 ++++++++++++++++++ TAO/tao/default_resource.cpp | 880 +++++++++++++++++++++++ 8 files changed, 3288 insertions(+) create mode 100644 TAO/tao/GIOP_Message_State.inl create mode 100644 TAO/tao/Incoming_Message_Queue.cpp create mode 100644 TAO/tao/Incoming_Message_Queue.h create mode 100644 TAO/tao/Incoming_Message_Queue.inl create mode 100644 TAO/tao/LIST_OF_TODO create mode 100644 TAO/tao/ORB_Core.h create mode 100644 TAO/tao/ORB_Core.i create mode 100644 TAO/tao/default_resource.cpp diff --git a/TAO/tao/GIOP_Message_State.inl b/TAO/tao/GIOP_Message_State.inl new file mode 100644 index 00000000000..9238ba596d4 --- /dev/null +++ b/TAO/tao/GIOP_Message_State.inl @@ -0,0 +1,46 @@ +// -*- C++ -*- + +//$Id$ + +ACE_INLINE CORBA::ULong +TAO_GIOP_Message_State::message_size (void) const +{ + return this->message_size_ + TAO_GIOP_MESSAGE_HEADER_LEN; +} + +ACE_INLINE CORBA::ULong +TAO_GIOP_Message_State::payload_size (void) const +{ + return this->message_size_; +} + +ACE_INLINE CORBA::Octet +TAO_GIOP_Message_State::byte_order (void) const +{ + return this->byte_order_; +} + +#if 0 +ACE_INLINE int +TAO_GIOP_Message_State::message_fragmented (void) +{ + if (this->more_fragments) + return 1; + + return 0; +} + +ACE_INLINE void +TAO_GIOP_Message_State::reset (int /*reset_contents*/) +{ + this->message_size = 0; + this->more_fragments = 0; +} + +ACE_INLINE CORBA::Boolean +TAO_GIOP_Message_State::header_received (void) const +{ + return this->message_size != 0; +} + +#endif diff --git a/TAO/tao/Incoming_Message_Queue.cpp b/TAO/tao/Incoming_Message_Queue.cpp new file mode 100644 index 00000000000..e5b239b775c --- /dev/null +++ b/TAO/tao/Incoming_Message_Queue.cpp @@ -0,0 +1,121 @@ +#include "Incoming_Message_Queue.h" +#include "ORB_Core.h" +#include "debug.h" + +#if !defined (__ACE_INLINE__) +# include "Incoming_Message_Queue.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (tao, Incoming_Message_Queue, "$Id$") + + +TAO_Incoming_Message_Queue::TAO_Incoming_Message_Queue (TAO_ORB_Core *orb_core) + : queued_data_ (0), + size_ (0), + orb_core_ (orb_core) +{ +} + +TAO_Incoming_Message_Queue::~TAO_Incoming_Message_Queue (void) +{ + // Need to delete all the unused data-blocks +} + +int +TAO_Incoming_Message_Queue::add_message (ACE_Message_Block *incoming, + size_t missing_data, + CORBA::Octet byte_order) + +{ + // Allocate memory for TAO_Queued_Data + TAO_Queued_Data *qd = this->get_node (); + + if (qd == 0) + { + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Could not make a node \n"))); + } + return -1; + } + + // Set the data block + qd->msg_block_ = incoming; + + // Set the byte_order + qd->byte_order_ = byte_order; + + qd->missing_data_ = missing_data; + + this->add_node (qd); + + // increment the size of the list + ++this->size_; + + return 1; +} + +void +TAO_Incoming_Message_Queue::copy_message (ACE_Message_Block &block) +{ + if (this->size_ > 0) + { + size_t n = 0; + + if (block.length () <= this->queued_data_->missing_data_) + { + n = block.length (); + } + else + { + n = this->queued_data_->missing_data_; + } + + this->queued_data_->msg_block_->copy (block.rd_ptr (), + n); + this->queued_data_->missing_data_ -= n; + } +} + +ACE_Message_Block * +TAO_Incoming_Message_Queue::dequeue_head (CORBA::Octet &byte_order) +{ + TAO_Queued_Data *tmp = + this->queued_data_->next_; + + if (tmp->missing_data_ != 0) + return 0; + + ACE_Message_Block *db = + tmp->msg_block_; + + this->queued_data_->next_ = tmp->next_; + byte_order = tmp->byte_order_; + + delete tmp; + + // Decrease the size + --this->size_; + + return db; +} + +int +TAO_Incoming_Message_Queue::add_node ( + TAO_Incoming_Message_Queue::TAO_Queued_Data *nd) +{ + if (this->size_ == 0) + { + this->queued_data_ = nd; + this->queued_data_->next_ = this->queued_data_; + } + else + { + nd->next_ = this->queued_data_->next_; + this->queued_data_->next_ = nd; + this->queued_data_ = nd; + } + + return 0; +} diff --git a/TAO/tao/Incoming_Message_Queue.h b/TAO/tao/Incoming_Message_Queue.h new file mode 100644 index 00000000000..ffe0f379e1d --- /dev/null +++ b/TAO/tao/Incoming_Message_Queue.h @@ -0,0 +1,99 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Incoming_Queued_Message.h + * + * $Id$ + * + * @author Balachandran Natarajan + */ +//============================================================================= + +#ifndef TAO_INCOMING_MESSAGE_QUEUE_H +#define TAO_INCOMING_MESSAGE_QUEUE_H +#include "ace/pre.h" + +#include "corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/// Forward declarations +class ACE_Data_Block; +class TAO_ORB_Core; +class TAO_Queued_Data; +class TAO_Transport; + +/** + * @class TAO_Incoming_Message_Queue + * //@@Bala: Documentation.. + */ + +class TAO_Export TAO_Incoming_Message_Queue +{ +public: + /// Ctor. + TAO_Incoming_Message_Queue (TAO_ORB_Core *orb_core); + + /// Dtor. + ~TAO_Incoming_Message_Queue (void); + + + /// @@Bala:Docu + int add_message (ACE_Message_Block *block, + size_t missing_data, + CORBA::Octet byte_order); + + void copy_message (ACE_Message_Block &block); + + CORBA::ULong queue_length (void); + + int is_complete_message (void); + + size_t missing_data (void) const; + void missing_data (size_t data); + + char *wr_ptr (void) const; + ACE_Message_Block *dequeue_head (CORBA::Octet &byte_order); + +private: + + friend class TAO_Transport; + + /// @@Bala:Docu + class TAO_Export TAO_Queued_Data + { + public: + TAO_Queued_Data (void); + + /// The actual message queue + ACE_Message_Block *msg_block_; + + CORBA::ULong missing_data_; + + CORBA::Octet byte_order_; + + TAO_Queued_Data *next_; + }; + + TAO_Queued_Data* get_node (void); + int add_node (TAO_Queued_Data *nd); + +private: + /// + TAO_Queued_Data *queued_data_; + + /// @@Bala:Docu + CORBA::ULong size_; + + TAO_ORB_Core *orb_core_; +}; + + +#if defined (__ACE_INLINE__) +# include "Incoming_Message_Queue.inl" +#endif /* __ACE_INLINE__ */ + +#endif /*TAO_INCOMING_MESSAGE_QUEUE_H*/ diff --git a/TAO/tao/Incoming_Message_Queue.inl b/TAO/tao/Incoming_Message_Queue.inl new file mode 100644 index 00000000000..10713dcf732 --- /dev/null +++ b/TAO/tao/Incoming_Message_Queue.inl @@ -0,0 +1,55 @@ +// -*- C++ -*- +//$Id$ +ACE_INLINE CORBA::ULong +TAO_Incoming_Message_Queue::queue_length (void) +{ + return this->size_; +} + +ACE_INLINE int +TAO_Incoming_Message_Queue::is_complete_message (void) +{ + if (this->size_ != 0 && + this->queued_data_->missing_data_ == 0) + return 0; + + return 1; +} + +ACE_INLINE char * +TAO_Incoming_Message_Queue::wr_ptr (void) const +{ + return this->queued_data_->msg_block_->wr_ptr (); +} + +ACE_INLINE size_t +TAO_Incoming_Message_Queue::missing_data (void) const +{ + if (this->size_ != 0) + return this->queued_data_->missing_data_; + + return 0; +} + + + +ACE_INLINE TAO_Incoming_Message_Queue::TAO_Queued_Data * +TAO_Incoming_Message_Queue::get_node (void) +{ + // @@TODO: Use the global pool for allocationg... + TAO_Queued_Data *qd = 0; + ACE_NEW_RETURN (qd, + TAO_Queued_Data, + 0); + + return qd; +} + +ACE_INLINE +TAO_Incoming_Message_Queue::TAO_Queued_Data::TAO_Queued_Data (void) + : msg_block_ (0), + missing_data_ (0), + byte_order_ (0), + next_ (0) +{ +} diff --git a/TAO/tao/LIST_OF_TODO b/TAO/tao/LIST_OF_TODO new file mode 100644 index 00000000000..75a0901a22e --- /dev/null +++ b/TAO/tao/LIST_OF_TODO @@ -0,0 +1,10 @@ +- Fragmentation +- test for Muli-threaded client & server (muxing tests) +- test LongUpCalls +- Problem with two messages coming in two diffrent GIOP versions.. +- Remove allocation of data block for reply handlers. Can use + stack based stuff +- Remove the allocation of data blocks in Reply_Params. +- AMI tests +- run purify quantify +- DSI_Gateway tests diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h new file mode 100644 index 00000000000..0ff9e111629 --- /dev/null +++ b/TAO/tao/ORB_Core.h @@ -0,0 +1,1376 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file ORB_Core.h + * + * $Id$ + * + * @author DOC Center - Washington University at St. Louis + * @author DOC Laboratory - University of California at Irvine + */ +// =================================================================== + +#ifndef TAO_ORB_CORE_H +#define TAO_ORB_CORE_H +#include "ace/pre.h" + +#include "corbafwd.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ORB.h" +#include "Environment.h" +#include "Policy_Manager.h" +#include "Resource_Factory.h" +#include "params.h" +#include "TAO_Singleton_Manager.h" +#include "TAO_Singleton.h" +#include "Adapter.h" +#include "PolicyFactory_Registry.h" +#include "Parser_Registry.h" +#include "Service_Callbacks.h" +#include "Fault_Tolerance_Service.h" +#include "Cleanup_Func_Registry.h" +#include "Object_Ref_Table.h" + +// Interceptor definitions. +#include "PortableInterceptorC.h" +#include "Interceptor_List.h" + +#include "Protocols_Hooks.h" + +#include "ace/Hash_Map_Manager.h" +#include "ace/Thread_Manager.h" + +// Forward declarations +class TAO_Acceptor; +class TAO_Connector; +class TAO_Acceptor_Registry; +class TAO_Connector_Registry; + +class TAO_Resource_Factory; +class TAO_Client_Strategy_Factory; +class TAO_Server_Strategy_Factory; +class TAO_Transport_Cache_Manager; + +class TAO_TSS_Resources; +class TAO_Reactor_Registry; +class TAO_Leader_Follower; +class TAO_LF_Strategy; +class TAO_RT_ORB; +class TAO_RT_Current; +class TAO_MProfile; +class TAO_Profile; +class TAO_GIOP_Invocation; + +class TAO_Endpoint_Selector_Factory; +class TAO_Message_State_Factory; +class TAO_ServerRequest; +class TAO_Protocols_Hooks; +class TAO_BiDir_Adapter; + +class TAO_Flushing_Strategy; + +class TAO_Stub_Factory; +class TAO_Endpoint_Selector_Factory; +class TAO_Service_Context; + +#if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) + +class TAO_Buffering_Constraint_Policy; +class TAO_Eager_Buffering_Sync_Strategy; +class TAO_Delayed_Buffering_Sync_Strategy; + +#endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ + +class TAO_Transport_Sync_Strategy; +class TAO_Sync_Strategy; + +class TAO_POA_Extension_Initializer; + +// **************************************************************** + +/** + * @class TAO_ORB_Core_TSS_Resources + * + * @brief The TSS resoures of an ORB core. + * + * This class is used by the ORB_Core to store the resources + * potentially bound to a thread in TSS storage. The members are public + * because only the ORB Core is expected to access them. + */ +class TAO_Export TAO_ORB_Core_TSS_Resources +{ +public: + + /// Constructor + TAO_ORB_Core_TSS_Resources (void); + + /// destructor + ~TAO_ORB_Core_TSS_Resources (void); + +private: + + /// The ORB Core TSS resources should not be copied + ACE_UNIMPLEMENTED_FUNC (TAO_ORB_Core_TSS_Resources (const TAO_ORB_Core_TSS_Resources&)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_ORB_Core_TSS_Resources&)) + +public: + /** + * @todo + * The rest of the resources are not currently in use, just a plan + * for the future... + */ + + /// The allocators for the output CDR streams. + //@{ + ACE_Allocator *output_cdr_dblock_allocator_; + ACE_Allocator *output_cdr_buffer_allocator_; + ACE_Allocator *output_cdr_msgblock_allocator_; + //@} + + /// The allocators for the input CDR streams. + //@{ + ACE_Allocator *input_cdr_dblock_allocator_; + ACE_Allocator *input_cdr_buffer_allocator_; + ACE_Allocator *input_cdr_msgblock_allocator_; + //@} + + /// This is is just a place holder, in the future the transport + /// cache will be separated from the connectors and it will be a + /// (potentially) TSS object. + TAO_Transport_Cache_Manager *transport_cache_; + + /// Counter for how (nested) calls this thread has made to run the + /// event loop. + int event_loop_thread_; + + /// Counter for how many times this thread has become a client + /// leader. + int client_leader_thread_; + + /// Condition variable for the leader follower model. + TAO_SYNCH_CONDITION* leader_follower_condition_variable_; + + /// The Reactor Holder that we should callback when destroying the + /// cookie. + TAO_Reactor_Registry *reactor_registry_; + + /// A TSS magic cookie used by the Reactor_Registry + void *reactor_registry_cookie_; + + /// Generic container for thread-specific objects. + ACE_Array_Base ts_objects_; + + /// Pointer to the ORB core. Needed to get access to the TSS + /// cleanup functions for the TSS objects stored in the TSS object + /// array in this class. + TAO_ORB_Core *orb_core_; +}; + +// **************************************************************** + +/** + * @class TAO_ORB_Core + * + * @brief Encapsulates the state of an ORB. + * + * This is the implementation class for the CORBA::ORB interface. The + * class also encapsulates the access to the ORB resources and its + * state. + * @par + * Some resources can be TSS or global, those resources are always + * accessed through a TSS interface, but are allocated using the + * Resource_Factory. If the resource is really global the + * Resource_Factory will simply return a pointer to the global + * instance. + */ +class TAO_Export TAO_ORB_Core +{ + friend class TAO_ORB_Core_Auto_Ptr; + friend class TAO_ORB_Table; + friend CORBA::ORB_ptr CORBA::ORB_init (int &, + char *argv[], + const char *, + CORBA_Environment &); + +public: + + /// Constructor. + TAO_ORB_Core (const char* id); + + /// Accessor for the ORB parameters. + TAO_ORB_Parameters *orb_params (void); + + /** + * @todo + * In the future this hook should change, instead of hardcoding the + * object we should add a "Resolver" to the ORB, so the "POACurrent" + * object returns a per-ORB object. + * @par + * Similarly, each ORB should implement the TSS pattern to put the + * POA_Current_Impl in a void* slot. The current approach *does* + * decouple the POA from the ORB, but it cannot add new adapters or + * other components transparently. + */ + /// Accessor to the POA current. + //@{ + CORBA::Object_ptr poa_current(void); + void poa_current (CORBA::Object_ptr poa_current); + //@} + + ///Get the connector registry + TAO_Connector_Registry *connector_registry (void); + + ///Get the acceptor registry + TAO_Acceptor_Registry *acceptor_registry (void); + + ///Get the IOR parser registry + TAO_Parser_Registry *parser_registry (void); + + /// Return pointer to the policy factory registry associated with + /// this ORB core. + TAO_PolicyFactory_Registry *policy_factory_registry (void); + + /// Get the protocol factories + TAO_ProtocolFactorySet *protocol_factories (void); + + /// Get pointer to the ORB. + CORBA::ORB_ptr orb (void); + + /// Wrappers that forward the request to the concurrency strategy. + ACE_Reactor *reactor (void); + ACE_Reactor *reactor (TAO_Acceptor *acceptor); + + /// Get the ACE_Thread_Manager + ACE_Thread_Manager *thr_mgr (void); + + /// Return the RootPOA, or try to load it if not initialized already. + CORBA::Object_ptr root_poa (CORBA::Environment &ACE_TRY_ENV); + + /// Get the adapter registry + TAO_Adapter_Registry *adapter_registry (void); + + /// Add a POA extension initializer. The ORB Core takes ownership of + /// the passed in instance. + void add_poa_extension_initializer (TAO_POA_Extension_Initializer *initializer); + + /// Get the POA extension initializers. + TAO_POA_Extension_Initializer *poa_extension_initializer (void); + + /// @name Collocation Strategies + //@{ + enum + { + /// Indicate object should refer to ORB for either one of the + /// following strategies. + ORB_CONTROL, + + /// Collocated calls will go thru POA. + THRU_POA, + + /// Collocated calls invoke operation on Servant directly. + DIRECT + }; + + /** + * This method returns the right collocation strategy, if any, + * to be used to perform a method invocation on the given object. + * + * @note + * No-Collocation is a special case of collocation. + */ + static int collocation_strategy ( + CORBA::Object_ptr object); + //@} + + /** + * @name Default Code Set Translators + * + * Get the default codeset translators. + * + * @par + * In most configurations these are just objects, but they can + * be set to something different if the native character sets are + * not ISO8869 (aka Latin/1, UTF-8) and UNICODE (aka UTF-16). + * + * @note + * This is just note on how the translator database coule be + * implemented: use the Service Configurator to load the translator, + * and then use the CodesetId (an unsigned long) to translate the + * character set code into the Service Object name. + * @par + * The default resource factory could parse command line options + * like: + * - -ORBcharcodeset 0x00010001=ISO8859 + * - -ORBcharcodeset 0x10020417=IBM1047 + * - -ORBwcharcodeset 0x00010106=ISOIEC10646 + * that would let the user experiment with different translators + * and plug them in on demand. + *@par + * + * We should also think about how translators will report conversion + * failures and how to simplify the implementation of char + * translators (it would seem like just a couple of arrays are + * needed, maybe the arrays should be dynamically loaded and the + * implementation would remain constant? Just a thought. + * + */ + //@{ + /// Convert from ISO8859 to the native character set + ACE_Char_Codeset_Translator *from_iso8859 (void) const; + + /// Convert from the native character set to ISO8859 + ACE_Char_Codeset_Translator *to_iso8859 (void) const; + + /// Convert from UNICODE to the native wide character set + ACE_WChar_Codeset_Translator *from_unicode (void) const; + + /// Convert from the native wide character set to UNICODE + ACE_WChar_Codeset_Translator *to_unicode (void) const; + //@} + + /// Set/get the collocation flags + //@{ + void optimize_collocation_objects (CORBA::Boolean opt); + CORBA::Boolean optimize_collocation_objects (void) const; + + void use_global_collocation (CORBA::Boolean opt); + CORBA::Boolean use_global_collocation (void) const; + + CORBA::ULong get_collocation_strategy (void) const; + //@} + + /// Get the adapter named "RootPOA" and cache the result, this is an + /// optimization for the POA. + TAO_Adapter *poa_adapter (void); + + /// A spawned thread needs to inherit some properties/objects from + /// the spawning thread in order to serve requests. Return 0 if + /// it successfully inherits from the parent, -1 otherwise. + int inherit_from_parent_thread (TAO_ORB_Core_TSS_Resources *tss_resources); + + /** + * @name Access to Factories + * + * These factories are not thread-specific, and are presented here + * in order to have one place to get useful information. Often, the + * instances to which the return pointers are stored in the Service + * Repository. + */ + //@{ + /// Returns pointer to the resource factory. + TAO_Resource_Factory *resource_factory (void); + + /// Returns pointer to the client factory. + TAO_Client_Strategy_Factory *client_factory (void); + + /// Returns pointer to the server factory. + TAO_Server_Strategy_Factory *server_factory (void); + + /// Returns pointer to the Protocol_Hooks. + TAO_Protocols_Hooks *protocols_hooks (void); + + /// Returns a pointer to the Stub factory. + TAO_Stub_Factory *stub_factory (void); + + /// Returns a pointer to the endpoint selector factory. + TAO_Endpoint_Selector_Factory *endpoint_selector_factory (void); + //@} + + /// Sets the value of TAO_ORB_Core::stub_factory_name_ + static void set_stub_factory (const char *stub_factory_name); + + /// Sets the value of TAO_ORB_Core::resource_factory_ + static void set_resource_factory (const char *resource_factory_name); + + /// Sets the value of TAO_ORB_Core::protocols_hooks_ + static void set_protocols_hooks (const char *protocols_hooks_name); + + /// Sets the value of TAO_ORB_Core::endpoint_selector_factory_ + static void set_endpoint_selector_factory ( + const char *endpoint_selector_factory_name); + + /// Sets the name of the POA factory and the dynamic service + /// configurator directive to load it if needed. + static void set_poa_factory ( + const char *poa_factory_name, + const char *poa_factory_directive); + + /// Gets the value of TAO_ORB_Core::protocols_hooks__ + TAO_Protocols_Hooks * get_protocols_hooks (CORBA::Environment &ACE_TRY_ENV); + + /// Sets the value of TAO_ORB_Core::dynamic_adapter_name_. + static void dynamic_adapter_name (const char *name); + + /// Gets the value of TAO_ORB_Core::dynamic_adapter_name_. + static const char *dynamic_adapter_name (void); + + /// Sets the value of TAO_ORB_Core::ifr_client_adapter_name_. + static void ifr_client_adapter_name (const char *name); + + /// Gets the value of TAO_ORB_Core::ifr_client_adapter_name_. + static const char *ifr_client_adapter_name (void); + + /// Sets the value of TAO_ORB_Core::typecodefactory_adapter_name_. + static void typecodefactory_adapter_name (const char *name); + + /// Gets the value of TAO_ORB_Core::typecodefactory_adapter_name_. + static const char *typecodefactory_adapter_name (void); + + /// See if we have a collocated address, if yes, return the POA + /// associated with the address. + int is_collocated (const TAO_MProfile& mprofile); + + /// This allocator is always TSS and has no locks. It is intended + /// for allocating the ACE_Data_Blocks used in *outgoing* CDR + /// streams. + ACE_Allocator *output_cdr_dblock_allocator (void); + + /// This allocator is always TSS and has no locks. It is intended + /// for allocating the buffers used in *outgoing* CDR streams. + ACE_Allocator *output_cdr_buffer_allocator (void); + + /// This allocator is always TSS and has no locks. It is intended + /// for allocating the ACE_Data_Blocks used in *outgoing* CDR + /// streams. + ACE_Allocator *output_cdr_msgblock_allocator (void); + + /// This allocator maybe TSS or global, may or may not have + /// locks. It is intended for allocating the ACE_Data_Blocks used in + /// *outgoing* / CDR streams. + ACE_Allocator *input_cdr_dblock_allocator (void); + + /// This allocator is always TSS and has no locks. It is intended + /// for allocating the buffers used in *outgoing* CDR streams. + ACE_Allocator *input_cdr_buffer_allocator (void); + + /// This allocator is always TSS and has no locks. It is intended + /// for allocating the buffers used in *outgoing* CDR streams. + ACE_Allocator *input_cdr_msgblock_allocator (void); + + /// This allocator is global, may or may not have locks. It is + /// intended for ACE_Data_Blocks used in message blocks or CDR + /// streams that have no relation with the life of threads, + /// something like used in a class on a per connection basis + ACE_Allocator *message_block_dblock_allocator (void); + + /// This allocator is global, may or may not have locks. It is + /// intended for ACE_Data_Blocks used in message blocks or CDR + /// streams that have no relation with the life of threads, + /// something like used in a class on a per connection basis + ACE_Allocator *message_block_buffer_allocator (void); + + /// This allocator is global, may or may not have locks. It is + /// intended for ACE_Data_Blocks used in message blocks or CDR + /// streams that have no relation with the life of threads, + /// something like used in a class on a per connection basis + ACE_Allocator *message_block_msgblock_allocator (void); + + /// The Message Blocks used for input CDRs must have appropiate + /// locking strategies. + ACE_Data_Block *create_input_cdr_data_block (size_t size); + + + /// Return the locking strategy used for the data blocks. + ACE_Lock *locking_strategy (void); + + /// The data blocks returned have memeory from the global pool. Will + /// not get anything from the TSS even if it is available. + ACE_Data_Block *data_block_for_message_block (size_t size); + + +#if (TAO_HAS_CORBA_MESSAGING == 1) + + /// Accessor method for the default_policies_ + TAO_Policy_Set *get_default_policies (void); + + /// Get a cached policy. First, check the ORB-level Policy + /// Manager, and then check the ORB defaults. + CORBA::Policy *get_cached_policy (TAO_Cached_Policy_Type type); + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + + /** + * The thread has a default environment to simplify porting between + * platforms that support native C++ exceptions and those that + * don't. This is a TSS resource (always), but with a twist: if the + * user creates a new environment the old one is "pushed" (actually + * the new one remembers it), eventually the new environment + * destructor pops itself from the stack and we recover the old + * environment. + * @par + * This means that if the user create a new environment and somebody + * calls a function using the default one the exception will still + * be received in the environment created by the user. + * The only drawback is that environments life time must nest + * properly, this shouldn't be a problem because environments are + * usually created on the stack, but, the spec allows their creation + * on the heap and/or as class members; we need to investigate the + * tradeoffs and take a decision. + */ + //@{ + CORBA_Environment *default_environment (void) const; + void default_environment (CORBA_Environment*); + //@} + +#if (TAO_HAS_CORBA_MESSAGING == 1) + + /// Return the Policy_Manager for this ORB. + TAO_Policy_Manager *policy_manager (void); + + /// Accesors to the policy current, this object should be kept in + /// TSS storage. The POA has to reset the policy current object on + /// every upcall. + TAO_Policy_Current &policy_current (void); + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + + /// Invoke the timeout hook if present. + /** + * The timeout hook is used to determine if the timeout policy is + * set and with what value. If the ORB is compiled without support + * for Messaging this feature does not take effect + * \param has_timeout returns 0 if there is no timeout policy set. + * \param time_value returns the timeout value in effect for the object, + * thread and current ORB. + */ + void call_timeout_hook (TAO_Stub *stub, + int &has_timeout, + ACE_Time_Value &time_value); + + /// Define the Timeout_Hook signature + typedef void (*Timeout_Hook) (TAO_ORB_Core *, + TAO_Stub *, + int&, + ACE_Time_Value&); + + static void set_timeout_hook (Timeout_Hook hook); + + /// Access to the RoundtripTimeoutPolicy policy set on the thread or + /// on the ORB. In this method, we do not consider the stub since + /// we do not have access to it. + CORBA::Policy *stubless_relative_roundtrip_timeout (void); + + void call_sync_scope_hook (TAO_Stub *stub, + int &has_synchronization, + int &scope); + TAO_Sync_Strategy &get_sync_strategy (TAO_Stub *stub, + int &scope); + typedef void (*Sync_Scope_Hook) (TAO_ORB_Core *, TAO_Stub *, int&, int&); + static void set_sync_scope_hook (Sync_Scope_Hook hook); + + void stubless_sync_scope (CORBA::Policy *&result); + + static Sync_Scope_Hook sync_scope_hook_; + // The hook to be set for the SyncScopePolicy + +#if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) + + CORBA::Policy *default_buffering_constraint (void) const; + + /// This strategy will buffer messages. + //@{ + TAO_Eager_Buffering_Sync_Strategy &eager_buffering_sync_strategy (void); + TAO_Delayed_Buffering_Sync_Strategy &delayed_buffering_sync_strategy (void); + //@} + +#endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ + + /// This strategy will sync with the transport. + TAO_Transport_Sync_Strategy &transport_sync_strategy (void); + + /// Pointer to chain of POA extension initializers. + TAO_POA_Extension_Initializer *poa_extension_initializer_; + + /// Handle to the factory for protocols_hooks_.. + TAO_Protocols_Hooks *protocols_hooks_; + + // Name of the protocols_hooks that needs to be instantiated. + // The default value is "Protocols_Hooks". If RTCORBA option is + // set, its value will be set to + // be "RT_Protocols_Hooks". + static const char *protocols_hooks_name_; + + /// Obtain the TSS resources of this orb. + TAO_ORB_Core_TSS_Resources* get_tss_resources (void); + + /// Obtain the TSS resource in the given slot. + void* get_tss_resource (size_t slot_id); + + /// Set the TSS resource at the given slot. + /// Returns 0 on success, and -1 on failure. + int set_tss_resource (size_t slot_id, void *); + + /// Register a TSS cleanup function. The slot ID for the + /// corresponding ORB core TSS resource is returned by the reference + /// argument. This method return 0 on success, and -1 on failure. + int add_tss_cleanup_func (ACE_CLEANUP_FUNC cleanup, + size_t &slot_id); + + /// Return the underlying TSS cleanup function registry. + TAO_Cleanup_Func_Registry *tss_cleanup_funcs (void); + + /// Get access to the leader_follower class. + TAO_Leader_Follower &leader_follower (void); + + /// Get access to the leader follower strategy. + TAO_LF_Strategy &lf_strategy (void); + + /// Run the event loop. + int run (ACE_Time_Value *tv, + int perform_work, + CORBA::Environment &ACE_TRY_ENV); + + /// End the event loop + void shutdown (CORBA::Boolean wait_for_completion, + CORBA::Environment &ACE_TRY_ENV); + + /// Get the shutdown flag value + int has_shutdown (void); + + /// Shutdown the ORB and free resources + void destroy (CORBA::Environment &ACE_TRY_ENV); + + /// Check if ORB has shutdown. If it has, throw an exception. + void check_shutdown (CORBA::Environment &ACE_TRY_ENV); + + /// Returns the value used by the server threads to poll + /// the shutdown flag. If the return value is zero then the server + /// threads block forever. + int thread_per_connection_timeout (ACE_Time_Value &timeout) const; + + /// Condition variable used in the Leader Follower Wait Strategy, on + /// which the follower thread blocks. + TAO_SYNCH_CONDITION* leader_follower_condition_variable (void); + + /// Makes sure that the ORB is open and then creates a TAO_Stub + /// based on the endpoint. + TAO_Stub *create_stub_object (const TAO_ObjectKey &key, + const char *type_id, + CORBA::PolicyList *policy_list, + TAO_Acceptor_Filter *filter, + CORBA::Environment &ACE_TRY_ENV); + + /// Factory method that create the "right" Stub depending on + /// wheather RTCORBA is loaded or not. The factory used to create + /// the stub, is loaded at ORB initialization, and its type depends + /// on the fact that RTCORBA is being used or not. + TAO_Stub *create_stub (const char *repository_id, + const TAO_MProfile &profiles, + TAO_ORB_Core *orb_core, + CORBA::Environment &ACE_TRY_ENV); + + + /// Give each registered IOR interceptor the opportunity to add + /// tagged components to profiles of each created servant. + void establish_components (TAO_MProfile &mp, + CORBA::PolicyList *policy_list, + CORBA::Environment &ACE_TRY_ENV); + + /// Create a new object, use the adapter registry to create a + /// collocated object, if not possible then create a regular + /// object. + CORBA::Object_ptr create_object (TAO_Stub *the_stub); + + /// Return ORBid string. + const char *orbid (void) const; + + /// Set/Get the IOR of the Implementation Repository service. + //@{ + CORBA::Object_ptr implrepo_service (void); + void implrepo_service (const CORBA::Object_ptr ir); + //@} + + /// Resolve the TypeCodeFactory DLL. + CORBA::Object_ptr resolve_typecodefactory (CORBA::Environment &ACE_TRY_ENV); + + /// Resolve the Dynamic Any Factory + CORBA::Object_ptr resolve_dynanyfactory (CORBA::Environment &ACE_TRY_ENV); + + /// Resolve the IOR Manipulation reference for this ORB. + CORBA::Object_ptr resolve_ior_manipulation (CORBA::Environment&); + + /// Resolve the IOR Table reference for this ORB. + CORBA::Object_ptr resolve_ior_table (CORBA::Environment&); + + /// Resolve an initial reference via the -ORBInitRef and + // -ORBDefaultInitRef options. + CORBA::Object_ptr resolve_rir (const char *name, + CORBA::Environment &); + + /// Resolve the RT ORB reference for this ORB. + CORBA::Object_ptr resolve_rt_orb (CORBA::Environment &ACE_TRY_ENV); + + /// Resolve the RT Current flyweight for this ORB. + CORBA::Object_ptr resolve_rt_current (CORBA::Environment &ACE_TRY_ENV); + + /// List all the service known by the ORB + CORBA_ORB_ObjectIdList_ptr list_initial_references (CORBA::Environment &); + + /// Reference counting... + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + + /// Register the handle of an open connection with the ORB Core + /// handle set. This handle set will be used to explicitly remove + /// corresponding event handlers from the reactor. + int register_handle (ACE_HANDLE handle); + + /// Remove from the ORB Core's handle set so that it + /// isn't included in the set that is passed to the reactor upon ORB + /// destruction. + int remove_handle (ACE_HANDLE handle); + + + /** + * @name ORB Core Service Hooks + * + * These methods would represent the hooks in the ORB Core. These + * hooks would be used to call back on the services or other + * features that are dynamically loaded. + */ + //@{ + /** + * The loaded service in the ORB_Core would determine if the profile + * selection is going to be made by the services or not. If the + * services do make the selection they would return the selected + * profile through . + */ + CORBA::Boolean service_profile_selection (TAO_MProfile &mprofile, + TAO_Profile *&profile); + + /** + * The loaded service in the ORB_Core would determine if the profile + * reselection is going to be made by the services or not. If the + * services do make the reselection they would return the selected + * profile through . The reselction is for the + * multi-profile IORS. + */ + CORBA::Boolean service_profile_reselection (TAO_Stub *stub, + TAO_Profile *&profile); + + /// Reset the flags in the loaded services. + void reset_service_profile_flags (void); + + /** + * The loaded service would determineif the CORBA::Object_ptr is + * actually nill or not. This would be useful to accomodate new + * enhanced definitions as defined by the service specification. + */ + CORBA::Boolean object_is_nil (CORBA::Object_ptr object); + + /// Call the service layers with the Service Context to check + /// whether they would like to add something to the list. + void service_context_list (TAO_Stub *stub, + TAO_Service_Context &service_context, + CORBA::Boolean retstart, + CORBA::Environment &ACE_TRY_ENV); + + /// Return a reference to the Fault Tolerant service object. + TAO_Fault_Tolerance_Service &fault_tolerance_service (void); + + /// Raise a comm failure exception if a service is not loaded, else + /// delegate to the service to see what the service has to do for + /// this case. + int service_raise_comm_failure (TAO_GIOP_Invocation *invoke, + TAO_Profile *profile, + CORBA::Environment &ACE_TRY_ENV); + + /// Raise a transient failure exception if a service is not loaded, + /// else delegate to the service to see what the service has to do + /// for this case. + int service_raise_transient_failure (TAO_GIOP_Invocation *invoke, + TAO_Profile *profile, + CORBA::Environment &ACE_TRY_ENV); + + /// Hook for logging of messages by the Logging & Recovery service + /// of an FT service. + void services_log_msg_rcv (TAO_Message_State_Factory &state); + + /// Hook for logging of messages by the Logging & Recovery service + /// of an FT service. + void services_log_msg_pre_upcall (TAO_ServerRequest &req); + + /// Hook for logging of messages by the Logging & Recovery service + /// of an FT service. + void services_log_msg_post_upcall (TAO_ServerRequest &req); + //@} + + + /** + * @name Portable Interceptor Related Methods + * + * These are support methods for interceptor registration and + * interceptor set (an array) access. + */ + //@{ +#if TAO_HAS_INTERCEPTORS == 1 + + /// Register a client request interceptor. + void add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + CORBA_Environment &ACE_TRY_ENV); + + /// Register a server request interceptor. + void add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + CORBA_Environment &ACE_TRY_ENV); + + /// Return the array of client-side interceptors specific to this + /// ORB. + TAO_ClientRequestInterceptor_List::TYPE & + client_request_interceptors (void); + + /// Return the array of server-side interceptors specific to this + /// ORB. + TAO_ServerRequestInterceptor_List::TYPE & + server_request_interceptors (void); + +#endif /* TAO_HAS_INTERCEPTORS */ + + /// Register an IOR interceptor. + void add_interceptor ( + PortableInterceptor::IORInterceptor_ptr interceptor, + CORBA_Environment &ACE_TRY_ENV); + + /// Return the array of IOR interceptors specific to this ORB. + TAO_IORInterceptor_List::TYPE & ior_interceptors (void); + //@} + + /// Set up the ORB Core's acceptor to listen on the + /// previously-specified port for requests. Returns -1 on failure, + /// otherwise 0. + int open (CORBA::Environment &ACE_TRY_ENV); + + /// Return the underlying transport cache + TAO_Transport_Cache_Manager *transport_cache (void); + + /// Call the bidir_giop library to parse the policy. + int parse_bidir_policy (CORBA::Policy_ptr policy, + CORBA::Environment &ACE_TRY_ENV); + + /// Set and Get methods to indicate whether a BiDir IIOP policy has + /// been set in the POA. + /// @note At present, the value will be true even if one of the POA's + /// is set with the Bi Dir GIOP policy. + CORBA::Boolean bidir_giop_policy (void); + void bidir_giop_policy (CORBA::Boolean); + + /// Return the table that maps object key/name to de-stringified + /// object reference. It is needed for supporting local objects in + /// the resolve_initial_references() mechanism. + TAO_Object_Ref_Table &object_ref_table (void); + + /// Return the flushing strategy + /** + * The flushing strategy is created by the resource factory, and it + * is used by the ORB to control the mechanism used to flush the + * outgoing data queues. + * The flushing strategies are stateless, therefore, there is only + * one per ORB. + */ + TAO_Flushing_Strategy *flushing_strategy (void); + +protected: + + /// Destructor is protected since the ORB Core is a reference + /// counted object. + ~TAO_ORB_Core (void); + + /// Initialize the guts of the ORB Core. It is intended that this be + /// called by . + int init (int &argc, char **argv, CORBA::Environment &ACE_TRY_ENV); + + /// Final termination hook, typically called by CORBA::ORB's + /// destructor. + int fini (void); + + /// Implement the input_cdr_*_allocator() routines using pre-fetched + /// TSS resources. This minimizes the number of calls to them. + //@{ + ACE_Allocator *input_cdr_dblock_allocator_i (TAO_ORB_Core_TSS_Resources *); + ACE_Allocator *input_cdr_buffer_allocator_i (TAO_ORB_Core_TSS_Resources *); + ACE_Allocator *input_cdr_msgblock_allocator_i (TAO_ORB_Core_TSS_Resources *); + //@} + + /// Routine that creates a ACE_Data_Block given the lock and allocators. + ACE_Data_Block *create_data_block_i (size_t size, + ACE_Allocator *buffer_allocator, + ACE_Allocator *dblock_allocator, + ACE_Lock *lock); + /// Obtain and cache the RT_ORB object reference + void resolve_rt_orb_i (CORBA::Environment &ACE_TRY_ENV); + + /// Obtain and cache the RT_Current flyweight reference + void resolve_rt_current_i (CORBA::Environment &ACE_TRY_ENV); + + /// Obtain and cache the dynamic any factory object reference. + void resolve_typecodefactory_i (CORBA::Environment &ACE_TRY_ENV); + + /// Obtain and cache the dynamic any factory object reference. + void resolve_dynanyfactory_i (CORBA::Environment &ACE_TRY_ENV); + + /// Obtain and cache the IORManipulation factory object reference. + void resolve_iormanipulation_i (CORBA::Environment &ACE_TRY_ENV); + + /// Search the Dynamic service list for BiDirectional options that + /// can be dynamically loaded. + int bidirectional_giop_init (CORBA::Environment &ACE_TRY_ENV); + + /// Search the Dynamic service list for well known services that has + /// callbacks which can be dynamically loaded. + void services_callbacks_init (void); + + /// Helper method that invokes Interceptor::destroy() on all + /// registered interceptors when ORB::destroy() is called. + void destroy_interceptors (CORBA::Environment &ACE_TRY_ENV); + +private: + + /// The ORB Core should not be copied. + //@{ + ACE_UNIMPLEMENTED_FUNC (TAO_ORB_Core(const TAO_ORB_Core&)) + ACE_UNIMPLEMENTED_FUNC (void operator=(const TAO_ORB_Core&)) + //@} + + /// Obtain and cache the dynamic any factory object reference. + void resolve_ior_table_i (CORBA::Environment &ACE_TRY_ENV); + + /// Try to create a new collocated object, using as the + /// target ORB. If not possible return 0. + CORBA::Object_ptr create_collocated_object (TAO_Stub *the_stub, + TAO_ORB_Core *other_orb, + const TAO_MProfile &mprofile); + + /// The hook to be set for the RelativeRoundtripTimeoutPolicy. + static Timeout_Hook timeout_hook_; + +protected: + + /// Synchronize internal state... + TAO_SYNCH_MUTEX lock_; + + /// The connector registry which all active connectors must register + /// themselves with. + TAO_Connector_Registry *connector_registry_; + + /// The registry which maintains a list of acceptor factories for + /// each loaded protocol. + TAO_Acceptor_Registry *acceptor_registry_; + + TAO_Stub_Factory *stub_factory_; + + /// Pointer to the list of protocol loaded into this ORB instance. + TAO_ProtocolFactorySet *protocol_factories_; + + /// The cached IOR for the Implementation Repository. + // @@ If this is a _var, where should it get deleted? (brunsch) + CORBA::Object_ptr implrepo_service_; + + /// Flag for whether the implrepo support is enabled or not. + int use_implrepo_; + + /// The cached IOR for the TypeCodeFactory DLL. + CORBA::Object_ptr typecode_factory_; + + /// The cached object reference for the DynAnyFactory. + CORBA::Object_ptr dynany_factory_; + + /// The cached object reference for the IORManipulataion. + CORBA::Object_ptr ior_manip_factory_; + + /// The cached object reference for the IORTable. + CORBA::Object_ptr ior_table_; + + /// The cached object reference for the RTCORBA::RTORB. + CORBA::Object_ptr rt_orb_; + + /// The cached object reference for the RTCORBA::RTCurrent interface. + CORBA::Object_ptr rt_current_; + + /// The cached object reference for the priority mapping manager. + CORBA::Object_ptr rt_priority_mapping_manager_; + + /** + * @note + * Should we keep a single ORB pointer? This is good because + * multiple calls to ORB_init() with the same ORBid can use the same + * object, but maybe don't want so much coupling. + * + * Pointer to the ORB. + */ + CORBA::ORB_var orb_; + + /// Object reference to the root POA. It will eventually be the + /// object reference returned by calls to + /// CORBA::ORB::resolve_initial_references ("RootPOA"). + CORBA::Object_var root_poa_; + + /// Parameters used by the ORB. + TAO_ORB_Parameters orb_params_; + + typedef ACE_Hash_Map_Manager InitRefMap; + InitRefMap init_ref_map_; + + /// Table that maps object key/name to (de-stringified) object + /// reference. It is needed for supporting local objects in the + /// resolve_initial_references() mechanism. + TAO_Object_Ref_Table object_ref_table_; + + /// The ORBid for this ORB. + char *orbid_; + + /// Handle to the factory for resource information.. + TAO_Resource_Factory *resource_factory_; + + /// The allocators for the message blocks + //@{ + ACE_Allocator *message_block_dblock_allocator_; + ACE_Allocator *message_block_buffer_allocator_; + ACE_Allocator *message_block_msgblock_allocator_; + //@} + + // Name of the endpoint selector factory that needs to be instantiated. + // The default value is "Default_Endpoint_Selector_Factory". If + // TAO_RTCORBA is linked, the set_endpoint_selector_factory will be + // called to set the value to be "RT_Endpoint_Selector_Factory". + static const char *endpoint_selector_factory_name_; + + // Name of the stub factory that needs to be instantiated. + // The default value is "Default_Stub_Factory". If TAO_RTCORBA is + // linked, the set_stub_factory will be called to set the value + // to be "RT_Stub_Factory". + static const char *stub_factory_name_; + + // Name of the resource factory that needs to be instantiated. + // The default value is "Resource_Factory". If TAO_Strategies is + // linked, the set_resource_factory will be called to set the value + // to be "Advanced_Resource_Factory". + static const char *resource_factory_name_; + + // Name of the service object for DII request creation that needs + // to be instantiated. The default value is "Dynamic_Adaper". If + // TAO_DynamicInterface is linked, dynamic_adapter_name() will be + // called to set the value to "Concrete_Dynamic_Adapter". + static const char *dynamic_adapter_name_; + + // Name of the service object for functions that make calls on + // the Interface Repository. The default value is "IFR_Client_Adaper". + // If TAO_IFR_CLient is linked, ifr_client_adapter_name() will be + // called to set the value to "Concrete_IFR_Client_Adapter". + static const char *ifr_client_adapter_name_; + + // Name of the service object used by the ORB create_*_tc functions. + // The default value is "TypeCodeFactory_Adapter". If the + // TypeCodeFactory library is linked, the corresponding accessor + // function typecodefactory_adapter_name() will be called to set + // the value to "Concrete_TypeCodeFactory_Adapter". + static const char *typecodefactory_adapter_name_; + + // Name of the service object used to create the RootPOA. The + // default value is "TAO_POA". If TAO_RTCORBA is loaded, this + // will be changed to TAO_RT_POA so that a POA equipped with + // realtime extensions will be returned. + static const char *poa_factory_name_; + + // The service configurator directive used to load + // poa_factory_name_ dynamically. + static const char *poa_factory_directive_; + + // @@ This is not needed since the default resource factory + // is staticaly added to the service configurator. + /// TRUE if was obtained from the Service + /// Configurator. + CORBA::Boolean resource_factory_from_service_config_; + + /// Handle to the factory for Client-side strategies. + TAO_Client_Strategy_Factory *client_factory_; + + // @@ This is not needed since the client facotry factory + // is staticaly added to the service configurator. + /// TRUE if was obtained from the Service + /// Configurator. + CORBA::Boolean client_factory_from_service_config_; + + /// Handle to the factory for Server-side strategies. + TAO_Server_Strategy_Factory *server_factory_; + + // @@ This is not needed since the server factory factory + // is staticaly added to the service configurator. + /// TRUE if was obtained from the Service + /// Configurator. + CORBA::Boolean server_factory_from_service_config_; + + /** + * @name Service Level Hooks + */ + //@{ + + /// Fault Tolerant service hook. + TAO_Fault_Tolerance_Service ft_service_; + + //@} + + /// TRUE if we want to take advantage of collocation optimization in + /// this ORB. + CORBA::Boolean opt_for_collocation_; + + /// TRUE if we want to consider all ORBs in this address space + /// collocated. + CORBA::Boolean use_global_collocation_; + + /// Default collocation policy. This should never be ORB_CONTROL. + CORBA::ULong collocation_strategy_; + + +#if (TAO_HAS_CORBA_MESSAGING == 1) + + /// The Policy_Manager for this ORB. + TAO_Policy_Manager *policy_manager_; + + /// The default policies. + TAO_Policy_Set *default_policies_; + + /// Policy current. + TAO_Policy_Current *policy_current_; + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + + /** + * POA current. + * + * @note + * This is a pointer in order to reduce the include file + * dependencies. + */ + CORBA::Object_var poa_current_; + + /// The list of Adapters used in this ORB. + TAO_Adapter_Registry adapter_registry_; + + /// An optimization for the POA. + TAO_Adapter *poa_adapter_; + + /// The Thread Manager + ACE_Thread_Manager tm_; + + /// The data block reference counts are locked using this mutex + ACE_Lock_Adapter data_block_lock_; + + + /// Codeset translators for simple implementations. + //@{ + ACE_Char_Codeset_Translator *from_iso8859_; + ACE_Char_Codeset_Translator *to_iso8859_; + ACE_WChar_Codeset_Translator *from_unicode_; + ACE_WChar_Codeset_Translator *to_unicode_; + //@} + + /// TSS Object cleanup functions. These correspond to the TSS + /// objects stored in TAO's TSS resources. + TAO_Cleanup_Func_Registry tss_cleanup_funcs_; + + /// If 1 then this ORB uses thread-specific resources + int use_tss_resources_; + + /// This is where the tss resources for this ORB are stored. + ACE_TSS_TYPE (TAO_ORB_Core_TSS_Resources) tss_resources_; + + /// If the resources are per-ORB (as opposed to per-ORB-per-thread) + /// then they are stored here... + TAO_ORB_Core_TSS_Resources orb_resources_; + + /// The server concurrency strategy. + TAO_Reactor_Registry *reactor_registry_; + + /// The reactor used for pure-clients, otherwise it comes from the + /// reactor_registry. + ACE_Reactor *reactor_; + + /// Flag which denotes that the ORB has been shutdown. + int has_shutdown_; + + /// The value of the timeout if the flag above is not zero. + //@{ + int thread_per_connection_use_timeout_; + ACE_Time_Value thread_per_connection_timeout_; + //@} + + + /// Mutual exclusion for calling open. + TAO_SYNCH_MUTEX open_lock_; + + /// Flag which denotes that the open method was called. + int open_called_; + + TAO_Endpoint_Selector_Factory *endpoint_selector_factory_; + +#if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) + + /// This strategy will buffer messages. + TAO_Eager_Buffering_Sync_Strategy *eager_buffering_sync_strategy_; + + /// This strategy will buffer messages. + TAO_Delayed_Buffering_Sync_Strategy *delayed_buffering_sync_strategy_; + +#endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ + + /// This strategy will sync with the transport. + TAO_Transport_Sync_Strategy *transport_sync_strategy_; + + /// Number of outstanding references to this object. + CORBA::ULong refcount_; + + /// Registry containing all registered policy factories. + TAO_PolicyFactory_Registry policy_factory_registry_; + +#if (TAO_HAS_INTERCEPTORS == 1) + /// Request interceptor registries. + TAO_ClientRequestInterceptor_List client_request_interceptors_; + TAO_ServerRequestInterceptor_List server_request_interceptors_; +#endif /* TAO_HAS_INTERCEPTORS */ + + /// IOR interceptor registry. + TAO_IORInterceptor_List ior_interceptors_; + + /// The IOR parser registry. + TAO_Parser_Registry parser_registry_; + + /// TAO's connection cache + TAO_Transport_Cache_Manager* transport_cache_; + + /// BiDirectional GIOP factory + TAO_BiDir_Adapter *bidir_adapter_; + + /// Bir Dir GIOP policy value + CORBA::Boolean bidir_giop_policy_; + + /// Hold the flushing strategy + TAO_Flushing_Strategy *flushing_strategy_; +}; + +// **************************************************************** + +/** + * @class TAO_ORB_Core_Auto_Ptr + * + * @brief Define a TAO_ORB_Core auto_ptr class. + * + * This class is used as an aid to make ORB initialization exception + * safe. It ensures that the ORB core is deallocated if an exception + * is thrown. + * + * @todo + * TAO_ORB_Core_Auto_Ptr should be renamed to TAO_ORB_Core_var + * since the ORB Core is reference counted. + */ +class TAO_Export TAO_ORB_Core_Auto_Ptr +{ +public: + + /// Initialization and termination methods + //@{ + /* explicit */ TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core *p = 0); + TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core_Auto_Ptr &ap); + TAO_ORB_Core_Auto_Ptr &operator= (TAO_ORB_Core_Auto_Ptr &rhs); + ~TAO_ORB_Core_Auto_Ptr (void); + //@} + + /// Accessor methods. + //@{ + TAO_ORB_Core &operator *() const; + TAO_ORB_Core *get (void) const; + TAO_ORB_Core *release (void); + void reset (TAO_ORB_Core *p = 0); + TAO_ORB_Core *operator-> () const; + //@} + +protected: + + TAO_ORB_Core *p_; + +}; + +// **************************************************************** +/** + * @class TAO_TSS_Resources + * + * @brief The TSS resoures shared by all the ORBs + * + * This class is used by TAO to store the resources that are + * thread-specific but are *not* ORB specific. The members are public + * because only the ORB Core is expected to access them. + */ +class TAO_Export TAO_TSS_Resources +{ +public: + + /// Constructor + TAO_TSS_Resources (void); + + /// Destructor + ~TAO_TSS_Resources (void); + +private: + + /// Do not copy TSS resources + //@{ + ACE_UNIMPLEMENTED_FUNC (TAO_TSS_Resources(const TAO_TSS_Resources&)) + ACE_UNIMPLEMENTED_FUNC (void operator=(const TAO_TSS_Resources&)) + //@} + +public: + + /** + * Points to structure containing state for the current upcall + * context in this thread. Note that it does not come from the + * resource factory because it must always be held in + * thread-specific storage. For now, since TAO_ORB_Core instances + * are TSS singletons, we simply ride along and don't allocate + * occupy another TSS slot since there are some platforms where + * those are precious commodities (e.g., NT). + */ + void *poa_current_impl_; + + /// The default environment for the thread. + CORBA_Environment* default_environment_; + + /// If the user (or library) provides no environment the ORB_Core + /// still holds one. + CORBA_Environment tss_environment_; + +#if (TAO_HAS_CORBA_MESSAGING == 1) + + /// The initial PolicyCurrent for this thread. Should be a TSS + /// resource. + TAO_Policy_Current_Impl initial_policy_current_; + + /// This pointer is reset by the POA on each upcall. + TAO_Policy_Current_Impl *policy_current_; + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + +}; + +/** + * @todo TAO_TSS_RESOURCES singleton typedef should go away. + */ +typedef TAO_TSS_Singleton + TAO_TSS_RESOURCES; + +// **************************************************************** + +/// Obtain an instance of the first ORB core registered in the ORB +/// table. +TAO_Export TAO_ORB_Core *TAO_ORB_Core_instance (void); + +#if defined (__ACE_INLINE__) +# include "ORB_Core.i" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_ORB_CORE_H */ diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i new file mode 100644 index 00000000000..8fe1c4ad291 --- /dev/null +++ b/TAO/tao/ORB_Core.i @@ -0,0 +1,701 @@ +// -*- C++ -*- +// $Id$ + +ACE_INLINE CORBA::ULong +TAO_ORB_Core::_incr_refcnt (void) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0); + return this->refcount_++; +} + +ACE_INLINE CORBA::ULong +TAO_ORB_Core::_decr_refcnt (void) +{ + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0); + this->refcount_--; + if (this->refcount_ != 0) + return this->refcount_; + } + + this->fini (); + return 0; +} + +ACE_INLINE ACE_Lock * +TAO_ORB_Core::locking_strategy (void) +{ + if (this->resource_factory ()->use_locked_data_blocks ()) + return &this->data_block_lock_; + + return 0; +} + +ACE_INLINE TAO_Transport_Cache_Manager * +TAO_ORB_Core::transport_cache (void) +{ + return this->transport_cache_; +} + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::bidir_giop_policy (void) +{ + return this->bidir_giop_policy_; +} + +ACE_INLINE void +TAO_ORB_Core::bidir_giop_policy (CORBA::Boolean val) +{ + this->bidir_giop_policy_ = val; +} + +ACE_INLINE TAO_Object_Ref_Table & +TAO_ORB_Core::object_ref_table (void) +{ + return this->object_ref_table_; +} + +ACE_INLINE TAO_Flushing_Strategy * +TAO_ORB_Core::flushing_strategy (void) +{ + return this->flushing_strategy_; +} + +ACE_INLINE TAO_POA_Extension_Initializer * +TAO_ORB_Core::poa_extension_initializer (void) +{ + return this->poa_extension_initializer_; +} + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::service_profile_selection (TAO_MProfile &mprofile, + TAO_Profile *&profile) +{ + CORBA::Boolean retval = 0; + // @@ If different services have the same feature we may want to + // prioritise them here. We need to decide here whose selection of + // profile is more important. + if (this->ft_service_.service_callback ()) + { + retval = + this->ft_service_.service_callback ()->select_profile (&mprofile, + profile); + } + return retval; +} + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::service_profile_reselection (TAO_Stub *stub, + TAO_Profile *&profile) +{ + CORBA::Boolean retval = 0; + // @@ If different services have the same feature we may want to + // prioritise them here. We need to decide here whose selection of + // profile is more important. + if (this->ft_service_.service_callback ()) + { + retval = + this->ft_service_.service_callback ()->reselect_profile (stub, + profile); + } + return retval; +} + +ACE_INLINE void +TAO_ORB_Core::reset_service_profile_flags (void) +{ + // @@ If different services have the same feature we may want to + // prioritise them here. We need to decide here whose selection of + // profile is more important. + + if (this->ft_service_.service_callback ()) + { + this->ft_service_.service_callback ()->reset_profile_flags (); + } + return; +} + + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::object_is_nil (CORBA::Object_ptr obj) +{ + CORBA::Boolean retval = 0; + if (this->ft_service_.service_callback ()) + { + retval = + this->ft_service_.service_callback ()->object_is_nil (obj); + } + return retval; +} + + + +ACE_INLINE void +TAO_ORB_Core:: services_log_msg_rcv (TAO_Message_State_Factory &state) +{ + if (this->ft_service_.service_callback ()) + { + this->ft_service_.service_callback ()->service_log_msg_rcv (state); + } +} + +ACE_INLINE void +TAO_ORB_Core:: services_log_msg_pre_upcall (TAO_ServerRequest &req) +{ + if (this->ft_service_.service_callback ()) + { + this->ft_service_.service_callback ()->service_log_msg_pre_upcall (req); + } +} + +ACE_INLINE void +TAO_ORB_Core:: services_log_msg_post_upcall (TAO_ServerRequest &req) +{ + if (this->ft_service_.service_callback ()) + { + this->ft_service_.service_callback ()->service_log_msg_post_upcall (req); + } +} + + +ACE_INLINE TAO_Fault_Tolerance_Service & +TAO_ORB_Core::fault_tolerance_service (void) +{ + return this->ft_service_; +} + + +ACE_INLINE ACE_Thread_Manager * +TAO_ORB_Core::thr_mgr (void) +{ + return &this->tm_; +} + +ACE_INLINE CORBA::ORB_ptr +TAO_ORB_Core::orb (void) +{ + return this->orb_.in (); +} + +ACE_INLINE TAO_Adapter_Registry * +TAO_ORB_Core::adapter_registry (void) +{ + return &this->adapter_registry_; +} + +ACE_INLINE void +TAO_ORB_Core::optimize_collocation_objects (CORBA::Boolean opt) +{ + this->opt_for_collocation_ = opt; +} + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::optimize_collocation_objects (void) const +{ + return this->opt_for_collocation_; +} + +ACE_INLINE void +TAO_ORB_Core::use_global_collocation (CORBA::Boolean opt) +{ + this->use_global_collocation_ = opt; +} + +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::use_global_collocation (void) const +{ + return this->use_global_collocation_; +} + +ACE_INLINE CORBA::ULong +TAO_ORB_Core::get_collocation_strategy (void) const +{ + return this->collocation_strategy_; +} + +ACE_INLINE TAO_ORB_Parameters * +TAO_ORB_Core::orb_params(void) +{ + return &(this->orb_params_); +} + +#define TAO_OC_RETRIEVE(member) \ + ((this->member##_ == 0) ? (this->member##_ = this->resource_factory ()->get_##member ()) : (this->member##_) ) + +ACE_INLINE TAO_ProtocolFactorySet * +TAO_ORB_Core::protocol_factories (void) +{ + return TAO_OC_RETRIEVE (protocol_factories); +} + +ACE_INLINE TAO_Connector_Registry * +TAO_ORB_Core::connector_registry (void) +{ + return TAO_OC_RETRIEVE (connector_registry); +} + +ACE_INLINE TAO_Acceptor_Registry * +TAO_ORB_Core::acceptor_registry (void) +{ + return TAO_OC_RETRIEVE (acceptor_registry); +} + +ACE_INLINE TAO_Parser_Registry * +TAO_ORB_Core::parser_registry (void) +{ + return &this->parser_registry_; +} + +ACE_INLINE TAO_PolicyFactory_Registry * +TAO_ORB_Core::policy_factory_registry (void) +{ + return &this->policy_factory_registry_; +} + + +#undef TAO_OC_RETRIEVE + +ACE_INLINE ACE_Char_Codeset_Translator * +TAO_ORB_Core::from_iso8859 (void) const +{ + return this->from_iso8859_; +} + +ACE_INLINE ACE_Char_Codeset_Translator * +TAO_ORB_Core::to_iso8859 (void) const +{ + return this->to_iso8859_; +} + +ACE_INLINE ACE_WChar_Codeset_Translator * +TAO_ORB_Core::from_unicode (void) const +{ + return this->from_unicode_; +} + +ACE_INLINE ACE_WChar_Codeset_Translator * +TAO_ORB_Core::to_unicode (void) const +{ + return this->to_unicode_; +} + +#if (TAO_HAS_CORBA_MESSAGING == 1) + +ACE_INLINE TAO_Policy_Manager * +TAO_ORB_Core::policy_manager (void) +{ + return this->policy_manager_; +} + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + +ACE_INLINE TAO_ORB_Core_TSS_Resources* +TAO_ORB_Core::get_tss_resources (void) +{ + return ACE_TSS_GET (&this->tss_resources_,TAO_ORB_Core_TSS_Resources); +} + +ACE_INLINE void * +TAO_ORB_Core::get_tss_resource (size_t slot_id) +{ + TAO_ORB_Core_TSS_Resources *tss_resources = + this->get_tss_resources (); + + if (slot_id >= tss_resources->ts_objects_.size ()) + return 0; + + return tss_resources->ts_objects_[slot_id]; +} + +ACE_INLINE int +TAO_ORB_Core::set_tss_resource (size_t slot_id, void *ts_object) +{ + TAO_ORB_Core_TSS_Resources *tss_resources = + this->get_tss_resources (); + + // The number of allocated slots is equal to the number of + // registered TSS cleanup functions, *not* the size of the array in + // the ORB core TSS resources. + if (slot_id >= this->tss_cleanup_funcs_.size ()) + { + errno = EINVAL; + return -1; + } + + // If the TSS array isn't large enough, then increase its size. + // We're guaranteed not to exceed the number of allocated slots by + // the above check. + size_t old_size = tss_resources->ts_objects_.size (); + size_t new_size = slot_id + 1; + if (slot_id >= old_size + && tss_resources->ts_objects_.size (new_size) != 0) + return -1; + + // Initialize intermediate array elements to zero, since they + // haven't been initialized yet. This ensures that garbage is not + // returned when accessing any of those elements at a later point in + // time. + for (size_t i = old_size; i < slot_id; ++i) + tss_resources->ts_objects_[i] = 0; + + tss_resources->ts_objects_[slot_id] = ts_object; + + // Make sure the ORB core pointer is set in the ORB core's TSS + // resources so that the TSS cleanup functions stored in the ORB + // core can be invoked. + tss_resources->orb_core_ = this; + + return 0; +} + +ACE_INLINE int +TAO_ORB_Core::add_tss_cleanup_func (ACE_CLEANUP_FUNC cleanup, + size_t &slot_id) +{ + return this->tss_cleanup_funcs_.register_cleanup_function (cleanup, + slot_id); +} + +ACE_INLINE TAO_Cleanup_Func_Registry * +TAO_ORB_Core::tss_cleanup_funcs (void) +{ + return &(this->tss_cleanup_funcs_); +} + +ACE_INLINE int +TAO_ORB_Core::has_shutdown (void) +{ + return this->has_shutdown_; +} + +ACE_INLINE void +TAO_ORB_Core::check_shutdown (CORBA_Environment &ACE_TRY_ENV) +{ + if (this->has_shutdown ()) + { + // As defined by the CORBA 2.3 specification, throw a + // CORBA::BAD_INV_ORDER exception with minor code 4 if the ORB + // has shutdown by the time an ORB function is called. + + ACE_THROW (CORBA::BAD_INV_ORDER (TAO_OMG_VMCID | 4, + CORBA::COMPLETED_NO)); + } +} + + +ACE_INLINE int +TAO_ORB_Core::thread_per_connection_timeout (ACE_Time_Value &timeout) const +{ + timeout = this->thread_per_connection_timeout_; + return this->thread_per_connection_use_timeout_; +} + +ACE_INLINE const char * +TAO_ORB_Core::orbid (void) const +{ + return this->orbid_; +} + +ACE_INLINE void +TAO_ORB_Core::implrepo_service (const CORBA::Object_ptr ir) +{ + this->implrepo_service_ = ir; +} + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::resolve_typecodefactory (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, + CORBA::Object::_nil ()); + if (CORBA::is_nil (this->typecode_factory_)) + { + this->resolve_typecodefactory_i (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } + return CORBA::Object::_duplicate (this->typecode_factory_); +} + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::resolve_dynanyfactory (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, + CORBA::Object::_nil ()); + if (CORBA::is_nil (this->dynany_factory_)) + { + this->resolve_dynanyfactory_i (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } + return CORBA::Object::_duplicate (this->dynany_factory_); +} + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::resolve_ior_manipulation (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, + CORBA::Object::_nil ()); + if (CORBA::is_nil (this->ior_manip_factory_)) + { + this->resolve_iormanipulation_i (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } + return CORBA::Object::_duplicate (this->ior_manip_factory_); +} + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::resolve_ior_table (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, + CORBA::Object::_nil ()); + if (CORBA::is_nil (this->ior_table_)) + { + this->resolve_ior_table_i (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } + return CORBA::Object::_duplicate (this->ior_table_); +} + +// **************************************************************** + +#if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) + +ACE_INLINE TAO_Eager_Buffering_Sync_Strategy & +TAO_ORB_Core::eager_buffering_sync_strategy (void) +{ + return *this->eager_buffering_sync_strategy_; +} + +ACE_INLINE TAO_Delayed_Buffering_Sync_Strategy & +TAO_ORB_Core::delayed_buffering_sync_strategy (void) +{ + return *this->delayed_buffering_sync_strategy_; +} + +#endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ + +ACE_INLINE TAO_Transport_Sync_Strategy & +TAO_ORB_Core::transport_sync_strategy (void) +{ + return *this->transport_sync_strategy_; +} + +#if (TAO_HAS_CORBA_MESSAGING == 1) + +ACE_INLINE TAO_Policy_Current & +TAO_ORB_Core::policy_current (void) +{ + return *this->policy_current_; +} + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::poa_current (void) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, 0); + + if (CORBA::is_nil (this->poa_current_.in ())) + { + ACE_TRY_NEW_ENV + { + // @@ This is a hack. FIXME! + // This forces the POACurrent to be initialized. + CORBA::Object_var root = this->root_poa (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return CORBA::Object::_nil (); + } + ACE_ENDTRY; + } + + return CORBA::Object::_duplicate (this->poa_current_.in ()); +} + +ACE_INLINE void +TAO_ORB_Core::poa_current (CORBA::Object_ptr current) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_); + this->poa_current_ = + CORBA::Object::_duplicate (current); +} + +#if (TAO_HAS_CORBA_MESSAGING == 1) + +ACE_INLINE TAO_Policy_Set * +TAO_ORB_Core::get_default_policies (void) +{ + return this->default_policies_; +} + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 */ + +ACE_INLINE CORBA_Environment * +TAO_ORB_Core::default_environment (void) const +{ + return TAO_TSS_RESOURCES::instance ()->default_environment_; +} + +ACE_INLINE void +TAO_ORB_Core::default_environment (CORBA_Environment *env) +{ + TAO_TSS_RESOURCES::instance ()->default_environment_ = env; +} + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::resolve_rt_orb (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, + CORBA::Object::_nil ()); + if (CORBA::is_nil (this->rt_orb_)) + { + this->resolve_rt_orb_i (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } + return CORBA::Object::_duplicate (this->rt_orb_); +} + +ACE_INLINE CORBA::Object_ptr +TAO_ORB_Core::resolve_rt_current (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, + CORBA::Object::_nil ()); + if (CORBA::is_nil (this->rt_current_)) + { + this->resolve_rt_current_i (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } + return CORBA::Object::_duplicate (this->rt_current_); +} + +#if (TAO_HAS_INTERCEPTORS == 1) +ACE_INLINE void +TAO_ORB_Core::add_interceptor ( + PortableInterceptor::ClientRequestInterceptor_ptr interceptor, + CORBA_Environment &ACE_TRY_ENV) +{ + this->client_request_interceptors_.add_interceptor (interceptor, + ACE_TRY_ENV); +} + +ACE_INLINE void +TAO_ORB_Core::add_interceptor ( + PortableInterceptor::ServerRequestInterceptor_ptr interceptor, + CORBA_Environment &ACE_TRY_ENV) +{ + this->server_request_interceptors_.add_interceptor (interceptor, + ACE_TRY_ENV); +} + +// ------ + +ACE_INLINE TAO_ClientRequestInterceptor_List::TYPE & +TAO_ORB_Core::client_request_interceptors (void) +{ + return this->client_request_interceptors_.interceptors (); +} + +// @@ It would be nice to move these to the PortableServer library, +// perhaps to the RootPOA. However, there is no "RootPOA" class so +// there doesn't appear to be a way that only the RootPOA +// implementation has these server-side interceptor methods and +// attributes. Leave them in the ORB Core for now. +ACE_INLINE TAO_ServerRequestInterceptor_List::TYPE & +TAO_ORB_Core::server_request_interceptors (void) +{ + return this->server_request_interceptors_.interceptors (); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +ACE_INLINE void +TAO_ORB_Core::add_interceptor ( + PortableInterceptor::IORInterceptor_ptr interceptor, + CORBA_Environment &ACE_TRY_ENV) +{ + this->ior_interceptors_.add_interceptor (interceptor, + ACE_TRY_ENV); +} + +ACE_INLINE TAO_IORInterceptor_List::TYPE & +TAO_ORB_Core::ior_interceptors (void) +{ + return this->ior_interceptors_.interceptors (); +} + +// **************************************************************** + +ACE_INLINE +TAO_ORB_Core_Auto_Ptr::TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core *p) + : p_ (p) +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::TAO_ORB_Core_Auto_Ptr"); +} + +ACE_INLINE TAO_ORB_Core * +TAO_ORB_Core_Auto_Ptr::get (void) const +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::get"); + return this->p_; +} + +ACE_INLINE TAO_ORB_Core * +TAO_ORB_Core_Auto_Ptr::release (void) +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::release"); + TAO_ORB_Core *old = this->p_; + this->p_ = 0; + return old; +} + +ACE_INLINE void +TAO_ORB_Core_Auto_Ptr::reset (TAO_ORB_Core *p) +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::reset"); + if (this->get () != p && this->get () != 0) + this->get ()->_decr_refcnt (); + this->p_ = p; +} + +ACE_INLINE TAO_ORB_Core * +TAO_ORB_Core_Auto_Ptr::operator-> () const +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::operator->"); + return this->get (); +} + +ACE_INLINE +TAO_ORB_Core_Auto_Ptr::TAO_ORB_Core_Auto_Ptr (TAO_ORB_Core_Auto_Ptr &rhs) + : p_ (rhs.release ()) +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::TAO_ORB_Core_Auto_Ptr"); +} + +ACE_INLINE TAO_ORB_Core_Auto_Ptr & +TAO_ORB_Core_Auto_Ptr::operator= (TAO_ORB_Core_Auto_Ptr &rhs) +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::operator="); + if (this != &rhs) + { + this->reset (rhs.release ()); + } + return *this; +} + +ACE_INLINE +TAO_ORB_Core_Auto_Ptr::~TAO_ORB_Core_Auto_Ptr (void) +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::~TAO_ORB_Core_Auto_Ptr"); + if (this->get() != 0) + this->get ()->_decr_refcnt (); +} + +// Accessor methods to the underlying ORB_Core Object + +ACE_INLINE TAO_ORB_Core & +TAO_ORB_Core_Auto_Ptr::operator *() const +{ + ACE_TRACE ("TAO_ORB_Core_Auto_Ptr::operator *()"); + // @@ Potential problem if this->p_ is zero! + return *this->get (); +} diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp new file mode 100644 index 00000000000..521e6fc8218 --- /dev/null +++ b/TAO/tao/default_resource.cpp @@ -0,0 +1,880 @@ +// $Id$ + +#include "tao/default_resource.h" + +#include "tao/ORB_Core.h" +#include "tao/debug.h" +#include "tao/IIOP_Factory.h" + +#include "tao/Acceptor_Registry.h" +#include "tao/Connector_Registry.h" +#include "tao/Single_Reactor.h" + +#include "tao/Reactive_Flushing_Strategy.h" +#include "tao/Block_Flushing_Strategy.h" +#include "tao/Leader_Follower.h" +#include "tao/LRU_Connection_Purging_Strategy.h" + +#include "ace/TP_Reactor.h" +#include "ace/Dynamic_Service.h" +#include "ace/Arg_Shifter.h" +#include "ace/Auto_Ptr.h" + +#if !defined (__ACE_INLINE__) +# include "tao/default_resource.i" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID(tao, default_resource, "$Id$") + + + +TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void) + : use_tss_resources_ (0), + use_locked_data_blocks_ (1), + parser_names_count_ (0), + parser_names_ (0), + protocol_factories_ (), + connection_caching_type_ (TAO_CONNECTION_CACHING_STRATEGY), + cache_maximum_ (TAO_CONNECTION_CACHE_MAXIMUM), + purge_percentage_ (TAO_PURGE_PERCENT), + reactor_mask_signals_ (1), + dynamically_allocated_reactor_ (0), + cached_connection_lock_type_ (TAO_THREAD_LOCK), + flushing_strategy_type_ (TAO_REACTIVE_FLUSHING) +{ +} + +TAO_Default_Resource_Factory::~TAO_Default_Resource_Factory (void) +{ + TAO_ProtocolFactorySetItor end = this->protocol_factories_.end (); + + for (TAO_ProtocolFactorySetItor iterator = + this->protocol_factories_.begin (); + iterator != end; + ++iterator) + delete *iterator; + + this->protocol_factories_.reset (); + + for (int i = 0; + i < this->parser_names_count_; + ++i) + CORBA::string_free (this->parser_names_[i]); + + delete []this->parser_names_; +} + +int +TAO_Default_Resource_Factory::init (int argc, char **argv) +{ + ACE_TRACE ("TAO_Default_Resource_Factory::init"); + + this->parser_names_count_ = 0; + + int curarg = 0; + + for (curarg = 0; curarg < argc; ++curarg) + { + // Parse thro' and find the number of Parsers to be loaded. + if (ACE_OS::strcasecmp (argv[curarg], + "-ORBIORParser") == 0) + ++this->parser_names_count_; + + ++curarg; + + if (curarg == (argc-1) && this->parser_names_count_ != 0) + { + // This is the last loop.. + this->parser_names_ = + new char *[this->parser_names_count_]; + + for (int i = 0; + i < this->parser_names_count_; + ++i) + this->parser_names_[i] = 0; + + this->index_ = 0; + } + } + + + for (curarg = 0; curarg < argc; curarg++) + if (ACE_OS::strcasecmp (argv[curarg], + "-ORBResources") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "global") == 0) + this->use_tss_resources_ = 0; + else if (ACE_OS::strcasecmp (name, + "tss") == 0) + this->use_tss_resources_ = 1; + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBReactorMaskSignals") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, "0") == 0) + this->reactor_mask_signals_ = 0; + else if (ACE_OS::strcasecmp (name, "1") == 0) + this->reactor_mask_signals_= 1; + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBProtocolFactory") == 0) + { + TAO_ProtocolFactorySet *pset = this->get_protocol_factories (); + curarg++; + if (curarg < argc) + { + TAO_Protocol_Item *item = 0; + ACE_NEW_RETURN (item, + TAO_Protocol_Item (argv[curarg]), + -1); + if (pset->insert (item) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) Unable to add protocol factories for %s: %p\n"), + argv[curarg])); + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBConnectionCachingStrategy") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "lru") == 0) + this->connection_caching_type_ = + TAO_Resource_Factory::LRU; + else if (ACE_OS::strcasecmp (name, + "lfu") == 0) + this->connection_caching_type_ = + TAO_Resource_Factory::LFU; + else if (ACE_OS::strcasecmp (name, + "fifo") == 0) + this->connection_caching_type_ = + TAO_Resource_Factory::FIFO; + else if (ACE_OS::strcasecmp (name, + "null") == 0) + this->connection_caching_type_ = + TAO_Resource_Factory::NOOP; + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Default_Factory - unknown argument") + ACE_TEXT (" <%s> for -ORBConnectionCachingStrategy\n"), name)); + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBConnectionCacheMax") == 0) + { + curarg++; + if (curarg < argc) + this->cache_maximum_ = ACE_OS::atoi (argv[curarg]); + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Default_Factory - unknown argument") + ACE_TEXT ("for -ORBConnectionCacheMax\n"))); + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBConnectionCachePurgePercentage") == 0) + { + curarg++; + if (curarg < argc) + this->purge_percentage_ = ACE_OS::atoi (argv[curarg]); + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Default_Factory - unknown argument") + ACE_TEXT ("for -ORBConnectionCachePurgePercentage\n"))); + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBPurgePercentage") == 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) This option has been ") + ACE_TEXT ("deprecated\n") + ACE_TEXT ("using -ORBConnectionCachePurgePercentage ") + ACE_TEXT ("instead "))); + curarg++; + if (curarg < argc) + this->purge_percentage_ = ACE_OS::atoi (argv[curarg]); + else + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO_Default_Factory - unknown argument") + ACE_TEXT ("for -ORBConnectionCachePurgePercentage\n"))); + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBIORParser") == 0) + { + curarg++; + + if (curarg < argc) + { + this->add_to_ior_parser_names (argv[curarg]); + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBConnectionCacheLock") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "thread") == 0) + this->cached_connection_lock_type_ = TAO_THREAD_LOCK; + else if (ACE_OS::strcasecmp (name, + "null") == 0) + { + // @@ Bug 940 :This is a sort of hack now. We need to put + // this in a common place once we get teh common + // switch that is documented in bug 940... + this->use_locked_data_blocks_ = 0; + this->cached_connection_lock_type_ = TAO_NULL_LOCK; + } + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBConnectionLock") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) This option has been deprecated \n") + ACE_TEXT ("using -ORBConnectionCacheLock instead "))); + + if (ACE_OS::strcasecmp (name, + "thread") == 0) + this->cached_connection_lock_type_ = TAO_THREAD_LOCK; + else if (ACE_OS::strcasecmp (name, + "null") == 0) + { + // @@ Bug 940 :This is a sort of hack now. We need to put + // this in a common place once we get teh common + // switch that is documented in bug 940... + this->use_locked_data_blocks_ = 0; + this->cached_connection_lock_type_ = TAO_NULL_LOCK; + } + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBConnectorLock") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) This option has been deprecated \n") + ACE_TEXT ("using -ORBConnectionCacheLock instead \n"))); + + if (ACE_OS::strcasecmp (name, + "thread") == 0) + this->cached_connection_lock_type_ = TAO_THREAD_LOCK; + else if (ACE_OS::strcasecmp (name, + "null") == 0) + { + // @@ Bug 940 :This is a sort of hack now. We need to put + // this in a common place once we get teh common + // switch that is documented in bug 940... + this->use_locked_data_blocks_ = 0; + this->cached_connection_lock_type_ = TAO_NULL_LOCK; + } + } + } + + else if (ACE_OS::strcasecmp (argv[curarg], + "-ORBFlushingStrategy") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, + "reactive") == 0) + this->flushing_strategy_type_ = TAO_REACTIVE_FLUSHING; + else if (ACE_OS::strcasecmp (name, + "blocking") == 0) + this->flushing_strategy_type_ = TAO_BLOCKING_FLUSHING; + } + } + + return 0; +} + +int +TAO_Default_Resource_Factory::get_parser_names (char **&names, + int &number_of_names) +{ + if (this->parser_names_count_ != 0) + { + // The user used some -ORBIORParser options, just return those. + names = this->parser_names_; + number_of_names = this->parser_names_count_; + + return 0; + } + + // OK fallback on the hardcoded ones.... + this->parser_names_count_ = 4; /*HOW MANY DO WE HAVE?*/ + + this->parser_names_ = new char *[this->parser_names_count_]; + + for (int i = 0; + i < this->parser_names_count_; + ++i) + this->parser_names_[i] = 0; + + // Ensure that there is enough space in the parser_names_ array */ + + // DLL_Parser + TAO_IOR_Parser *tmp = + ACE_Dynamic_Service::instance ("DLL_Parser"); + + if (tmp == 0) + { + int r = ACE_Service_Config::process_directive + ( + "dynamic DLL_Parser Service_Object * TAO:_make_TAO_DLL_Parser()" + ); + if (r != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Error configuring DLL parser\n"), -1); + } + } + + int index = 0; + if (tmp != 0) + { + this->parser_names_[index] = CORBA::string_dup ("DLL_Parser"); + index++; + } + + // FILE_Parser + tmp = + ACE_Dynamic_Service::instance ("FILE_Parser"); + + if (tmp == 0) + { + int r = ACE_Service_Config::process_directive + ( + "dynamic FILE_Parser Service_Object * TAO:_make_TAO_FILE_Parser()" + ); + + if (r != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Error Configuring FILE Parser\n"), -1); + } + } + if (tmp != 0) + { + this->parser_names_[index] = CORBA::string_dup ("FILE_Parser"); + index++; + } + + + // CORBALOC_Parser + tmp = + ACE_Dynamic_Service::instance ("CORBALOC_Parser"); + + if (tmp == 0) + { + int r = ACE_Service_Config::process_directive + ( + "dynamic CORBALOC_Parser Service_Object * TAO:_make_TAO_CORBALOC_Parser()" + ); + + if (r != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Error Configuring CORBALOC Parser\n"), -1); + } + } + + this->parser_names_[index] = CORBA::string_dup ("CORBALOC_Parser"); + index++; + + // CORBANAME_Parser + tmp = + ACE_Dynamic_Service::instance ("CORBANAME_Parser"); + + if (tmp == 0) + { + int r = ACE_Service_Config::process_directive + ( + "dynamic CORBANAME_Parser Service_Object * TAO :_make_TAO_CORBANAME_Parser()" + ); + + if (r != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Error Configuring CORBANAME Parser\n"), -1); + } + } + + this->parser_names_[index] = CORBA::string_dup ("CORBANAME_Parser"); + index++; + + names = this->parser_names_; + + // number_of_names = this->parser_names_count_; + number_of_names = index; + + return 0; +} + +int +TAO_Default_Resource_Factory::add_to_ior_parser_names (const char *curarg) +{ + this->parser_names_[this->index_] = CORBA::string_dup (curarg); + + ++this->index_; + + return 0; +} + +// This is virtual and protected... +int +TAO_Default_Resource_Factory::load_default_protocols (void) +{ + // If the user did not list any protocols in her svc.conf file + // then default to TAO's basic protocols. + // You do *NOT* need modify this code to add your own protocol, + // instead simply add the following to your svc.conf file: + // + // dynamic PP_Factory Service_Object * LIB:_make_PP_Protocol_Factory() "" + // static Resource_Factory "-ORBProtocolFactory PP_Factory" + // + // where "PP_Factory" is the name of your protocol, i.e. the + // second argument passed to the ACE_STATIC_SVC_DEFINE macro: + // + // ACE_STATIC_SVC_DEFINE (PP_Protocol_Factory, + // ACE_TEXT ("PP_Factory"), ...) + // + // "PP_Protocol_Factory" is the name of your protocol factory + // class. A "_make_" is prepended to your protocol factory + // class name by the ACE_FACTORY_DECLARE macro. The resulting + // factory function "_make_PP_Protocol_Factory()" is what should + // be used in the "dynamic" line in your svc.conf file. + // + // LIB is the base name of the shared library that implements + // the protocol. The directory containing your library must be + // in your library search path, typically defined by the + // LD_LIBRARY_PATH environment variable on UNIX systems, and/or + // the `/etc/ld.so.conf' file on some UNIX systems. Remember to + // run "ldconfig" if you modify `/etc/ld.so.conf'. + + TAO_Protocol_Factory *protocol_factory = 0; + auto_ptr safe_protocol_factory; + + TAO_Protocol_Item *item = 0; + + // If a protocol factory is obtained from the Service + // Configurator then do not transfer ownership to the + // TAO_Protocol_Item. + int transfer_ownership = 0; + + protocol_factory = + ACE_Dynamic_Service::instance ("IIOP_Factory"); + + if (protocol_factory == 0) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_WARNING, + ACE_TEXT ("TAO (%P|%t) No %s found in ") + ACE_TEXT ("Service Repository. ") + ACE_TEXT ("Using default instance IIOP ") + ACE_TEXT ("Protocol Factory.\n"), + ACE_TEXT ("IIOP Protocol Factory"))); + + ACE_NEW_RETURN (protocol_factory, + TAO_IIOP_Protocol_Factory, + -1); + + ACE_AUTO_PTR_RESET (safe_protocol_factory, + protocol_factory, + TAO_Protocol_Factory); + + transfer_ownership = 1; + } + else + { + transfer_ownership = 0; + } + + ACE_NEW_RETURN (item, + TAO_Protocol_Item ("IIOP_Factory"), + -1); + // If the TAO_Protocol_Item retains ownership of the + // TAO_Protocol_Factory then we used an auto_ptr<> above, so + // release the TAO_Protocol_Factory from it. Otherwise, we + // obtained the TAO_Protocol_Factory from the Service + // Configurator so an auto_ptr<> wasn't used since the Service + // Configurator retains ownership, hence there was no need to + // use an auto_ptr<> in this method. + item->factory ((transfer_ownership ? + safe_protocol_factory.release () : + protocol_factory), + transfer_ownership); + + if (this->protocol_factories_.insert (item) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) Unable to add ") + ACE_TEXT ("<%s> to protocol factory set.\n"), + item->protocol_name ().c_str ())); + + delete item; + + if (transfer_ownership == 0) + delete protocol_factory; + + return -1; + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Loaded default ") + ACE_TEXT ("protocol \n"))); + } + + return 0; +} + +int +TAO_Default_Resource_Factory::init_protocol_factories (void) +{ + TAO_ProtocolFactorySetItor end = protocol_factories_.end (); + TAO_ProtocolFactorySetItor factory = protocol_factories_.begin (); + + if (factory == end) + { + return this->load_default_protocols (); + } + + for (; factory != end; factory++) + { + const ACE_CString &name = (*factory)->protocol_name (); + (*factory)->factory ( + ACE_Dynamic_Service::instance (name.c_str ())); + if ((*factory)->factory () == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) Unable to load ") + ACE_TEXT ("protocol <%s>, %p\n"), + name.c_str (), ""), + -1); + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Loaded protocol <%s>\n"), + name.c_str ())); + } + } + + return 0; +} + +int +TAO_Default_Resource_Factory::use_tss_resources (void) const +{ + return this->use_tss_resources_; +} + +int +TAO_Default_Resource_Factory::use_locked_data_blocks (void) const +{ + return this->use_locked_data_blocks_; +} + +TAO_ProtocolFactorySet * +TAO_Default_Resource_Factory::get_protocol_factories (void) +{ + return &protocol_factories_; +} + +TAO_Acceptor_Registry* +TAO_Default_Resource_Factory::get_acceptor_registry (void) +{ + TAO_Acceptor_Registry *ar = 0; + + ACE_NEW_RETURN(ar, + TAO_Acceptor_Registry, + 0); + + return ar; +} + +TAO_Connector_Registry* +TAO_Default_Resource_Factory::get_connector_registry (void) +{ + TAO_Connector_Registry *cr = 0; + + ACE_NEW_RETURN(cr, + TAO_Connector_Registry, + 0); + + return cr; +} + +TAO_Reactor_Registry * +TAO_Default_Resource_Factory::get_reactor_registry (void) +{ + TAO_Reactor_Registry *reactor_registry = 0; + + ACE_NEW_RETURN (reactor_registry, + TAO_Single_Reactor, + 0); + return reactor_registry; +} + +ACE_Reactor_Impl* +TAO_Default_Resource_Factory::allocate_reactor_impl (void) const +{ + ACE_Reactor_Impl *impl = 0; + + ACE_NEW_RETURN (impl, ACE_TP_Reactor ((ACE_Sig_Handler*)0, + (ACE_Timer_Queue*)0, + this->reactor_mask_signals_), + 0); + return impl; +} + +ACE_Reactor * +TAO_Default_Resource_Factory::get_reactor (void) +{ + ACE_LOG_MSG->errnum (0); + + ACE_Reactor *reactor = 0; + ACE_NEW_RETURN (reactor, + ACE_Reactor (this->allocate_reactor_impl (), 1), + 0); + + if (ACE_LOG_MSG->errnum () != 0) + { + delete reactor; + reactor = 0; + } + else + this->dynamically_allocated_reactor_ = 1; + + return reactor; +} + +void +TAO_Default_Resource_Factory::reclaim_reactor (ACE_Reactor *reactor) +{ + if (this->dynamically_allocated_reactor_ == 1) + delete reactor; +} + + +typedef ACE_Malloc NULL_LOCK_MALLOC; +typedef ACE_Allocator_Adapter NULL_LOCK_ALLOCATOR; + +typedef ACE_Malloc LOCKED_MALLOC; +typedef ACE_Allocator_Adapter LOCKED_ALLOCATOR; + +ACE_Allocator * +TAO_Default_Resource_Factory::input_cdr_dblock_allocator (void) +{ + ACE_Allocator *allocator = 0; + ACE_NEW_RETURN (allocator, + LOCKED_ALLOCATOR, + 0); + + return allocator; +} + +ACE_Allocator * +TAO_Default_Resource_Factory::input_cdr_buffer_allocator (void) +{ + ACE_Allocator *allocator = 0; + ACE_NEW_RETURN (allocator, + LOCKED_ALLOCATOR, + 0); + + return allocator; +} + +ACE_Allocator * +TAO_Default_Resource_Factory::input_cdr_msgblock_allocator (void) +{ + ACE_Allocator *allocator = 0; + ACE_NEW_RETURN (allocator, + LOCKED_ALLOCATOR, + 0); + + return allocator; +} + +int +TAO_Default_Resource_Factory::input_cdr_allocator_type_locked (void) +{ + return 1; +} + +ACE_Allocator* +TAO_Default_Resource_Factory::output_cdr_dblock_allocator (void) +{ + ACE_Allocator *allocator = 0; + ACE_NEW_RETURN (allocator, NULL_LOCK_ALLOCATOR, 0); + return allocator; +} + +ACE_Allocator * +TAO_Default_Resource_Factory::output_cdr_buffer_allocator (void) +{ + ACE_Allocator *allocator = 0; + ACE_NEW_RETURN (allocator, NULL_LOCK_ALLOCATOR, 0); + return allocator; +} + +ACE_Allocator* +TAO_Default_Resource_Factory::output_cdr_msgblock_allocator (void) +{ + ACE_Allocator *allocator = 0; + ACE_NEW_RETURN (allocator, NULL_LOCK_ALLOCATOR, 0); + return allocator; +} + +TAO_Resource_Factory::Caching_Strategy +TAO_Default_Resource_Factory::connection_caching_strategy_type (void) const +{ + return this->connection_caching_type_; +} + +int +TAO_Default_Resource_Factory::cache_maximum (void) const +{ + return this->cache_maximum_; +} + +int +TAO_Default_Resource_Factory::purge_percentage (void) const +{ + return this->purge_percentage_; +} + +ACE_Lock * +TAO_Default_Resource_Factory::create_cached_connection_lock (void) +{ + ACE_Lock *the_lock = 0; + + if (this->cached_connection_lock_type_ == TAO_NULL_LOCK) + ACE_NEW_RETURN (the_lock, + ACE_Lock_Adapter, + 0); + else + ACE_NEW_RETURN (the_lock, + ACE_Lock_Adapter, + 0); + + return the_lock; +} + +TAO_Flushing_Strategy * +TAO_Default_Resource_Factory::create_flushing_strategy (void) +{ + TAO_Flushing_Strategy *strategy = 0; + if (this->flushing_strategy_type_ == TAO_REACTIVE_FLUSHING) + ACE_NEW_RETURN (strategy, + TAO_Reactive_Flushing_Strategy, + 0); + else + ACE_NEW_RETURN (strategy, + TAO_Block_Flushing_Strategy, + 0); + return strategy; +} + +TAO_Connection_Purging_Strategy * +TAO_Default_Resource_Factory::create_purging_strategy (void) +{ + TAO_Connection_Purging_Strategy *strategy = 0; + + if (this->connection_caching_type_ == TAO_Resource_Factory::LRU) + { + ACE_NEW_RETURN (strategy, + TAO_LRU_Connection_Purging_Strategy ( + this->cache_maximum ()), + 0); + } + else + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) - ") + ACE_TEXT ("no usable purging strategy ") + ACE_TEXT ("was found.\n"))); + } + + return strategy; +} + +TAO_LF_Strategy * +TAO_Default_Resource_Factory::create_lf_strategy (void) +{ + TAO_LF_Strategy *strategy = 0; + + ACE_NEW_RETURN (strategy, + TAO_Complete_LF_Strategy, + 0); + + return strategy; +} + +// **************************************************************** + +ACE_STATIC_SVC_DEFINE (TAO_Default_Resource_Factory, + ACE_TEXT ("Resource_Factory"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_Default_Resource_Factory), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) +ACE_FACTORY_DEFINE (TAO, TAO_Default_Resource_Factory) + +// **************************************************************** + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class auto_ptr; +template class ACE_Auto_Basic_Ptr; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate auto_ptr +#pragma instantiate ACE_Auto_Basic_Ptr + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ -- cgit v1.2.1