summaryrefslogtreecommitdiff
path: root/trunk/TAO/orbsvcs/examples/LoadBalancing/ORBInitializer.cpp
blob: 1641db55b1e6789fe47e61f8733c6dd5ec8aa67d (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "ORBInitializer.h"
#include "ServerRequestInterceptor.h"

#include "orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.h"

#include "orbsvcs/CosLoadBalancingC.h"
#include "tao/ORB_Constants.h"


ACE_RCSID (LoadBalancing,
           ORBInitializer,
           "$Id$")


ORBInitializer::ORBInitializer (void)
  : load_alert_ (),
    interceptor_ (0)
{
}

void
ORBInitializer::pre_init (
    PortableInterceptor::ORBInitInfo_ptr)
{
}

void
ORBInitializer::post_init (
    PortableInterceptor::ORBInitInfo_ptr info)
{

  ACE_NEW_THROW_EX (this->interceptor_,
                    ServerRequestInterceptor,
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  PortableInterceptor::ServerRequestInterceptor_var sr_interceptor =
    this->interceptor_;

  info->add_server_request_interceptor (sr_interceptor.in ());

  PortableInterceptor::ServerRequestInterceptor_ptr reject_interceptor;
  ACE_NEW_THROW_EX (reject_interceptor,
                    TAO_LB_ServerRequestInterceptor (this->load_alert_),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  PortableInterceptor::ServerRequestInterceptor_var safe_reject_interceptor =
    reject_interceptor;

  info->add_server_request_interceptor (safe_reject_interceptor.in ());
}


TAO_LB_LoadAlert &
ORBInitializer::load_alert (void)
{
  return this->load_alert_;
}

ServerRequestInterceptor *
ORBInitializer::interceptor (void) const
{
  return this->interceptor_;
}