default_resource.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   default_resource.h
00006  *
00007  *  $Id: default_resource.h 80944 2008-03-14 13:56:43Z johnnyw $
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/Copy_Disabled.h"
00020 #include "ace/Service_Config.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_Codeset_Parameters
00041  *
00042  * @brief A simple storage class for the native codeset and any
00043  * translators that must be configured when creating an instance of
00044  * codeset manager.
00045  *
00046  * The Resource Factory uses two instances of this class during its
00047  * initialization, to capture any native codeset or translators
00048  * settings. The RF later uses these parameters when creating
00049  * instances of the codeset manager.
00050  *
00051  * Perhaps, the best would be to place the responsibility for codeset
00052  * manager's configuration with the the codeset manager factory?
00053  *
00054  */
00055 class TAO_Export TAO_Codeset_Parameters
00056   : public ACE_Copy_Disabled
00057 {
00058 public:
00059   TAO_Codeset_Parameters (void);
00060   ~TAO_Codeset_Parameters (void);
00061 
00062   /// The native codeset (getter)
00063   const ACE_TCHAR* native (void);
00064 
00065   /// The native codeset (setter)
00066   void native (const ACE_TCHAR* n);
00067 
00068   /// Add a new codeset
00069   void add_translator (const ACE_TCHAR* name);
00070 
00071   typedef ACE_Unbounded_Queue_Iterator<ACE_TCHAR*> iterator;
00072 
00073   /// Iterate through the registered translators
00074   iterator translators (void);
00075 
00076   /// Apply the parameters to the said descriptor
00077   void apply_to (TAO_Codeset_Descriptor_Base *csd);
00078 
00079 private:
00080   ACE_Unbounded_Queue<ACE_TCHAR*> translators_;
00081   ACE_TCHAR* native_;
00082 };
00083 
00084 
00085 
00086 /**
00087  * @class TAO_Default_Resource_Factory
00088  *
00089  * @brief TAO's default resource factory
00090  *
00091  * Using a <{resource source specifier}> as a discriminator, the
00092  * factory can return resource instances which are, e.g., global,
00093  * stored in thread-specific storage, stored in shared memory,
00094  * etc.
00095  *
00096  * @note When using an ORB created by a dynamically loaded object, it
00097  *       is generally necessary to pre-load a "Resource_Factory" prior
00098  *       to initializing the ORB.  In the case of the
00099  *       TAO_Default_Resource_Factory, this can be done by adding the
00100  *       following Service Configurator directive to your `svc.conf'
00101  *       file before your the directive that loads the object that
00102  *       initialized your ORB:
00103  * @par
00104  *           static Resource_Factory ""
00105  * @par
00106  *       Alternatively, explicitly pre-load the Resource_Factory using
00107  *       the following in your code:
00108  * @par
00109  *           ACE_Service_Config::process_directive (
00110  *             ACE_TEXT ("static Resource_Factory \"\"") );
00111  * @par
00112  *       In both cases, place the appropriate resource factory
00113  *       arguments, if any, between the quotes immediately following
00114  *       "Resource_Factory."
00115  */
00116 class TAO_Export TAO_Default_Resource_Factory
00117   : public TAO_Resource_Factory
00118 {
00119 public:
00120 
00121   /// Constructor.
00122   TAO_Default_Resource_Factory (void);
00123 
00124   /// Destructor.
00125   virtual ~TAO_Default_Resource_Factory (void);
00126 
00127   /**
00128    * @name Service Configurator Hooks
00129    */
00130   //@{
00131   /// Dynamic linking hook
00132   virtual int init (int argc, ACE_TCHAR *argv[]);
00133 
00134   /// Parse svc.conf arguments
00135   int parse_args (int argc, ACE_TCHAR* argv[]);
00136   //@}
00137 
00138   /**
00139    * @name Member Accessors
00140    */
00141   //@{
00142 
00143   int get_parser_names (char **&names,
00144                         int &number_of_names);
00145   enum
00146   {
00147     TAO_ALLOCATOR_THREAD_LOCK
00148   };
00149 
00150   /// Modify and get the source for the CDR allocators
00151   int cdr_allocator_source (void);
00152 
00153   // = Resource Retrieval
00154   virtual int use_locked_data_blocks (void) const;
00155   virtual ACE_Reactor *get_reactor (void);
00156   virtual void reclaim_reactor (ACE_Reactor *);
00157   virtual TAO_Acceptor_Registry  *get_acceptor_registry (void);
00158   virtual TAO_Connector_Registry *get_connector_registry (void);
00159   virtual void use_local_memory_pool (bool);
00160   virtual ACE_Allocator* input_cdr_dblock_allocator (void);
00161   virtual ACE_Allocator* input_cdr_buffer_allocator (void);
00162   virtual ACE_Allocator* input_cdr_msgblock_allocator (void);
00163   virtual int input_cdr_allocator_type_locked (void);
00164   virtual ACE_Allocator* output_cdr_dblock_allocator (void);
00165   virtual ACE_Allocator* output_cdr_buffer_allocator (void);
00166   virtual ACE_Allocator* output_cdr_msgblock_allocator (void);
00167   virtual ACE_Allocator* amh_response_handler_allocator (void);
00168   virtual ACE_Allocator* ami_response_handler_allocator (void);
00169   virtual TAO_ProtocolFactorySet *get_protocol_factories (void);
00170 
00171   virtual int init_protocol_factories (void);
00172 
00173   virtual TAO_Codeset_Manager * codeset_manager (void);
00174 
00175   virtual int cache_maximum (void) const;
00176   virtual int purge_percentage (void) const;
00177   virtual int max_muxed_connections (void) const;
00178   virtual ACE_Lock *create_cached_connection_lock (void);
00179   virtual ACE_Lock *create_object_key_table_lock (void);
00180   virtual TAO_Configurable_Refcount create_corba_object_refcount (void);
00181   virtual ACE_Lock *create_corba_object_lock (void);
00182   virtual int locked_transport_cache (void);
00183   virtual TAO_Flushing_Strategy *create_flushing_strategy (void);
00184   virtual TAO_Connection_Purging_Strategy *create_purging_strategy (void);
00185   TAO_Resource_Factory::Resource_Usage resource_usage_strategy (void) const;
00186   virtual TAO_LF_Strategy *create_lf_strategy (void);
00187   virtual auto_ptr<TAO_GIOP_Fragmentation_Strategy>
00188     create_fragmentation_strategy (TAO_Transport * transport,
00189                                    CORBA::ULong max_message_size) const;
00190   virtual void disable_factory (void);
00191   virtual bool drop_replies_during_shutdown (void) const;
00192   //@}
00193 
00194 protected:
00195 
00196   /// Obtain the reactor implementation
00197   virtual ACE_Reactor_Impl *allocate_reactor_impl (void) const;
00198 
00199   /// Add a Parser name to the list of Parser names.
00200   int add_to_ior_parser_names (const char *);
00201 
00202   void report_option_value_error (const ACE_TCHAR* option_name,
00203                                   const ACE_TCHAR* option_value);
00204 
00205 protected:
00206 
00207   /// The type of data blocks that the ORB should use
00208   int use_locked_data_blocks_;
00209 
00210   /// The number of the different types of Parsers.
00211   int parser_names_count_;
00212 
00213   /// Array consisting of the names of the parsers
00214   char **parser_names_;
00215 
00216   /// Index of the current element in the parser_names_ array
00217   int index_;
00218 
00219   /// list of loaded protocol factories.
00220   TAO_ProtocolFactorySet protocol_factories_;
00221 
00222   /// Specifies the typeof purging strategy we should use for cleaning
00223   /// up unused connections
00224   TAO_Resource_Factory::Purging_Strategy connection_purging_type_;
00225 
00226   /// Specifies the maximum number of connections which should get cached
00227   /// in the ORB.
00228   int cache_maximum_;
00229 
00230   /// Specifies the percentage of entries which should get purged on
00231   /// demand.
00232   int purge_percentage_;
00233 
00234   /// Specifies the limit on the number of muxed connections
00235   /// allowed per-property for the ORB. A value of 0 indicates no
00236   /// limit
00237   int max_muxed_connections_;
00238 
00239   /// If <0> then we create reactors with signal handling disabled.
00240   int reactor_mask_signals_;
00241 
00242   /**
00243    * Flag that is set to true if the reactor obtained from the
00244    * get_reactor() method is dynamically allocated.  If this flag is
00245    * set to true, then the reclaim_reactor() method with call the delete
00246    * operator on the given reactor.  This flag is necessary to make
00247    * sure that a reactor not allocated by the default resource factory
00248    * is not reclaimed by the default resource factory.  Such a
00249    * situation can occur when a resource factory derived from the
00250    * default one overrides the get_reactor() method but does not
00251    * override the reclaim_reactor() method.
00252    */
00253   bool dynamically_allocated_reactor_;
00254 
00255   virtual int load_default_protocols (void);
00256 
00257   /// This flag is used to determine whether options have been
00258   /// processed via the init() function.  It is necessary to
00259   /// properly report errors when the default factory is replaced.
00260   int options_processed_;
00261 
00262   /// This flag specifies whether the factory has been disabled.
00263   /// If it has been disabled we should print warnings if options
00264   /// were processed before (or later).
00265   int factory_disabled_;
00266 
00267   enum Output_CDR_Allocator_Type
00268     {
00269       LOCAL_MEMORY_POOL,
00270 #if TAO_HAS_SENDFILE == 1
00271       MMAP_ALLOCATOR,
00272 #endif  /* TAO_HAS_SENDFILE == 1*/
00273       DEFAULT
00274     };
00275 
00276   /// Type of allocator to use for output CDR buffers.
00277   Output_CDR_Allocator_Type output_cdr_allocator_type_;
00278 
00279   /// This flag is used to determine whether the CDR allocators
00280   /// should use the local memory pool or not.
00281   bool use_local_memory_pool_;
00282 
00283 private:
00284   enum Lock_Type
00285   {
00286     TAO_NULL_LOCK,
00287     TAO_THREAD_LOCK
00288   };
00289 
00290   /// Type of lock used by the cached connector.
00291   Lock_Type cached_connection_lock_type_;
00292 
00293   /// Type of lock used by the corba object.
00294   Lock_Type object_key_table_lock_type_;
00295 
00296   /// Type of lock used by the corba object.
00297   Lock_Type corba_object_lock_type_;
00298 
00299   enum Flushing_Strategy_Type
00300   {
00301     TAO_LEADER_FOLLOWER_FLUSHING,
00302     TAO_REACTIVE_FLUSHING,
00303     TAO_BLOCKING_FLUSHING
00304   };
00305 
00306   /// Type of flushing strategy configured
00307   Flushing_Strategy_Type flushing_strategy_type_;
00308 
00309   // Initialization options. To be used later when creating a codeset
00310   // manager instance (s)
00311   TAO_Codeset_Parameters char_codeset_parameters_;
00312   TAO_Codeset_Parameters wchar_codeset_parameters_;
00313 
00314   /// Resource usage strategy
00315   Resource_Usage resource_usage_strategy_;
00316 
00317   /// Flag to indicate whether replies should be dropped during ORB
00318   /// shutdown.
00319   bool drop_replies_;
00320 };
00321 
00322 TAO_END_VERSIONED_NAMESPACE_DECL
00323 
00324 ACE_STATIC_SVC_DECLARE_EXPORT (TAO, TAO_Default_Resource_Factory)
00325 ACE_FACTORY_DECLARE (TAO, TAO_Default_Resource_Factory)
00326 
00327 #include /**/ "ace/post.h"
00328 #endif /* TAO_DEFAULT_CLIENT_H */

Generated on Tue Feb 2 17:37:51 2010 for TAO by  doxygen 1.4.7