1 #include "ClientInitializer.h"
2 #include "ClientInterceptor.h"
3 #include "MessengerC.h"
4 #include "orbsvcs/CosNamingC.h"
5 #include "ace/OS_NS_unistd.h"
8 ClientInitializer::ClientInitializer (void)
10 current_ (PortableInterceptor::Current::_nil())
15 ClientInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr
)
20 ClientInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info
)
22 // Find the Naming Service
23 CORBA::Object_var naming_obj
=
24 info
->resolve_initial_references("NameService");
25 CosNaming::NamingContext_var root
=
26 CosNaming::NamingContext::_narrow(naming_obj
.in());
27 if( CORBA::is_nil(root
.in())) {
28 std::cerr
<< "Nil Naming Context reference" << std::endl
;
32 // Resolve the Messenger object
35 name
[0].id
= CORBA::string_dup( "Messenger" );
36 CORBA::Object_var obj
= CORBA::Object::_nil();
37 while ( CORBA::is_nil( obj
.in() ) ) {
39 obj
= root
->resolve( name
);
40 } catch (const CosNaming::NamingContext::NotFound
&) {
41 // Sleep for a second and try again
46 Messenger_var messenger
= Messenger::_narrow( obj
.in() );
47 if( CORBA::is_nil( messenger
.in() ) ) {
48 std::cerr
<< "Not a Messenger reference" << std::endl
;
53 slot_
= info
->allocate_slot_id();
56 CORBA::Object_var current_obj
= info
->resolve_initial_references("PICurrent");
59 PortableInterceptor::Current::_narrow(current_obj
.in());
61 // Create and register the request interceptors.
62 PortableInterceptor::ClientRequestInterceptor_var ci
=
63 new ClientInterceptor(messenger
, current_
.in(), slot_
);
64 info
->add_client_request_interceptor (ci
.in());
68 ClientInitializer::set_slot_data (void)
70 // Set the recursion flag
73 flag
<<= CORBA::Any::from_boolean(x
);
74 current_
->set_slot(slot_
, flag
);
76 // Now that we're done with the PICurrent, we will release
77 // our reference to it.
78 current_
= PortableInterceptor::Current::_nil();