summaryrefslogtreecommitdiff
path: root/tests/POA/Loader/server.cpp
blob: 37603d1319b6a1dfc4a73a119a5e16341e2d0fd6 (plain)
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

//=============================================================================
/**
 *  @file     server.cpp
 *
 *  $Id$
 *
 *   Server application to test the Servant Activator and Servant Locator.
 *
 *
 *  @author  Kirthika Parameswaran <kirthika@cs.wustl.edu>
 */
//=============================================================================


#include "Server_Manager.h"

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      Server_i server;

      if (server.init (argc, argv) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          "Failure during Initialisation: init ()\n"),
                          -1);

      // This POA is used to test the Servant Activator interface and
      // hence has an RETAIN policy.
      PortableServer::POA_var first_poa =
        server.create_poa ("firstPOA", 1);

      if (first_poa.in () == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          "Failure during first POA creation: create_poa ()\n"),
                          -1);

      // This poa is used to test the Servant Activator interface and
      // hence has an NONRETAIN policy.
      PortableServer::POA_var second_poa =
        server.create_poa ("secondPOA", 0);

      if (second_poa.in () == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          "Failure during second POA creation: create_poa ()\n"),
                          -1);

      // The Servant Activator interface is created and initialised.
      if (server.create_activator (first_poa) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          "Failure during first Servant Activator creation: create_activator()\n"),
                          -1);

      // The Servant Locator interface is created and initialised.
      if (server.create_locator (second_poa) !=0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          "Failure during first Servant Locator creation: create_activator()\n"),
                          -1);

      // The server begins processing requests.
      if (server.run () != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          "Failure during request processing: run ()\n"),
                          -1);
    }
  catch (const ::CORBA::Exception &ex)
    {
      ex._tao_print_exception("Caught unexpected CORBA exception :");
    }
  return 0;
}