1 // ============================================================================
7 // This test exercises ACE_Service_Config assembling a stream.
10 // Steve Huston <shuston@riverace.com>
12 // ============================================================================
14 #include "test_config.h"
15 #include "ace/Log_Msg.h"
16 #include "ace/Module.h"
17 #include "ace/Service_Config.h"
21 * The Decrypter service is static and is configured into a stream
24 * NOTE! This code is here, and it will trip up while being loaded. If
25 * "static Decrypter" is inserted into the .conf file's module list, this
26 * test will barf. This is arguably a weird test, but I don't know any
27 * reason it should not work; however, this behavior has never been tested
28 * and may not have ever worked... but if someone is feeling ambitious,
29 * please go ahead and make this work. I'm out of time and energy.
32 class Static_Task
: public ACE_Task
<ACE_SYNCH
>
35 int open (void *) override
38 ACE_TEXT ("opening %s\n"),
39 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
43 int close (u_long
) override
46 ACE_TEXT ("closing %s\n"),
47 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
51 int init (int, ACE_TCHAR
*[]) override
54 ACE_TEXT ("initializing %s\n"),
55 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
62 ACE_TEXT ("finalizing %s\n"),
63 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
68 class Decrypter
: public ACE_Service_Object
, public ACE_Module
<ACE_SYNCH
, ACE_System_Time_Policy
>
72 : ACE_Module
<ACE_SYNCH
, ACE_System_Time_Policy
> (
73 ACE_TEXT ("Decrypter"),
76 M_DELETE_NONE
) // Tasks are members; don't delete
79 ACE_ALLOC_HOOK_DECLARE
;
86 ACE_FACTORY_DEFINE (ACE_Local_Service
, Decrypter
)
87 ACE_STATIC_SVC_DEFINE (Decrypter_Descriptor
,
88 ACE_TEXT ("Decrypter"),
90 &ACE_SVC_NAME (Decrypter
),
91 (ACE_Service_Type::DELETE_THIS
|
92 ACE_Service_Type::DELETE_OBJ
),
94 ACE_STATIC_SVC_REQUIRE (Decrypter_Descriptor
)
96 ACE_ALLOC_HOOK_DEFINE(Decrypter
);
99 run_main (int, ACE_TCHAR
*argv
[])
101 ACE_START_TEST (ACE_TEXT ("Service_Config_Stream_Test"));
103 ACE_STATIC_SVC_REGISTER (Decrypter
);
105 // If you want to try the static module in the stream test (comments at
106 // the top of this file) it needs the -y in the argv list which enables
107 // static services. Otherwise it's not really needed. Same with the
108 // 'false' 4th arg to open() below - it allows static services.
109 ACE_TCHAR
*_argv
[5] = { argv
[0],
110 const_cast<ACE_TCHAR
*> (ACE_TEXT ("-d")),
111 const_cast<ACE_TCHAR
*> (ACE_TEXT ("-y")),
112 const_cast<ACE_TCHAR
*> (ACE_TEXT ("-f")),
113 const_cast<ACE_TCHAR
*>
114 (ACE_TEXT ("Service_Config_Stream_Test.conf")) };
116 if ((status
= ACE_Service_Config::open (5,
118 ACE_DEFAULT_LOGGER_KEY
,
120 true /*ignore def svc.conf*/)) == -1)
121 ACE_ERROR ((LM_ERROR
,