Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tests / Bug_3499_Regression / DLL_Service_Host.cpp
blobd1c4ae09bbac32a3cdb548c8d5801cc300ecd64b
1 #include "DLL_Service.h"
2 #include "ace/DLL.h"
3 #include "ace/Service_Gestalt.h"
4 #include "ace/Service_Config.h"
5 #include "ace/CORBA_macros.h"
6 #include "ace/OS_NS_unistd.h"
7 //
8 // main
9 //
10 int ACE_TMAIN (int argc, ACE_TCHAR * argv [])
12 try
14 ACE_DLL module;
16 ACE_Service_Gestalt * gestalt = 0;
17 ACE_NEW_NORETURN (gestalt, ACE_Service_Gestalt ());
18 if (gestalt == 0)
20 ACE_throw_bad_alloc;
23 ACE_Intrusive_Auto_Ptr <ACE_Service_Gestalt> auto_clean (gestalt);
25 // Without the following line, the application will crash while ACE
26 // is *cleaning* the ACE_Service_Config::global () object. We want
27 // to force all services to be loaded under this configuration.
28 ACE_Service_Config_Guard guard (gestalt);
30 if (module.open (ACE_TEXT ("Bug_3499_Regression_ACE_DLL_TAO_Service")) == -1)
32 ACE_ERROR_RETURN ((LM_ERROR,
33 ACE_TEXT ("failed to load ACE_DLL_TAO_Service\n")),
34 -1);
37 void * symbol = module.symbol (ACE_TEXT ("_make_ACE_DLL_TAO_Service"));
39 if (symbol == 0)
41 ACE_ERROR_RETURN ((LM_ERROR,
42 ACE_TEXT ("failed to load symbol _make_ACE_DLL_TAO_Service\n")),
43 -1);
46 typedef ACE_DLL_Service * (*factory_type) ();
47 ptrdiff_t tmp_ptr = reinterpret_cast <ptrdiff_t> (symbol);
48 factory_type f = reinterpret_cast <factory_type> (tmp_ptr);
50 ACE_DLL_Service * svc = (*f) ();
52 if (svc != 0)
54 // Initialize the service.
56 // If '-ORBGestalt CURRENT' does not appear in the command-line options,
57 // which is a fix for the bug in question, then the service will fail
58 // when trying to resolve to RootPOA.
59 ACE_DEBUG ((LM_DEBUG,
60 ACE_TEXT ("(%t) %T - %M - initializing the loaded service\n")));
61 svc->init (argc, argv);
63 // Sleep for a few seconds
64 ACE_DEBUG ((LM_DEBUG,
65 ACE_TEXT ("(%t) %T - %M - sleeping for 5 seconds\n")));
66 ACE_OS::sleep (5);
68 // Finalize the service.
69 ACE_DEBUG ((LM_DEBUG,
70 ACE_TEXT ("(%t) %T - %M - finalizing the service\n")));
71 svc->fini ();
73 // Destroy the service.
74 ACE_DEBUG ((LM_DEBUG,
75 ACE_TEXT ("(%t) %T - %M - destroying the service\n")));
76 svc->destroy ();
79 catch (...)
81 ACE_ERROR ((LM_ERROR,
82 ACE_TEXT ("(%t) %T - %M - caught unknown exception\n")));
85 return 0;