summaryrefslogtreecommitdiff
path: root/TAO/tao/default_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/default_server.cpp')
-rw-r--r--TAO/tao/default_server.cpp272
1 files changed, 184 insertions, 88 deletions
diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp
index c1a76f1b9e4..642dd9405dd 100644
--- a/TAO/tao/default_server.cpp
+++ b/TAO/tao/default_server.cpp
@@ -11,6 +11,10 @@ ACE_RCSID(tao, default_server, "$Id$")
TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory (void)
: thread_flags_ (THR_BOUND),
+ active_object_map_size_ (TAO_DEFAULT_SERVER_ACTIVE_OBJECT_MAP_SIZE),
+ object_lookup_strategy_for_user_id_policy_ (TAO_DYNAMIC_HASH),
+ object_lookup_strategy_for_system_id_policy_ (TAO_ACTIVE_DEMUX),
+ reverse_object_lookup_strategy_for_unique_id_policy_ (TAO_DYNAMIC_HASH),
poa_lock_type_ (TAO_THREAD_LOCK),
poa_mgr_lock_type_ (TAO_THREAD_LOCK),
event_loop_lock_type_ (TAO_NULL_LOCK),
@@ -45,17 +49,53 @@ TAO_Default_Server_Strategy_Factory::concurrency_strategy (void)
return this->concurrency_strategy_;
}
-int
-TAO_Default_Server_Strategy_Factory::enable_poa_locking (void)
+ACE_Lock *
+TAO_Default_Server_Strategy_Factory::create_poa_lock (void)
{
+ ACE_Lock *the_lock = 0;
+
switch (this->poa_lock_type_)
{
- case TAO_NULL_LOCK:
- return 0;
case TAO_THREAD_LOCK:
+#if defined (ACE_HAS_THREADS)
+ ACE_NEW_RETURN (the_lock,
+ ACE_Lock_Adapter<ACE_Recursive_Thread_Mutex> (),
+ 0);
+ break;
+#endif /* ACE_HAS_THREADS */
default:
- return 1;
+ ACE_NEW_RETURN (the_lock,
+ ACE_Lock_Adapter<ACE_Null_Mutex> (),
+ 0);
+ break;
}
+
+ return the_lock;// Just to make sure we return something
+}
+
+ACE_Lock *
+TAO_Default_Server_Strategy_Factory::create_poa_mgr_lock (void)
+{
+ ACE_Lock *the_lock = 0;
+
+ switch (this->poa_mgr_lock_type_)
+ {
+ case TAO_THREAD_LOCK:
+#if defined (ACE_HAS_THREADS)
+ ACE_NEW_RETURN (the_lock,
+ ACE_Lock_Adapter<ACE_Thread_Mutex> (),
+ 0);
+ break;
+#endif /* ACE_HAS_THREADS */
+ default:
+ ACE_NEW_RETURN (the_lock,
+ ACE_Lock_Adapter<ACE_Null_Mutex> (),
+ 0);
+ break;
+ }
+
+ // Just to make sure we return something.
+ return the_lock;
}
ACE_Lock *
@@ -129,6 +169,105 @@ TAO_Default_Server_Strategy_Factory::create_cached_connector_lock (void)
return the_lock;
}
+TAO_Active_Object_Map_Impl *
+TAO_Default_Server_Strategy_Factory::create_active_object_map (int user_id_policy)
+{
+ if (user_id_policy)
+ return this->create_user_id_policy_active_object_map ();
+ else
+ return this->create_system_id_policy_active_object_map ();
+}
+
+TAO_Active_Object_Map_Impl *
+TAO_Default_Server_Strategy_Factory::create_user_id_policy_active_object_map (void)
+{
+ return this->create_active_object_map_i (this->object_lookup_strategy_for_user_id_policy_, 1);
+}
+
+TAO_Active_Object_Map_Impl *
+TAO_Default_Server_Strategy_Factory::create_system_id_policy_active_object_map (void)
+{
+ return this->create_active_object_map_i (this->object_lookup_strategy_for_system_id_policy_, 0);
+}
+
+TAO_Active_Object_Map_Impl *
+TAO_Default_Server_Strategy_Factory::create_active_object_map_i (TAO_Demux_Strategy table_type,
+ int user_id_policy)
+{
+ // Create the appropriate-sized object table based on passed
+ // arguments.
+ TAO_Active_Object_Map_Impl *objtable = 0;
+
+ switch (table_type)
+ {
+ case TAO_LINEAR:
+ ACE_NEW_RETURN (objtable,
+ TAO_Linear_Active_Object_Map (this->active_object_map_size_),
+ 0);
+ break;
+ // Don't do this one right now until we determine how to deal
+ // with its reliance on a global singleton.
+ case TAO_USER_DEFINED:
+ // it is assumed that the user would have used the hooks to
+ // supply a user-defined instance of the object table
+ //
+ // Note that the usage below doesn't really fit very well now.
+ // We need for the userdef stuff to provide a creation hook--IF
+ // we decide to keep the whole demultiplexing strategy creation
+ // the way it is. IMHO, the way that userdef stuff should be
+ // done is to create the User_Server_Strategy_Factory and just
+ // link it in. The default server would only encompass the
+ // strategies that are "shipped", so to speak. --cjc
+ if (user_id_policy)
+ objtable = TAO_ORB_Core_instance()->oa_params()->userdef_lookup_strategy_for_user_id_policy ();
+ else
+ objtable = TAO_ORB_Core_instance()->oa_params()->userdef_lookup_strategy_for_system_id_policy ();
+ break;
+ case TAO_ACTIVE_DEMUX:
+ ACE_NEW_RETURN (objtable,
+ TAO_Active_Demux_Active_Object_Map (this->active_object_map_size_),
+ 0);
+ break;
+ case TAO_DYNAMIC_HASH:
+ ACE_NEW_RETURN (objtable,
+ TAO_Dynamic_Hash_Active_Object_Map (this->active_object_map_size_),
+ 0);
+ break;
+ }
+
+ return objtable;
+}
+
+TAO_Reverse_Active_Object_Map_Impl *
+TAO_Default_Server_Strategy_Factory::create_reverse_active_object_map (int unique_id_policy)
+{
+ // Create the appropriate-sized object table based on passed
+ // arguments.
+ TAO_Reverse_Active_Object_Map_Impl *objtable = 0;
+
+ if (unique_id_policy)
+ {
+ if (this->reverse_object_lookup_strategy_for_unique_id_policy_ == TAO_USER_DEFINED)
+ {
+ objtable = TAO_ORB_Core_instance ()->oa_params ()->userdef_reverse_lookup_strategy_for_unique_id_policy ();
+ }
+ else
+ {
+ ACE_NEW_RETURN (objtable,
+ TAO_Reverse_Active_Object_Map_For_Unique_Id_Policy (this->active_object_map_size_),
+ 0);
+ }
+ }
+ else
+ {
+ ACE_NEW_RETURN (objtable,
+ TAO_Reverse_Active_Object_Map_For_Multiple_Id_Policy (),
+ 0);
+ }
+
+ return objtable;
+}
+
// Evil macros b/c I'm lazy!
#define TAO_BEGINCHECK if (0)
#define TAO_CHECKANDSET(sym) else if (ACE_OS::strcmp (flag, #sym) == 0) ACE_SET_BITS (this->thread_flags_, sym)
@@ -162,8 +301,10 @@ TAO_Default_Server_Strategy_Factory::init (int argc, char *argv[])
}
int
-TAO_Default_Server_Strategy_Factory::open (TAO_ORB_Core* orb_core)
+TAO_Default_Server_Strategy_Factory::open (void)
{
+ TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
+
if (reactive_strategy_.open (orb_core->reactor ()) == 0
&& threaded_strategy_.open (orb_core->thr_mgr (),
this->thread_flags_) == 0)
@@ -193,48 +334,11 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
this->concurrency_strategy_ = &threaded_strategy_;
}
}
- else if (ACE_OS::strcmp (argv[curarg], "-ORBtablesize") == 0 ||
- ACE_OS::strcmp (argv[curarg], "-ORBactiveobjectmapsize") == 0)
- {
- curarg++;
- if (curarg < argc)
- this->active_object_map_creation_parameters_.active_object_map_size_ = ACE_OS::strtoul (argv[curarg], 0, 10);
- }
- else if (ACE_OS::strcmp (argv[curarg], "-ORBpoamapsize") == 0)
- {
- curarg++;
- if (curarg < argc)
- this->active_object_map_creation_parameters_.poa_map_size_ = ACE_OS::strtoul (argv[curarg], 0, 10);
- }
- else if (ACE_OS::strcmp (argv[curarg], "-ORBactivehintinids") == 0)
+ else if (ACE_OS::strcmp (argv[curarg], "-ORBtablesize") == 0)
{
curarg++;
if (curarg < argc)
- {
- char *value = argv[curarg];
-
- this->active_object_map_creation_parameters_.use_active_hint_in_ids_ = ACE_OS::atoi (value);
- }
- }
- else if (ACE_OS::strcmp (argv[curarg], "-ORBactivehintinpoanames") == 0)
- {
- curarg++;
- if (curarg < argc)
- {
- char *value = argv[curarg];
-
- this->active_object_map_creation_parameters_.use_active_hint_in_poa_names_ = ACE_OS::atoi (value);
- }
- }
- else if (ACE_OS::strcmp (argv[curarg], "-ORBallowreactivationofsystemids") == 0)
- {
- curarg++;
- if (curarg < argc)
- {
- char *value = argv[curarg];
-
- this->active_object_map_creation_parameters_.allow_reactivation_of_system_ids_ = ACE_OS::atoi (value);
- }
+ this->active_object_map_size_ = ACE_OS::strtoul (argv[curarg], 0, 10);
}
else if (ACE_OS::strcmp (argv[curarg], "-ORBuseridpolicydemuxstrategy") == 0)
{
@@ -245,9 +349,11 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
// Active demux not supported with user id policy
if (ACE_OS::strcasecmp (name, "dynamic") == 0)
- this->active_object_map_creation_parameters_.object_lookup_strategy_for_user_id_policy_ = TAO_DYNAMIC_HASH;
+ this->object_lookup_strategy_for_user_id_policy_ = TAO_DYNAMIC_HASH;
else if (ACE_OS::strcasecmp (name, "linear") == 0)
- this->active_object_map_creation_parameters_.object_lookup_strategy_for_user_id_policy_ = TAO_LINEAR;
+ this->object_lookup_strategy_for_user_id_policy_ = TAO_LINEAR;
+ else if (ACE_OS::strcasecmp (name, "user") == 0)
+ this->object_lookup_strategy_for_user_id_policy_ = TAO_USER_DEFINED;
}
}
else if (ACE_OS::strcmp (argv[curarg], "-ORBsystemidpolicydemuxstrategy") == 0)
@@ -258,28 +364,16 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
char *name = argv[curarg];
if (ACE_OS::strcasecmp (name, "dynamic") == 0)
- this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ = TAO_DYNAMIC_HASH;
+ this->object_lookup_strategy_for_system_id_policy_ = TAO_DYNAMIC_HASH;
else if (ACE_OS::strcasecmp (name, "linear") == 0)
- this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ = TAO_LINEAR;
+ this->object_lookup_strategy_for_system_id_policy_ = TAO_LINEAR;
else if (ACE_OS::strcasecmp (name, "active") == 0)
- this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ = TAO_ACTIVE_DEMUX;
+ this->object_lookup_strategy_for_system_id_policy_ = TAO_ACTIVE_DEMUX;
+ else if (ACE_OS::strcasecmp (name, "user") == 0)
+ this->object_lookup_strategy_for_system_id_policy_ = TAO_USER_DEFINED;
}
}
- else if (ACE_OS::strcmp (argv[curarg], "-ORBpersistentidpolicydemuxstrategy") == 0)
- {
- curarg++;
- if (curarg < argc)
- {
- char *name = argv[curarg];
-
- // Active demux not supported with user id policy
- if (ACE_OS::strcasecmp (name, "dynamic") == 0)
- this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ = TAO_DYNAMIC_HASH;
- else if (ACE_OS::strcasecmp (name, "linear") == 0)
- this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ = TAO_LINEAR;
- }
- }
- else if (ACE_OS::strcmp (argv[curarg], "-ORBtransientidpolicydemuxstrategy") == 0)
+ else if (ACE_OS::strcmp (argv[curarg], "-ORBuniqueidpolicyreversedemuxstrategy") == 0)
{
curarg++;
if (curarg < argc)
@@ -287,34 +381,25 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
char *name = argv[curarg];
if (ACE_OS::strcasecmp (name, "dynamic") == 0)
- this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ = TAO_DYNAMIC_HASH;
- else if (ACE_OS::strcasecmp (name, "linear") == 0)
- this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ = TAO_LINEAR;
- else if (ACE_OS::strcasecmp (name, "active") == 0)
- this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ = TAO_ACTIVE_DEMUX;
+ this->reverse_object_lookup_strategy_for_unique_id_policy_ = TAO_DYNAMIC_HASH;
+ else if (ACE_OS::strcasecmp (name, "user") == 0)
+ this->reverse_object_lookup_strategy_for_unique_id_policy_ = TAO_USER_DEFINED;
}
}
- else if (ACE_OS::strcmp (argv[curarg], "-ORBuniqueidpolicyreversedemuxstrategy") == 0)
+ else if (ACE_OS::strcmp (argv[curarg], "-ORBpoalock") == 0)
{
curarg++;
if (curarg < argc)
{
char *name = argv[curarg];
- if (ACE_OS::strcasecmp (name, "dynamic") == 0)
- this->active_object_map_creation_parameters_.reverse_object_lookup_strategy_for_unique_id_policy_ = TAO_DYNAMIC_HASH;
- else if (ACE_OS::strcasecmp (name, "linear") == 0)
- this->active_object_map_creation_parameters_.reverse_object_lookup_strategy_for_unique_id_policy_ = TAO_LINEAR;
+ if (ACE_OS::strcasecmp (name, "thread") == 0)
+ this->poa_lock_type_ = TAO_THREAD_LOCK;
+ else if (ACE_OS::strcasecmp (name, "null") == 0)
+ this->poa_lock_type_ = TAO_NULL_LOCK;
}
}
- else if (ACE_OS::strcmp (argv[curarg], "-ORBdemuxstrategy") == 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "Warning: -ORBdemuxstrategy is deprecated. Please use "
- "-ORBsystemidpolicydemuxstrategy or -ORBuseridpolicydemuxstrategy instead.\n"));
- curarg++;
- }
- else if (ACE_OS::strcmp (argv[curarg], "-ORBpoalock") == 0)
+ else if (ACE_OS::strcmp (argv[curarg], "-ORBpoamgrlock") == 0)
{
curarg++;
if (curarg < argc)
@@ -322,9 +407,9 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
char *name = argv[curarg];
if (ACE_OS::strcasecmp (name, "thread") == 0)
- this->poa_lock_type_ = TAO_THREAD_LOCK;
+ this->poa_mgr_lock_type_ = TAO_THREAD_LOCK;
else if (ACE_OS::strcasecmp (name, "null") == 0)
- this->poa_lock_type_ = TAO_NULL_LOCK;
+ this->poa_mgr_lock_type_ = TAO_NULL_LOCK;
}
}
else if (ACE_OS::strcmp (argv[curarg], "-ORBeventlock") == 0)
@@ -377,13 +462,21 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[])
return 0;
}
-TAO_Default_Server_Creation_Strategy::TAO_Default_Server_Creation_Strategy (ACE_Thread_Manager *t)
+u_long
+TAO_Default_Server_Strategy_Factory::active_object_map_size (void) const
+{
+ return this->active_object_map_size_;
+}
+
+TAO_Default_Server_Creation_Strategy::
+TAO_Default_Server_Creation_Strategy (ACE_Thread_Manager *t)
: ACE_Creation_Strategy<TAO_Server_Connection_Handler> (t)
{
}
int
-TAO_Default_Server_Creation_Strategy::make_svc_handler (TAO_Server_Connection_Handler *&sh)
+TAO_Default_Server_Creation_Strategy::
+make_svc_handler (TAO_Server_Connection_Handler *&sh)
{
if (sh == 0)
{
@@ -409,10 +502,13 @@ template class ACE_Thread_Strategy<TAO_Server_Connection_Handler>;
#pragma instantiate ACE_Thread_Strategy<TAO_Server_Connection_Handler>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
+#if defined (TAO_USES_STATIC_SERVICE) || defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP)
ACE_STATIC_SVC_DEFINE (TAO_Default_Server_Strategy_Factory,
- ASYS_TEXT ("Server_Strategy_Factory"),
+ ASYS_TEXT ("TAO_Default_Server_Strategy_Factory"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (TAO_Default_Server_Strategy_Factory),
ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
0)
+#endif /* TAO_USES_STATIC_SERVICE || TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */
+
ACE_FACTORY_DEFINE (TAO, TAO_Default_Server_Strategy_Factory)