Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Monitor / Marshal_Buffer / server.cpp
blob21d5cf6125c109921c82fe056d1260a39f1162fc
1 #include "test_i.h"
2 #include "ace/OS_NS_stdio.h"
3 #include "ace/CORBA_macros.h"
5 const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior");
7 int
8 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
10 try
12 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
14 CORBA::Object_var poa_object =
15 orb->resolve_initial_references ("RootPOA");
17 if (CORBA::is_nil (poa_object.in ()))
19 ACE_ERROR_RETURN ((LM_ERROR,
20 " (%P|%t) Unable to initialize the POA.\n"),
21 1);
24 PortableServer::POA_var root_poa =
25 PortableServer::POA::_narrow (poa_object.in ());
27 PortableServer::POAManager_var poa_manager =
28 root_poa->the_POAManager ();
30 test_impl svnt;
31 test_var server = svnt._this ();
33 CORBA::String_var ior =
34 orb->object_to_string (server.in ());
36 FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
38 if (output_file == 0)
40 ACE_ERROR_RETURN ((LM_ERROR,
41 "Can't open output file for writing IOR: %s",
42 ior_output_file),
43 1);
46 ACE_OS::fprintf (output_file,
47 "%s",
48 ior.in ());
49 ACE_OS::fclose (output_file);
51 poa_manager->activate ();
52 orb->run ();
54 /// Destroy the POA, waiting until the destruction terminates,
55 /// then the ORB.
56 root_poa->destroy (true, true);
57 orb->destroy ();
59 catch (const CORBA::Exception &ex)
61 ex._tao_print_exception ("Server: exception caught:");
62 return 1;
65 return 0;