2 #include "tao/Utils/ORB_Destroyer.h"
3 #include "tao/Utils/RIR_Narrow.h"
4 #include "tao/Utils/PolicyList_Destroyer.h"
6 PortableServer::POA_ptr
7 create_persistent_POA (PortableServer::POA_ptr parent
,
10 TAO::Utils::PolicyList_Destroyer
plist (3);
14 parent
->create_lifespan_policy (PortableServer::PERSISTENT
);
17 parent
->create_id_assignment_policy (PortableServer::USER_ID
);
20 parent
->create_implicit_activation_policy (
21 PortableServer::NO_IMPLICIT_ACTIVATION
);
23 PortableServer::POAManager_var mgr
=
24 parent
->the_POAManager ();
26 return parent
->create_POA (name
,
32 test_create_object_before_servant_reactivation (
34 PortableServer::POA_ptr root_poa
)
36 // Create a persistent POA and then create a reference in it...
37 PortableServer::POA_var persistent_poa
=
38 create_persistent_POA(root_poa
,
42 PortableServer::ObjectId_var oid
=
43 PortableServer::string_to_ObjectId ("TestServant");
45 char const * id
= _tc_Test
->id ();
47 CORBA::Object_var object
=
48 persistent_poa
->create_reference_with_id (
52 if (CORBA::is_nil (object
.in ()))
55 "(%P|%t) nil reference in create_reference_with_id\n"));
60 CORBA::String_var ior
=
61 orb
->object_to_string (object
.in ());
63 // Now destroy the POA...
64 persistent_poa
->destroy (true,
67 // Now create the POA again...
69 create_persistent_POA (root_poa
,
72 // And try to create the object again...
74 orb
->string_to_object (ior
.in ());
76 if(CORBA::is_nil (object
.in ()))
79 "(%P|%t) nil reference in string_to_object (servant reactivation)\n"));
83 persistent_poa
->destroy (true,
88 test_create_object_before_POA_reactivation(
90 PortableServer::POA_ptr root_poa
)
92 // Create a persistent POA and then create a reference in it...
93 PortableServer::POA_var persistent_poa
=
94 create_persistent_POA (root_poa
,
97 PortableServer::ObjectId_var oid
=
98 PortableServer::string_to_ObjectId ("TestServant");
100 char const * id
= _tc_Test
->id ();
102 CORBA::Object_var object
=
103 persistent_poa
->create_reference_with_id (oid
.in (),
106 if (CORBA::is_nil (object
.in ()))
108 ACE_DEBUG ((LM_DEBUG
,
109 "(%P|%t) nil reference in create_reference_with_id\n"));
113 CORBA::String_var ior
=
114 orb
->object_to_string (object
.in ());
116 // Now destroy the POA...
117 persistent_poa
->destroy (true,
120 // And try to create the object again...
121 object
= orb
->string_to_object (ior
.in ());
123 if (CORBA::is_nil (object
.in ()))
125 ACE_DEBUG ((LM_DEBUG
,
126 "(%P|%t) nil reference in string_to_object (POA reactivation)\n"));
131 persistent_poa
->destroy (true,
136 test_no_implicit_activation (
137 PortableServer::POA_ptr root_poa
)
139 // Create a persistent POA and then create a reference in it...
140 PortableServer::POA_var persistent_poa
=
141 create_persistent_POA (root_poa
,
144 Hello
myhello (persistent_poa
.in ());
146 bool succeed
= false;
149 // Implicit activation should fail
153 catch (const PortableServer::POA::WrongPolicy
& )
157 catch (const PortableServer::POA::ServantNotActive
& )
159 // This is now the case when looking at the corba spec, raised
160 // an issue 10522 about this
163 catch (const CORBA::Exception
&)
169 ACE_ERROR ((LM_ERROR
,
170 "(%t) ERROR, Implicit activation failed with invalid exception\n"));
173 // Now destroy the POA...
174 persistent_poa
->destroy (true,
179 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
184 CORBA::ORB_init (argc
,
187 TAO::Utils::ORB_Destroyer
orb_destroyer (orb
.in());
189 PortableServer::POA_var root_poa
=
190 TAO::Utils::RIR_Narrow
<PortableServer::POA
>::narrow (orb
.in (),
193 PortableServer::POAManager_var poa_manager
=
194 root_poa
->the_POAManager ();
196 poa_manager
->activate ();
198 test_create_object_before_POA_reactivation (orb
.in(),
201 test_create_object_before_servant_reactivation (orb
.in (),
204 test_no_implicit_activation (root_poa
.in ());
206 catch (const CORBA::Exception
& ex
)
208 ex
._tao_print_exception ("Caught a CORBA exception\n");