1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
// -*- C++ -*-
#include "Service_Config_DLL.h"
ACE_RCSID (tests,
Service_Config_DLL,
"$Id$")
static void *
invoke_service_config (void *arg)
{
const ACE_TCHAR *directive = ACE_reinterpret_cast (const ACE_TCHAR *,
arg);
// Process a Service Configurator directive in the current thread.
if (ACE_Service_Config::process_directive (directive) != 0)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) Service_Config_DLL::svc() - ")
ACE_TEXT ("process_directive() failed for:\n")
ACE_TEXT ("\"%s\"\n"),
directive));
return 0;
}
Service_Config_DLL::Service_Config_DLL (void)
{
ACE_OS::memset (this->directive_[0], 0, BUFSIZ * sizeof (ACE_TCHAR));
ACE_OS::memset (this->directive_[1], 0, BUFSIZ * sizeof (ACE_TCHAR));
}
int
Service_Config_DLL::init (int argc, ACE_TCHAR *argv[])
{
if (argc == 2)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Loading Test_Object_%s and Test_Object_%s\n"),
argv[0],
argv[1]));
ACE_OS::sprintf (this->directive_[0],
ACE_TEXT ("dynamic Test_Object_%s Service_Object * Service_Config_DLL:_make_Service_Config_DLL() \"Test_Object_%s\""),
argv[0],
argv[0]);
ACE_OS::sprintf (this->directive_[1],
ACE_TEXT ("dynamic Test_Object_%s Service_Object * Service_Config_DLL:_make_Service_Config_DLL() \"Test_Object_%s\""),
argv[1],
argv[1]);
if (ACE_Service_Config::process_directive (this->directive_[0]) != 0)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) Service_Config_DLL::init() - ")
ACE_TEXT ("process_directive() failed for:\n")
ACE_TEXT ("\"%s\"\n"),
this->directive_[0]));
#if defined (ACE_HAS_THREADS)
// Become an Active Object if more than one argument passed.
// Two arguments indicate two "test objects" to be dynamically
// loaded.
return this->activate ();
#endif /* ACE_HAS_THREADS */
}
else if (argc == 1)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Service_Config_DLL::init () - %s\n"),
argv[0]));
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) Incorrect number of arguments ")
ACE_TEXT ("(%d) passed to Service_Config_DLL::init ()"),
argc),
-1);
}
return 0;
}
int
Service_Config_DLL::fini (void)
{
return 0;
}
int
Service_Config_DLL::svc (void)
{
if (ACE_Thread_Manager::instance ()->spawn (invoke_service_config,
this->directive_[1]) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) Unable to spawn thread to ")
ACE_TEXT ("invoke Service Configurator.\n")),
-1);
return 0;
}
// The same class (Service_Config_DLL) is used to implement each of the
// Service Objects whose service descriptors are defined below.
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Test_Object_1,
ACE_TEXT ("Test_Object_1"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Test_Object_2,
ACE_TEXT ("Test_Object_2"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Test_Object_3,
ACE_TEXT ("Test_Object_3"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Test_Object_4,
ACE_TEXT ("Test_Object_4"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Test_Object_5,
ACE_TEXT ("Test_Object_5"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Test_Object_6,
ACE_TEXT ("Test_Object_6"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
ACE_STATIC_SVC_DEFINE (Final_Object,
ACE_TEXT ("Final_Object"),
ACE_SVC_OBJ_T,
&ACE_SVC_NAME (Service_Config_DLL),
ACE_Service_Type::DELETE_THIS
| ACE_Service_Type::DELETE_OBJ,
0)
// -----------------------------------------------------------------
// Same factory is used for all service descriptors defined above.
ACE_FACTORY_DEFINE (Service_Config_DLL, Service_Config_DLL)
|