2 //=============================================================================
6 * This directory contains an example that illustrates how the ACE
7 * Service Configurator can configure static and dynamic services,
8 * both from the command-line and from a svc.config file.
10 * @author Doug Schmidt <d.schmidt@vanderbilt.edu>
12 //=============================================================================
15 #include "ace/OS_main.h"
16 #include "ace/Service_Config.h"
18 #include "ace/Log_Msg.h"
19 #include "Timer_Service.h"
22 // Create an object that will insert the <Timer_Service> into the list
23 // of statically linked services that the <ACE_Service_Config> will
24 // process at run-time.
25 ACE_STATIC_SVC_REQUIRE (Timer_Service_1
)
28 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
30 // Set up an argument vector that we can add entries to!
33 // Manufacture a "fake" svc.conf entry to demonstrate the -S option
34 // that allows us to pass these entries via the "command-line"
35 // rather than the svc.conf file.
37 for (int i
= 0; i
< argc
; i
++)
40 args
.add (ACE_TEXT ("-y"));
41 args
.add (ACE_TEXT ("-d"));
42 args
.add (ACE_TEXT ("-S"));
43 args
.add (ACE_TEXT ("\"static Timer_Service_1 'timer 1 10 $TRACE'\""));
44 args
.add (ACE_TEXT ("-S"));
45 args
.add (ACE_TEXT ("\"dynamic Timer_Service_2 Service_Object * Timer:_make_Timer_Service_2() 'timer 2 10 $TRACE'\""));
46 // Test the -f option!
47 args
.add (ACE_TEXT ("-f svc.conf1"));
48 args
.add (ACE_TEXT ("-f svc.conf2"));
51 ACE_TEXT ("argc = %d\n"),
54 // Print the contents of the combined <ACE_ARGV>.
55 for (int i
= 0; i
< args
.argc (); i
++)
57 ACE_TEXT ("(%d) %s\n"),
61 int const result
= ACE_Service_Config::open (args
.argc (),
63 ACE_DEFAULT_LOGGER_KEY
,
66 ACE_ERROR_RETURN ((LM_ERROR
,
71 // Run forever, performing the configured services until we
74 ACE_Reactor::run_event_loop ();