default_resource.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   default_resource.h
00006  *
00007  *  default_resource.h,v 1.66 2006/06/20 06:05:30 jwillemsen Exp
00008  *
00009  *  @author Chris Cleeland
00010  *  @author Carlos O'Ryan
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef TAO_DEFAULT_RESOURCE_H
00016 #define TAO_DEFAULT_RESOURCE_H
00017 
00018 #include /**/ "ace/pre.h"
00019 #include "ace/Service_Config.h"
00020 #include "ace/Dynamic_Service_Dependency.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "tao/Resource_Factory.h"
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 class ACE_Reactor_Impl;
00030 ACE_END_VERSIONED_NAMESPACE_DECL
00031 
00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 class TAO_Object_Adapter;
00035 class TAO_IOR_Parser;
00036 class TAO_LF_Strategy;
00037 class TAO_Codeset_Descriptor_Base;
00038 
00039 /**
00040  * @class TAO_Default_Resource_Factory
00041  *
00042  * @brief TAO's default resource factory
00043  *
00044  * Using a <{resource source specifier}> as a discriminator, the
00045  * factory can return resource instances which are, e.g., global,
00046  * stored in thread-specific storage, stored in shared memory,
00047  * etc.
00048  *
00049  * @note When using an ORB created by a dynamically loaded object, it
00050  *       is generally necessary to pre-load a "Resource_Factory" prior
00051  *       to initializing the ORB.  In the case of the
00052  *       TAO_Default_Resource_Factory, this can be done by adding the
00053  *       following Service Configurator directive to your `svc.conf'
00054  *       file before your the directive that loads the object that
00055  *       initialized your ORB:
00056  * @par
00057  *           static Resource_Factory ""
00058  * @par
00059  *       Alternatively, explicitly pre-load the Resource_Factory using
00060  *       the following in your code:
00061  * @par
00062  *           ACE_Service_Config::process_directive (
00063  *             ACE_TEXT ("static Resource_Factory \"\"") );
00064  * @par
00065  *       In both cases, place the appropriate resource factory
00066  *       arguments, if any, between the quotes immediately following
00067  *       "Resource_Factory."
00068  */
00069 class TAO_Export TAO_Default_Resource_Factory
00070   : public TAO_Resource_Factory
00071 {
00072 public:
00073 
00074   /// Constructor.
00075   TAO_Default_Resource_Factory (void);
00076 
00077   /// Destructor.
00078   virtual ~TAO_Default_Resource_Factory (void);
00079 
00080   /**
00081    * @name Service Configurator Hooks
00082    */
00083   //@{
00084   /// Dynamic linking hook
00085   virtual int init (int argc, ACE_TCHAR *argv[]);
00086 
00087   /// Parse svc.conf arguments
00088   int parse_args (int argc, ACE_TCHAR* argv[]);
00089   //@}
00090 
00091   /**
00092    * @name Member Accessors
00093    */
00094   //@{
00095 
00096   int get_parser_names (char **&names,
00097                         int &number_of_names);
00098   enum
00099   {
00100     TAO_ALLOCATOR_THREAD_LOCK
00101   };
00102 
00103   /// Modify and get the source for the CDR allocators
00104   int cdr_allocator_source (void);
00105 
00106   // = Resource Retrieval
00107   virtual int use_locked_data_blocks (void) const;
00108   virtual ACE_Reactor *get_reactor (void);
00109   virtual void reclaim_reactor (ACE_Reactor *);
00110   virtual TAO_Acceptor_Registry  *get_acceptor_registry (void);
00111   virtual TAO_Connector_Registry *get_connector_registry (void);
00112   virtual void use_local_memory_pool (bool);
00113   virtual ACE_Allocator* input_cdr_dblock_allocator (void);
00114   virtual ACE_Allocator* input_cdr_buffer_allocator (void);
00115   virtual ACE_Allocator* input_cdr_msgblock_allocator (void);
00116   virtual int input_cdr_allocator_type_locked (void);
00117   virtual ACE_Allocator* output_cdr_dblock_allocator (void);
00118   virtual ACE_Allocator* output_cdr_buffer_allocator (void);
00119   virtual ACE_Allocator* output_cdr_msgblock_allocator (void);
00120   virtual ACE_Allocator* amh_response_handler_allocator (void);
00121   virtual ACE_Allocator* ami_response_handler_allocator (void);
00122   virtual TAO_ProtocolFactorySet *get_protocol_factories (void);
00123 
00124   virtual int init_protocol_factories (void);
00125 
00126   virtual TAO_Codeset_Manager * codeset_manager (void);
00127 
00128   virtual int cache_maximum (void) const;
00129   virtual int purge_percentage (void) const;
00130   virtual int max_muxed_connections (void) const;
00131   virtual ACE_Lock *create_cached_connection_lock (void);
00132   virtual ACE_Lock *create_object_key_table_lock (void);
00133   virtual ACE_Lock *create_corba_object_lock (void);
00134   virtual int locked_transport_cache (void);
00135   virtual TAO_Flushing_Strategy *create_flushing_strategy (void);
00136   virtual TAO_Connection_Purging_Strategy *create_purging_strategy (void);
00137   TAO_Resource_Factory::Resource_Usage resource_usage_strategy (void) const;
00138   virtual TAO_LF_Strategy *create_lf_strategy (void);
00139   virtual auto_ptr<TAO_GIOP_Fragmentation_Strategy>
00140     create_fragmentation_strategy (TAO_Transport * transport,
00141                                    CORBA::ULong max_message_size) const;
00142   virtual void disable_factory (void);
00143   virtual bool drop_replies_during_shutdown (void) const;
00144   //@}
00145 
00146 protected:
00147 
00148   /// Obtain the reactor implementation
00149   virtual ACE_Reactor_Impl *allocate_reactor_impl (void) const;
00150 
00151   /// Add a Parser name to the list of Parser names.
00152   int add_to_ior_parser_names (const char *);
00153 
00154   void report_option_value_error (const ACE_TCHAR* option_name,
00155                                   const ACE_TCHAR* option_value);
00156 
00157 protected:
00158 
00159   /// The type of data blocks that the ORB should use
00160   int use_locked_data_blocks_;
00161 
00162   /// The number of the different types of Parsers.
00163   int parser_names_count_;
00164 
00165   /// Array consisting of the names of the parsers
00166   char **parser_names_;
00167 
00168   /// Index of the current element in the parser_names_ array
00169   int index_;
00170 
00171   /// list of loaded protocol factories.
00172   TAO_ProtocolFactorySet protocol_factories_;
00173 
00174   /// Specifies the typeof purging strategy we should use for cleaning
00175   /// up unused connections
00176   TAO_Resource_Factory::Purging_Strategy connection_purging_type_;
00177 
00178   /// Specifies the maximum number of connections which should get cached
00179   /// in the ORB.
00180   int cache_maximum_;
00181 
00182   /// Specifies the percentage of entries which should get purged on
00183   /// demand.
00184   int purge_percentage_;
00185 
00186   /// Specifies the limit on the number of muxed connections
00187   /// allowed per-property for the ORB. A value of 0 indicates no
00188   /// limit
00189   int max_muxed_connections_;
00190 
00191   /// If <0> then we create reactors with signal handling disabled.
00192   int reactor_mask_signals_;
00193 
00194   /**
00195    * Flag that is set to 1 if the reactor obtained from the
00196    * get_reactor() method is dynamically allocated.  If this flag is
00197    * set to 1, then the reclaim_reactor() method with call the delete
00198    * operator on the given reactor.  This flag is necessary to make
00199    * sure that a reactor not allocated by the default resource factory
00200    * is not reclaimed by the default resource factory.  Such a
00201    * situation can occur when a resource factory derived from the
00202    * default one overrides the get_reactor() method but does not
00203    * override the reclaim_reactor() method.
00204    */
00205   int dynamically_allocated_reactor_;
00206 
00207   virtual int load_default_protocols (void);
00208 
00209   /// This flag is used to determine whether options have been
00210   /// processed via the init() function.  It is necessary to
00211   /// properly report errors when the default factory is replaced.
00212   int options_processed_;
00213 
00214   /// This flag specifies whether the factory has been disabled.
00215   /// If it has been disabled we should print warnings if options
00216   /// were processed before (or later).
00217   int factory_disabled_;
00218 
00219   enum Output_CDR_Allocator_Type
00220     {
00221       LOCAL_MEMORY_POOL,
00222 #ifdef ACE_HAS_SENDFILE
00223       MMAP_ALLOCATOR,
00224 #endif  /* ACE_HAS_SENDFILE */
00225       DEFAULT
00226     };
00227 
00228   /// Type of allocator to use for output CDR buffers.
00229   Output_CDR_Allocator_Type output_cdr_allocator_type_;
00230 
00231   /// This flag is used to determine whether the CDR allocators
00232   /// should use the local memory pool or not.
00233   bool use_local_memory_pool_;
00234 
00235 private:
00236   void init_codeset_descriptors (void);
00237 
00238   enum Lock_Type
00239   {
00240     TAO_NULL_LOCK,
00241     TAO_THREAD_LOCK
00242   };
00243 
00244   /// Type of lock used by the cached connector.
00245   Lock_Type cached_connection_lock_type_;
00246 
00247   /// Type of lock used by the corba object.
00248   Lock_Type object_key_table_lock_type_;
00249 
00250   /// Type of lock used by the corba object.
00251   Lock_Type corba_object_lock_type_;
00252 
00253   enum Flushing_Strategy_Type
00254   {
00255     TAO_LEADER_FOLLOWER_FLUSHING,
00256     TAO_REACTIVE_FLUSHING,
00257     TAO_BLOCKING_FLUSHING
00258   };
00259 
00260   /// Type of flushing strategy configured
00261   Flushing_Strategy_Type flushing_strategy_type_;
00262 
00263   TAO_Codeset_Manager *codeset_manager_;
00264   TAO_Codeset_Descriptor_Base *char_codeset_descriptor_;
00265   TAO_Codeset_Descriptor_Base * wchar_codeset_descriptor_;
00266 
00267   /// Resource usage strategy
00268   Resource_Usage resource_usage_strategy_;
00269 
00270   /// Flag to indicate whether replies should be dropped during ORB
00271   /// shutdown.
00272   bool drop_replies_;
00273 
00274   // Makes a dependency on a specific dynamic service ("TAO_Codeset") explicit.
00275   // It helps to keep the corresponding DLL around until the last instance
00276   // is destroyed. Note that failure to delete the instances will "pin" the
00277   // DLL in memory, preventing it from being unloaded on demand.
00278   ACE_Dynamic_Service_Dependency *principal_;
00279 };
00280 
00281 TAO_END_VERSIONED_NAMESPACE_DECL
00282 
00283 ACE_STATIC_SVC_DECLARE_EXPORT (TAO, TAO_Default_Resource_Factory)
00284 ACE_FACTORY_DECLARE (TAO, TAO_Default_Resource_Factory)
00285 
00286 #include /**/ "ace/post.h"
00287 #endif /* TAO_DEFAULT_CLIENT_H */

Generated on Thu Nov 9 11:54:10 2006 for TAO by doxygen 1.3.6