2 #include "Stock_Factory_Locator_i.h"
3 #include "ace/streams.h"
5 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
8 // First initialize the ORB, that will remove some arguments...
10 CORBA::ORB_init (argc
, argv
);
11 CORBA::Object_var poa_object
=
12 orb
->resolve_initial_references ("RootPOA");
13 PortableServer::POA_var poa
=
14 PortableServer::POA::_narrow (poa_object
.in ());
15 PortableServer::POAManager_var poa_manager
=
16 poa
->the_POAManager ();
17 poa_manager
->activate ();
19 CORBA::PolicyList
policies (3);
25 poa
->create_id_assignment_policy (PortableServer::USER_ID
);
28 poa
->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER
);
31 poa
->create_servant_retention_policy (PortableServer::NON_RETAIN
);
33 // Create the POA with these policies
34 PortableServer::POA_var child_poa
=
35 poa
->create_POA ("childPOA",
39 // Destroy the policy objects
40 for (CORBA::ULong i
= 0; i
!= policies
.length (); ++i
) {
41 policies
[i
]->destroy ();
44 // Create a Stock_Factory_Locator
45 PortableServer::ServantLocator_var servant_locator
=
46 new Quoter_Stock_Factory_Locator_i (orb
.in ());
48 // Set the SM with the childPOA
49 child_poa
->set_servant_manager (servant_locator
.in ());
51 PortableServer::ObjectId_var child_oid
=
52 PortableServer::string_to_ObjectId ("childFoo");
54 CORBA::Object_var stock_factory
=
55 child_poa
->create_reference_with_id (child_oid
.in (),
56 "IDL:Quoter/Stock_Factory:1.0");
59 // Put the object reference as an IOR string
60 CORBA::String_var ior
= orb
->object_to_string (stock_factory
.in ());
63 cout
<< ior
.in () << endl
;
67 // Destroy the POA, waiting until the destruction terminates
71 catch (const CORBA::Exception
&) {
72 cerr
<< "CORBA exception raised!" << endl
;