summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/ORT/Server_IORInterceptor_ORBInitializer.cpp
blob: 42306c63e6781bf678f73c16052238221492818f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// $Id$

#include "Server_IORInterceptor_ORBInitializer.h"
#include "Server_IORInterceptor.h"
#include "tao/ORB_Constants.h"

#include "GatewayC.h"

ACE_RCSID (ORT,
           Server_IORInterceptor_ORBInitializer,
           "$Id: ")

void
Server_IORInterceptor_ORBInitializer::pre_init (
    PortableInterceptor::ORBInitInfo_ptr /* info */
    )
{
}

void
Server_IORInterceptor_ORBInitializer::post_init (
    PortableInterceptor::ORBInitInfo_ptr info)
{
  CORBA::Object_var obj =
    info->resolve_initial_references ("Gateway_Object_Factory");

  /// Narrow it down correctly.
  Gateway::Object_Factory_var gateway_object_factory =
    Gateway::Object_Factory::_narrow (obj.in ());

  /// Check for nil reference
  if (CORBA::is_nil (gateway_object_factory.in ()))
    ACE_ERROR ((LM_ERROR,
                "Unable to obtain reference to Gateway::Object_Factory "
                "object.\n"));

  PortableInterceptor::IORInterceptor_ptr gateway;
  ACE_NEW_THROW_EX (gateway,
                    Server_IORInterceptor (gateway_object_factory.in ()),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  PortableInterceptor::IORInterceptor_var ior_interceptor = gateway;

  info->add_ior_interceptor (ior_interceptor.in ());
}