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
|
// $Id$
// ============================================================================
//
// = LIBRARY
// tests
//
// = DESCRIPTION
// This program tests both the ACE_Framework_Compondent and ACE_Repository.
// Since Framework Components are singletons that can live in dlls loaded
// via the Service Configurator framework, this test uses that framework
// to load services from a dll that has a singleton based on ACE_DLL_Singleton.
// When the dll is finally ready to be unloaded, the singleton will be
// automatically cleaned up just-in-time.//
//
// = AUTHOR
// Don Hinton <dhinton@ieee.org>
//
// ============================================================================
#include "Framework_Component_DLL.h"
#include "ace/Service_Config.h"
#include "ace/ARGV.h"
#include "tests/test_config.h"
ACE_RCSID(tests, Framework_Component_Test, "$Id$")
int
ACE_TMAIN (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT("Framework_Component_Test"));
// Now, let the ACE Service Configurator framework load our service from a
// dll, which contains a singleton.
ACE_ARGV args;
args.add (ACE_TEXT ("Framework_Component_Test"));
args.add (ACE_TEXT ("-n"));
args.add (ACE_TEXT ("-d"));
//args.add (ACE_TEXT ("-f"));
//args.add (ACE_TEXT ("Framework_Component_Test.conf"));
args.add (ACE_TEXT ("-S"));
args.add (ACE_TEXT ("\"dynamic Server_1 Service_Object * "
"Framework_Component_DLL:_make_Server_1() 'xxx' \""));
// Load it, should load a dll.
ACE_Service_Config::open (args.argc (), args.argv ());
// Now that the dll has been loaded, the singleton is available.
Simple_Service *ss = SS_SINGLETON::instance ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Simple_Service lives in library: %s\n"),
ss->dll_name ()));
// Now load another service from the same library.
ACE_Service_Config::process_directive
(ACE_TEXT ("dynamic Server_2 Service_Object * "
"Framework_Component_DLL:_make_Server_2() 'xxx' "));
// And unload the first one, should *not* unload the dll.
ACE_Service_Config::process_directive (ACE_TEXT ("remove Server_1"));
// Make sure our singlton is still happy..
// This will blow up now that simple service is deleted when the first
// ACE_DLL is destoyed--that's why we need to ref count the dlls ourselves
//ACE_DEBUG ((LM_DEBUG,
// ACE_TEXT ("Simple_Service is still alive in library: %s\n"),
// ss->dll_name ()));
ACE_Service_Config::close ();
ACE_END_TEST;
return 0;
}
|