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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// $Id$
//========================================================================
//
// = LIBRARY
// TAO/tests/BiDir_Multiple_ORB
//
// = FILENAME
// destroy.cpp
//
// = DESCRIPTION
// Modified ORB destruction test.
//
// = AUTHOR
// Andrew Schnable <Andrew.Schnable@veritas.com>
// Iliyan Jeliazkov <jeliazkov_i@ociweb.com>
//
//=========================================================================
#include "tao/corba.h"
#include "tao/PortableServer/PortableServer.h"
#include "tao/AnyTypeCode/Any.h"
#include "tao/BiDir_GIOP/BiDirGIOP.h"
ACE_RCSID(BiDir_Multiple_ORB, destroy, "$Id$")
int
test_with_bidir_poa (int argc,
char **argv,
const char *orb_name,
int destroy_orb)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv, orb_name ACE_ENV_ARG_PARAMETER);
CORBA::Object_var obj =
orb->resolve_initial_references ("RootPOA"
ACE_ENV_ARG_PARAMETER);
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
CORBA::PolicyList policies (1);
policies.length (1);
CORBA::Any pol;
pol <<= BiDirPolicy::BOTH;
policies[0] =
orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE,
pol
ACE_ENV_ARG_PARAMETER);
// Create POA as child of RootPOA with the above policies. This POA
// will receive request in the same connection in which it sent
// the request
PortableServer::POA_var child_poa =
root_poa->create_POA ("childPOA",
poa_manager.in (),
policies
ACE_ENV_ARG_PARAMETER);
// Creation of childPOA is over. Destroy the Policy objects.
for (CORBA::ULong i = 0;
i < policies.length ();
++i)
{
policies[i]->destroy ();
}
poa_manager->activate ();
root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER);
if (destroy_orb)
{
orb->destroy ();
}
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
"Exception raised");
}
ACE_ENDTRY;
return 0;
}
int
main (int argc, char **argv)
{
int result = 0;
for (int i=0; i<10; i++)
{
result = test_with_bidir_poa (argc, argv, "poa_1", 1);
ACE_ASSERT (result == 0);
result = test_with_bidir_poa (argc, argv, "poa_2", 1);
ACE_ASSERT (result == 0);
}
ACE_DEBUG ((LM_DEBUG, "Completed OK\n"));
return result;
}
|