3 //=============================================================================
5 * @file default_resource.h
7 * @author Chris Cleeland
8 * @author Carlos O'Ryan
10 //=============================================================================
13 #ifndef TAO_DEFAULT_RESOURCE_H
14 #define TAO_DEFAULT_RESOURCE_H
16 #include /**/ "ace/pre.h"
17 #include "ace/Service_Config.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "tao/Resource_Factory.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 class ACE_Reactor_Impl
;
27 ACE_END_VERSIONED_NAMESPACE_DECL
29 #include "ace/Timer_Queuefwd.h"
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 class TAO_Object_Adapter
;
35 class TAO_LF_Strategy
;
36 class TAO_Codeset_Descriptor_Base
;
37 class TAO_Time_Policy_Manager
;
38 class TAO_RSF_Timer_Queue_Ptr
;
41 * @class TAO_Codeset_Parameters
43 * @brief A simple storage class for the native codeset and any
44 * translators that must be configured when creating an instance of
47 * The Resource Factory uses two instances of this class during its
48 * initialization, to capture any native codeset or translators
49 * settings. The RF later uses these parameters when creating
50 * instances of the codeset manager.
52 * Perhaps, the best would be to place the responsibility for codeset
53 * manager's configuration with the the codeset manager factory?
55 class TAO_Export TAO_Codeset_Parameters
58 TAO_Codeset_Parameters ();
59 ~TAO_Codeset_Parameters ();
61 /// The native codeset (getter)
62 const ACE_TCHAR
* native ();
64 /// The native codeset (setter)
65 void native (const ACE_TCHAR
* n
);
68 void add_translator (const ACE_TCHAR
* name
);
70 typedef ACE_Unbounded_Queue_Iterator
<ACE_TCHAR
*> iterator
;
72 /// Iterate through the registered translators
73 iterator
translators ();
75 /// Apply the parameters to the said descriptor
76 void apply_to (TAO_Codeset_Descriptor_Base
*csd
);
79 TAO_Codeset_Parameters (const TAO_Codeset_Parameters
&) = delete;
80 TAO_Codeset_Parameters
&operator= (const TAO_Codeset_Parameters
&) = delete;
82 ACE_Unbounded_Queue
<ACE_TCHAR
*> translators_
;
87 * @class TAO_Default_Resource_Factory
89 * @brief TAO's default resource factory
91 * Using a <{resource source specifier}> as a discriminator, the
92 * factory can return resource instances which are, e.g., global,
93 * stored in thread-specific storage, stored in shared memory,
96 * @note When using an ORB created by a dynamically loaded object, it
97 * is generally necessary to pre-load a "Resource_Factory" prior
98 * to initializing the ORB. In the case of the
99 * TAO_Default_Resource_Factory, this can be done by adding the
100 * following Service Configurator directive to your `svc.conf'
101 * file before your the directive that loads the object that
102 * initialized your ORB:
104 * static Resource_Factory ""
106 * Alternatively, explicitly pre-load the Resource_Factory using
107 * the following in your code:
109 * ACE_Service_Config::process_directive (
110 * ACE_TEXT ("static Resource_Factory \"\"") );
112 * In both cases, place the appropriate resource factory
113 * arguments, if any, between the quotes immediately following
114 * "Resource_Factory."
116 class TAO_Export TAO_Default_Resource_Factory
117 : public TAO_Resource_Factory
121 TAO_Default_Resource_Factory ();
124 virtual ~TAO_Default_Resource_Factory ();
127 * @name Service Configurator Hooks
130 /// Dynamic linking hook
131 virtual int init (int argc
, ACE_TCHAR
*argv
[]);
133 /// Parse svc.conf arguments
134 int parse_args (int argc
, ACE_TCHAR
* argv
[]);
138 * @name Member Accessors
141 int get_parser_names (char **&names
,
142 int &number_of_names
);
145 TAO_ALLOCATOR_THREAD_LOCK
148 /// Modify and get the source for the CDR allocators
149 int cdr_allocator_source ();
151 // = Resource Retrieval
152 virtual int use_locked_data_blocks () const;
153 virtual ACE_Reactor
*get_reactor ();
154 virtual void reclaim_reactor (ACE_Reactor
*);
155 virtual TAO_Acceptor_Registry
*get_acceptor_registry ();
156 virtual TAO_Connector_Registry
*get_connector_registry ();
157 virtual void use_local_memory_pool (bool);
158 virtual ACE_Allocator
* input_cdr_dblock_allocator ();
159 virtual ACE_Allocator
* input_cdr_buffer_allocator ();
160 virtual ACE_Allocator
* input_cdr_msgblock_allocator ();
161 virtual int input_cdr_allocator_type_locked ();
162 virtual ACE_Allocator
* output_cdr_dblock_allocator ();
163 virtual ACE_Allocator
* output_cdr_buffer_allocator ();
164 virtual ACE_Allocator
* output_cdr_msgblock_allocator ();
165 virtual ACE_Allocator
* amh_response_handler_allocator ();
166 virtual ACE_Allocator
* ami_response_handler_allocator ();
167 virtual TAO_ProtocolFactorySet
*get_protocol_factories ();
169 virtual int init_protocol_factories ();
171 virtual TAO_Codeset_Manager
* codeset_manager ();
173 virtual int cache_maximum () const;
174 virtual int purge_percentage () const;
175 virtual int max_muxed_connections () const;
176 virtual ACE_Lock
*create_cached_connection_lock ();
177 virtual int locked_transport_cache ();
178 virtual TAO_Flushing_Strategy
*create_flushing_strategy ();
179 virtual TAO_Connection_Purging_Strategy
*create_purging_strategy ();
180 TAO_Resource_Factory::Resource_Usage
resource_usage_strategy () const;
181 virtual TAO_LF_Strategy
*create_lf_strategy ();
182 virtual TAO_GIOP_Fragmentation_Strategy
*
183 create_fragmentation_strategy (TAO_Transport
* transport
,
184 CORBA::ULong max_message_size
) const;
185 virtual void disable_factory ();
186 virtual bool drop_replies_during_shutdown () const;
190 friend class TAO_RSF_Timer_Queue_Ptr
;
192 #if (TAO_HAS_TIME_POLICY == 1)
193 TAO_Time_Policy_Manager
* time_policy_manager () const;
196 ACE_Timer_Queue
* create_timer_queue () const;
198 void destroy_timer_queue (ACE_Timer_Queue
*tmq
) const;
200 /// Obtain the reactor implementation
201 virtual ACE_Reactor_Impl
*allocate_reactor_impl () const;
203 /// Add a Parser name to the list of Parser names.
204 int add_to_ior_parser_names (const char *);
206 void report_option_value_error (const ACE_TCHAR
* option_name
,
207 const ACE_TCHAR
* option_value
);
210 /// The type of data blocks that the ORB should use
211 int use_locked_data_blocks_
;
213 /// The number of the different types of Parsers.
214 int parser_names_count_
;
216 /// Array consisting of the names of the parsers
217 char **parser_names_
;
219 /// Index of the current element in the parser_names_ array
222 /// list of loaded protocol factories.
223 TAO_ProtocolFactorySet protocol_factories_
;
225 /// Specifies the typeof purging strategy we should use for cleaning
226 /// up unused connections
227 TAO_Resource_Factory::Purging_Strategy connection_purging_type_
;
229 /// Specifies the maximum number of connections which should get cached
233 /// Specifies the percentage of entries which should get purged on
235 int purge_percentage_
;
237 /// Specifies the limit on the number of muxed connections
238 /// allowed per-property for the ORB. A value of 0 indicates no
240 int max_muxed_connections_
;
242 /// If 0 then we create reactors with signal handling disabled.
243 int reactor_mask_signals_
;
246 * Flag that is set to true if the reactor obtained from the
247 * get_reactor() method is dynamically allocated. If this flag is
248 * set to true, then the reclaim_reactor() method with call the delete
249 * operator on the given reactor. This flag is necessary to make
250 * sure that a reactor not allocated by the default resource factory
251 * is not reclaimed by the default resource factory. Such a
252 * situation can occur when a resource factory derived from the
253 * default one overrides the get_reactor() method but does not
254 * override the reclaim_reactor() method.
256 bool dynamically_allocated_reactor_
;
258 virtual int load_default_protocols ();
260 /// This flag is used to determine whether options have been
261 /// processed via the init() function. It is necessary to
262 /// properly report errors when the default factory is replaced.
263 int options_processed_
;
265 /// This flag specifies whether the factory has been disabled.
266 /// If it has been disabled we should print warnings if options
267 /// were processed before (or later).
268 int factory_disabled_
;
270 enum Output_CDR_Allocator_Type
273 #if TAO_HAS_SENDFILE == 1
275 #endif /* TAO_HAS_SENDFILE == 1*/
279 /// Type of allocator to use for output CDR buffers.
280 Output_CDR_Allocator_Type output_cdr_allocator_type_
;
282 /// This flag is used to determine whether the CDR allocators
283 /// should use the local memory pool or not.
284 bool use_local_memory_pool_
;
293 /// Type of lock used by the cached connector.
294 Lock_Type cached_connection_lock_type_
;
296 enum Flushing_Strategy_Type
298 TAO_LEADER_FOLLOWER_FLUSHING
,
299 TAO_REACTIVE_FLUSHING
,
300 TAO_BLOCKING_FLUSHING
303 /// Type of flushing strategy configured
304 Flushing_Strategy_Type flushing_strategy_type_
;
306 /// Initialization options. To be used later when creating a codeset
307 /// manager instance (s)
308 TAO_Codeset_Parameters char_codeset_parameters_
;
309 TAO_Codeset_Parameters wchar_codeset_parameters_
;
311 /// Resource usage strategy
312 Resource_Usage resource_usage_strategy_
;
314 /// Flag to indicate whether replies should be dropped during ORB
319 ACE_STATIC_SVC_DECLARE_EXPORT (TAO
, TAO_Default_Resource_Factory
)
320 ACE_FACTORY_DECLARE (TAO
, TAO_Default_Resource_Factory
)
323 * @class TAO_RSF_Timer_Queue_Ptr
325 * @brief A simple auto_ptr like class to manage timer queues dynamically
326 * allocated by a time policy.
328 class TAO_Export TAO_RSF_Timer_Queue_Ptr
331 TAO_RSF_Timer_Queue_Ptr (TAO_Default_Resource_Factory
const &, ACE_Timer_Queue
*);
332 ~TAO_RSF_Timer_Queue_Ptr ();
334 ACE_Timer_Queue
* get ();
338 TAO_Default_Resource_Factory
const & resource_factory_
;
339 ACE_Timer_Queue
* timer_queue_
;
342 TAO_END_VERSIONED_NAMESPACE_DECL
344 #if defined (__ACE_INLINE__)
345 #include "tao/default_resource.inl"
346 #endif /* __ACE_INLINE__ */
348 #include /**/ "ace/post.h"
350 #endif /* TAO_DEFAULT_CLIENT_H */