1 // author : Boris Kolpackov <boris@kolpackov.net>
3 #include "tao/LocalObject.h"
4 #include "tao/ORBInitializer_Registry.h"
6 PortableInterceptor::SlotId slot_id
;
8 class ORB_Initializer
: public virtual PortableInterceptor::ORBInitializer
,
9 public virtual ::CORBA::LocalObject
13 pre_init (PortableInterceptor::ORBInitInfo_ptr
)
18 post_init (PortableInterceptor::ORBInitInfo_ptr info
)
20 slot_id
= info
->allocate_slot_id ();
21 ACE_DEBUG ((LM_DEBUG
, "Allocated slot with id %d.\n", slot_id
));
26 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
30 PortableInterceptor::ORBInitializer_var orb_initializer
= new ORB_Initializer ();
31 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
33 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
35 CORBA::Object_var pic_obj
= orb
->resolve_initial_references ("PICurrent");
36 PortableInterceptor::Current_var
pic (
37 PortableInterceptor::Current::_narrow (pic_obj
.in ()));
40 in
<<= CORBA::ULong (1);
41 pic
->set_slot (slot_id
, in
);
44 CORBA::Any_var out
= pic
->get_slot (slot_id
);
49 ACE_ERROR ((LM_ERROR
, "ERROR: Slot value was not preserved.\n"));
55 catch (PortableInterceptor::InvalidSlot
const&)
57 ACE_ERROR ((LM_ERROR
, "ERROR: Caught InvalidSlot exception.\n"));
60 catch (const CORBA::Exception
& ex
)
62 ex
._tao_print_exception ("Exception caught:");