Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Portable_Interceptors / PICurrent / ServerORBInitializer.cpp
blob5e5cbda05e4ed51a6f999d654fe77b8217686d96
1 // -*- C++ -*-
2 #include "ServerORBInitializer.h"
3 #include "ServerRequestInterceptor.h"
4 #include "ClientRequestInterceptor2.h"
5 #include "tao/PI/ORBInitInfo.h"
6 #include "tao/ORB_Core.h"
8 PortableInterceptor::SlotId slot_id = 2093843221;
10 void
11 ServerORBInitializer::pre_init (
12 PortableInterceptor::ORBInitInfo_ptr /* info */
17 void
18 ServerORBInitializer::post_init (
19 PortableInterceptor::ORBInitInfo_ptr info)
21 CORBA::Object_var obj =
22 info->resolve_initial_references ("PICurrent");
24 PortableInterceptor::Current_var pi_current =
25 PortableInterceptor::Current::_narrow (obj.in ());
27 if (CORBA::is_nil (pi_current.in ()))
29 ACE_ERROR ((LM_ERROR,
30 "(%P|%t) ERROR: Could not resolve PICurrent object.\n"));
32 throw CORBA::INTERNAL ();
35 ::slot_id = info->allocate_slot_id ();
37 PortableInterceptor::ServerRequestInterceptor_ptr server_tmp;
38 ACE_NEW_THROW_EX (server_tmp,
39 ServerRequestInterceptor (::slot_id,
40 pi_current.in ()),
41 CORBA::NO_MEMORY (
42 CORBA::SystemException::_tao_minor_code (
43 TAO::VMCID,
44 ENOMEM),
45 CORBA::COMPLETED_NO));
47 PortableInterceptor::ServerRequestInterceptor_var server_interceptor =
48 server_tmp;
50 info->add_server_request_interceptor (server_interceptor.in ());
52 PortableInterceptor::ClientRequestInterceptor_ptr client_tmp;
53 ACE_NEW_THROW_EX (client_tmp,
54 ClientRequestInterceptor2 (::slot_id),
55 CORBA::NO_MEMORY (
56 CORBA::SystemException::_tao_minor_code (
57 TAO::VMCID,
58 ENOMEM),
59 CORBA::COMPLETED_NO));
61 PortableInterceptor::ClientRequestInterceptor_var client_interceptor =
62 client_tmp;
64 info->add_client_request_interceptor (client_interceptor.in ());
66 // Disable collocation -- TAO-specific!!!
68 // Collocation optimizations must be disabled since TAO doesn't
69 // implement interceptor support for THRU_POA collocated
70 // invocations yet, and we need to force a client request
71 // interceptor to be invoked in this server.
72 TAO_ORBInitInfo_var tao_info =
73 TAO_ORBInitInfo::_narrow (info);
75 tao_info->orb_core ()->optimize_collocation_objects (0);