1 #include "tao/ORB_Core.h"
2 #include "tao/PortableServer/PortableServer.h"
7 class Foo_i
: public virtual POA_foo
12 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) checking\n"));
16 int vc_check(foo_ptr ff
, bool active
=true)
20 CORBA::PolicyList_var policies
;
21 CORBA::Boolean rv
=ff
->_validate_connection (policies
.out());
24 ACE_ERROR_RETURN ((LM_ERROR
,
25 " (%P|%t) got false from _validate_connection\n"),
29 catch (const CORBA::INV_POLICY
&)
32 ACE_ERROR_RETURN ((LM_ERROR
,
33 " (%P|%t) unexpect inlaid policies\n"),
36 catch (const CORBA::OBJECT_NOT_EXIST
&)
39 ACE_ERROR_RETURN ((LM_ERROR
,
40 " (%P|%t) unexpect object not exists\n"),
43 catch (const CORBA::Exception
&)
45 ACE_ERROR_RETURN ((LM_ERROR
,
46 " (%P|%t) unexpect exception\n"),
53 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
58 orb
= CORBA::ORB_init (argc
, argv
);
60 CORBA::Object_var root_poa_o
=
61 orb
->resolve_initial_references ("RootPOA");
63 PortableServer::POA_var rootPOA
=
64 PortableServer::POA::_narrow (root_poa_o
.in ());
66 if (CORBA::is_nil (rootPOA
.in ()))
68 ACE_ERROR_RETURN ((LM_ERROR
,
69 " (%P|%t) Panic: nil RootPOA\n"), 1);
72 PortableServer::POAManager_var poaMgr
= rootPOA
->the_POAManager ();
76 CORBA::PolicyList policies
;
78 policies
[0] = rootPOA
->create_id_assignment_policy (
79 PortableServer::SYSTEM_ID
);
80 policies
[1] = rootPOA
->create_implicit_activation_policy (
81 PortableServer::NO_IMPLICIT_ACTIVATION
);
82 policies
[2] = rootPOA
->create_lifespan_policy (
83 PortableServer::TRANSIENT
);
85 PortableServer::POA_var fooPoa
= rootPOA
->create_POA (
86 "FOO_POA", poaMgr
.in (), policies
);
88 for (CORBA::ULong i
= 0; i
< policies
.length (); ++i
)
90 policies
[i
]->destroy ();
94 PortableServer::ObjectId_var oid
= fooPoa
->activate_object( &servant
);
96 CORBA::Object_var obj
= fooPoa
->id_to_reference (oid
.in ());
98 foo_var client
= foo::_narrow (obj
.in());
102 if (vc_check(client
.in()))
108 fooPoa
->deactivate_object (oid
.in () ); //servant is gone
110 if (vc_check(client
.in(), false)) //exception expected