2 #include "Service_Config_DLL.h"
3 #include "ace/Service_Config.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_string.h"
7 static ACE_THR_FUNC_RETURN
8 invoke_service_config (void *arg
)
10 const ACE_TCHAR
*directive
= reinterpret_cast<const ACE_TCHAR
*> (arg
);
13 // Process a Service Configurator directive in the current thread.
14 if (ACE_Service_Config::process_directive (directive
) != 0)
16 ACE_TEXT ("(%P|%t) Service_Config_DLL::svc() - ")
17 ACE_TEXT ("process_directive() failed for:\n")
18 ACE_TEXT ("\"%s\"\n"),
24 Service_Config_DLL::Service_Config_DLL ()
26 ACE_OS::memset (this->directive_
[0], 0, BUFSIZ
* sizeof (ACE_TCHAR
));
27 ACE_OS::memset (this->directive_
[1], 0, BUFSIZ
* sizeof (ACE_TCHAR
));
31 Service_Config_DLL::init (int argc
, ACE_TCHAR
*argv
[])
36 ACE_TEXT ("Loading Test_Object_%s and Test_Object_%s\n"),
40 ACE_OS::sprintf (this->directive_
[0],
41 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
42 ACE_TEXT ("dynamic Test_Object_%s Service_Object * Service_Config_Dependent_DLL:_make_Service_Config_DLL() \"Test_Object_%s\""),
44 ACE_TEXT ("<?xml version='1.0'?> <dynamic id='Test_Object_%s' type='service_object'> <initializer init='_make_Service_Config_DLL' path='Service_Config_Dependent_DLL' params='Test_Object_%s'/> </dynamic>"),
49 ACE_OS::sprintf (this->directive_
[1],
50 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
51 ACE_TEXT ("dynamic Test_Object_%s Service_Object * Service_Config_Dependent_DLL:_make_Service_Config_DLL() \"Test_Object_%s\""),
53 ACE_TEXT ("<?xml version='1.0'?> <dynamic id='Test_Object_%s' type='service_object'> <initializer init='_make_Service_Config_DLL' path='Service_Config_Dependent_DLL' params='Test_Object_%s'/> </dynamic>"),
59 if (ACE_Service_Config::process_directive (this->directive_
[0]) != 0)
61 ACE_TEXT ("(%P|%t) Service_Config_DLL::init() - ")
62 ACE_TEXT ("process_directive() failed for:\n")
63 ACE_TEXT ("\"%s\"\n"),
64 this->directive_
[0]));
66 #if defined (ACE_HAS_THREADS)
68 // Become an Active Object if more than one argument passed.
69 // Two arguments indicate two "test objects" to be dynamically
71 return this->activate ();
73 #endif /* ACE_HAS_THREADS */
79 ACE_TEXT ("Service_Config_DLL::init () - %s\n"),
84 ACE_ERROR_RETURN ((LM_ERROR
,
85 ACE_TEXT ("(%P|%t) Incorrect number of arguments ")
86 ACE_TEXT ("(%d) passed to Service_Config_DLL::init ()"),
95 Service_Config_DLL::fini ()
101 Service_Config_DLL::svc ()
103 if (ACE_Thread_Manager::instance ()->spawn (invoke_service_config
,
104 this->directive_
[1]) == -1)
105 ACE_ERROR_RETURN ((LM_ERROR
,
106 ACE_TEXT ("(%P|%t) Unable to spawn thread to ")
107 ACE_TEXT ("invoke Service Configurator.\n")),
113 // The same class (Service_Config_DLL) is used to implement each of the
114 // Service Objects whose service descriptors are defined below.
116 // -----------------------------------------------------------------
118 ACE_STATIC_SVC_DEFINE (Test_Object_1
,
119 ACE_TEXT ("Test_Object_1"),
121 &ACE_SVC_NAME (Service_Config_DLL
),
122 ACE_Service_Type::DELETE_THIS
123 | ACE_Service_Type::DELETE_OBJ
,
126 // -----------------------------------------------------------------
128 ACE_STATIC_SVC_DEFINE (Test_Object_2
,
129 ACE_TEXT ("Test_Object_2"),
131 &ACE_SVC_NAME (Service_Config_DLL
),
132 ACE_Service_Type::DELETE_THIS
133 | ACE_Service_Type::DELETE_OBJ
,
136 // -----------------------------------------------------------------
138 ACE_STATIC_SVC_DEFINE (Test_Object_3
,
139 ACE_TEXT ("Test_Object_3"),
141 &ACE_SVC_NAME (Service_Config_DLL
),
142 ACE_Service_Type::DELETE_THIS
143 | ACE_Service_Type::DELETE_OBJ
,
146 // -----------------------------------------------------------------
148 ACE_STATIC_SVC_DEFINE (Test_Object_4
,
149 ACE_TEXT ("Test_Object_4"),
151 &ACE_SVC_NAME (Service_Config_DLL
),
152 ACE_Service_Type::DELETE_THIS
153 | ACE_Service_Type::DELETE_OBJ
,
156 // -----------------------------------------------------------------
158 ACE_STATIC_SVC_DEFINE (Test_Object_5
,
159 ACE_TEXT ("Test_Object_5"),
161 &ACE_SVC_NAME (Service_Config_DLL
),
162 ACE_Service_Type::DELETE_THIS
163 | ACE_Service_Type::DELETE_OBJ
,
166 // -----------------------------------------------------------------
168 ACE_STATIC_SVC_DEFINE (Test_Object_6
,
169 ACE_TEXT ("Test_Object_6"),
171 &ACE_SVC_NAME (Service_Config_DLL
),
172 ACE_Service_Type::DELETE_THIS
173 | ACE_Service_Type::DELETE_OBJ
,
176 // -----------------------------------------------------------------
178 ACE_STATIC_SVC_DEFINE (Final_Object
,
179 ACE_TEXT ("Final_Object"),
181 &ACE_SVC_NAME (Service_Config_DLL
),
182 ACE_Service_Type::DELETE_THIS
183 | ACE_Service_Type::DELETE_OBJ
,
186 // -----------------------------------------------------------------
188 // Same factory is used for all service descriptors defined above.
189 ACE_FACTORY_DEFINE (Service_Config_DLL
, Service_Config_DLL
)