2 //=============================================================================
6 * Test server for the CosPropertyService
8 * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
10 //=============================================================================
19 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
23 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
25 CORBA::Object_var poa_object
= orb
->resolve_initial_references("RootPOA");
27 PortableServer::POA_var root_poa
=
28 PortableServer::POA::_narrow (poa_object
.in ());
30 if (CORBA::is_nil (root_poa
.in ()))
31 ACE_ERROR_RETURN ((LM_ERROR
,
32 " (%P|%t) Panic: nil RootPOA\n"),
35 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
37 // Using naming server.
38 TAO_Naming_Client my_name_client
;
39 if (my_name_client
.init (orb
.in ()) < 0)
42 // Create PropertySetDef object and register.
43 TAO_PropertySetDef
*propsetdef_impl
= 0;
44 ACE_NEW_RETURN (propsetdef_impl
,
47 CosPropertyService::PropertySetDef_var propsetdef
=
48 propsetdef_impl
->_this ();
50 CosNaming::Name
propsetdef_name (1);
51 propsetdef_name
.length (1);
52 propsetdef_name
[0].id
= CORBA::string_dup ("PropertySetDef");
53 my_name_client
->bind (propsetdef_name
,
57 // Make this IOR as one of the properties in there.
58 any_val
<<= propsetdef
.in ();
60 CORBA::Object_var ior
= CosPropertyService::PropertySetDef::_duplicate (propsetdef
.in());
61 CORBA::Object_ptr ior_ptr
= ior
.in ();
64 propsetdef_impl
->define_property_with_mode ("PropertySetDef_IOR",
66 CosPropertyService::fixed_readonly
);
68 // Create PropertySet factory and then register.
69 TAO_PropertySetFactory
*propset_factory_impl
;
70 ACE_NEW_RETURN (propset_factory_impl
,
71 TAO_PropertySetFactory
,
73 CosPropertyService::PropertySetFactory_var propset_factory
=
74 propset_factory_impl
->_this ();
76 CosNaming::Name
propset_factory_name (1);
77 propset_factory_name
.length (1);
78 propset_factory_name
[0].id
= CORBA::string_dup ("PropertySetFactory");
79 my_name_client
->bind (propset_factory_name
,
80 propset_factory
.in ());
82 poa_manager
->activate ();
84 // Run the ORB Event loop.
87 root_poa
->destroy (true, true);
91 catch (const CORBA::SystemException
& sysex
)
93 sysex
._tao_print_exception ("System Exception");
96 catch (const CORBA::UserException
& userex
)
98 userex
._tao_print_exception ("User Exception");
101 ACE_DEBUG ((LM_DEBUG
,
102 "\nServer is terminating"));