Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / DevGuideExamples / PortableInterceptors / PICurrent / ClientInitializer.cpp
blobb8ee6b53248fb30f97032ae5f6e92adb26e9e1b0
1 #include "ClientInitializer.h"
2 #include "ClientInterceptor.h"
3 #include "MessengerC.h"
4 #include <iostream>
6 ClientInitializer::ClientInitializer (void)
7 : slot_ (0),
8 current_ (PortableInterceptor::Current::_nil())
12 void
13 ClientInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr)
17 void
18 ClientInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info)
20 // resolve Messenger object
21 CORBA::Object_var obj = info->resolve_initial_references( "Messenger" );
22 Messenger_var messenger = Messenger::_narrow( obj.in() );
23 if( CORBA::is_nil( messenger.in() ) ) {
24 std::cerr << "Not a Messenger reference" << std::endl;
25 ACE_ASSERT(false);
28 // allocate slot
29 slot_ = info->allocate_slot_id();
31 // get PICurrent
32 CORBA::Object_var current_obj = info->resolve_initial_references("PICurrent");
34 current_ =
35 PortableInterceptor::Current::_narrow(current_obj.in());
37 // Create and register the request interceptors.
38 PortableInterceptor::ClientRequestInterceptor_var ci =
39 new ClientInterceptor(messenger, current_.in(), slot_);
40 info->add_client_request_interceptor (ci.in());
43 void
44 ClientInitializer::set_slot_data (void)
46 // Set the recursion flag
47 CORBA::Any flag;
48 CORBA::Boolean x = false;
49 flag <<= CORBA::Any::from_boolean(x);
50 current_->set_slot(slot_, flag);
52 // Now that we're done with the PICurrent, we will release
53 // our reference to it.
54 current_ = PortableInterceptor::Current::_nil();