Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / ForwardRequest / Client_ORBInitializer.cpp
blob36ee9800e6357f11da7834aeb378795f462f49fb
1 // -*- C++ -*-
2 #include "Client_ORBInitializer.h"
4 #if TAO_HAS_INTERCEPTORS == 1
6 #include "Client_Request_Interceptor.h"
8 #include "tao/StringSeqC.h"
9 #include "tao/ORB_Constants.h"
10 #include "ace/OS_NS_string.h"
12 void
13 Client_ORBInitializer::pre_init (
14 PortableInterceptor::ORBInitInfo_ptr)
18 void
19 Client_ORBInitializer::post_init (
20 PortableInterceptor::ORBInitInfo_ptr info)
22 CORBA::String_var orb_id = info->orb_id ();
24 CORBA::StringSeq_var args = info->arguments ();
26 CORBA::String_var forward_str;
28 // Extract the last forward reference from the argument list.
29 CORBA::ULong args_len = args->length ();
30 for (CORBA::ULong i = 0; i < args_len; ++i)
31 if (ACE_OS::strcmp ("-k", args[i]) == 0
32 && i < (args_len - 1))
33 forward_str = args[i + 1];
35 PortableInterceptor::ClientRequestInterceptor_ptr interceptor =
36 PortableInterceptor::ClientRequestInterceptor::_nil ();
38 // Install the client request interceptor.
39 ACE_NEW_THROW_EX (interceptor,
40 Client_Request_Interceptor (orb_id.in (),
41 forward_str.in ()),
42 CORBA::NO_MEMORY (
43 CORBA::SystemException::_tao_minor_code (
44 TAO::VMCID,
45 ENOMEM),
46 CORBA::COMPLETED_NO));
48 PortableInterceptor::ClientRequestInterceptor_var
49 client_interceptor = interceptor;
51 info->add_client_request_interceptor (client_interceptor.in ());
54 #endif /* TAO_HAS_INTERCEPTORS == 1 */