Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / orbsvcs / examples / ImR / Combined_Service / combined.cpp
blob147fb42f0e8559455207de3e10d7264f0e2a6e00
1 // This is a simple example, showing how you can load an
2 // ImR Locator and/or Activator as ACE Service Objects
3 // using the ACE Service Configurator framework.
5 #include "service_configS.h"
7 #include "ace/Service_Config.h"
8 #include "ace/streams.h"
9 #include "ace/OS_NS_string.h"
12 using namespace CORBA;
13 using namespace PortableServer;
15 class SvcConf
16 : public POA_ServiceConfigurator
18 ACE_Service_Config& asc_;
19 public:
20 SvcConf(ACE_Service_Config& asc)
21 : asc_(asc)
24 virtual CORBA::Long process_directive(const char* s)
26 ACE_ASSERT(s != 0);
27 ACE_ASSERT(ACE_OS::strlen(s) > 0);
28 return asc_.process_directive(ACE_TEXT_CHAR_TO_TCHAR(s));
31 virtual void reconfigure()
33 asc_.reconfigure();
37 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
39 try {
40 ACE_Service_Config config;
41 config.open (argc, argv);
43 ORB_var orb = ORB_init (argc, argv);
45 Object_var obj = orb->resolve_initial_references("RootPOA");
46 POA_var poa = POA::_narrow(obj.in());
47 ACE_ASSERT(! is_nil(poa.in()));
48 POAManager_var poaman = poa->the_POAManager();
50 SvcConf svt(config);
52 ObjectId_var id = poa->activate_object(&svt);
53 obj = poa->id_to_reference(id.in());
54 ACE_ASSERT(! is_nil(obj.in()));
55 String_var ior = orb->object_to_string(obj.in());
57 poaman->activate();
60 ofstream out("combined.ior");
61 out << ior;
64 ACE_DEBUG((LM_DEBUG, "Combined service started.\n"));
66 orb->run();
68 ACE_DEBUG((LM_DEBUG, "Combined service shutdown.\n"));
70 poa->destroy(1, 1);
71 orb->destroy();
72 } catch (const CORBA::Exception& e) {
73 e._tao_print_exception ("Combined Service:");
75 return 0;