summaryrefslogtreecommitdiff
path: root/TAO/tao/CSD_Framework/CSD_POA.cpp
blob: a77bb5f32e9bec5dc364f0959d77edf44945fc6a (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// -*- C++ -*-
#include "tao/CSD_Framework/CSD_POA.h"
#include "tao/CSD_Framework/CSD_Strategy_Repository.h"
#include "tao/CSD_Framework/CSD_Strategy_Base.h"

#include "ace/Dynamic_Service.h"

#if !defined (__ACE_INLINE__)
# include "tao/CSD_Framework/CSD_POA.inl"
#endif /* ! __ACE_INLINE__ */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

// Implementation skeleton constructor
TAO_CSD_POA::TAO_CSD_POA (const String &name,
                          PortableServer::POAManager_ptr poa_manager,
                          const TAO_POA_Policy_Set &policies,
                          TAO_Root_POA *parent,
                          ACE_Lock &lock,
                          TAO_SYNCH_MUTEX &thread_lock,
                          TAO_ORB_Core &orb_core,
                          TAO_Object_Adapter *object_adapter)
: TAO_Regular_POA (name,
                   poa_manager,
                   policies,
                   parent,
                   lock,
                   thread_lock,
                   orb_core,
                   object_adapter)
{
  ACE_NEW_THROW_EX (this->sds_proxy_,
                    TAO::CSD::Strategy_Proxy (),
                    CORBA::NO_MEMORY ());
}


// Implementation skeleton destructor
TAO_CSD_POA::~TAO_CSD_POA (void)
{
  delete this->sds_proxy_;
}

void TAO_CSD_POA::set_csd_strategy (::CSD_Framework::Strategy_ptr strategy)
{
  if (CORBA::is_nil (strategy))
    {
      throw ::CORBA::BAD_PARAM ();
    }
  this->sds_proxy_->custom_strategy (strategy);
}

TAO_Root_POA *
TAO_CSD_POA::new_POA (const String &name,
                      PortableServer::POAManager_ptr poa_manager,
                      const TAO_POA_Policy_Set &policies,
                      TAO_Root_POA *parent,
                      ACE_Lock &lock,
                      TAO_SYNCH_MUTEX &thread_lock,
                      TAO_ORB_Core &orb_core,
                      TAO_Object_Adapter *object_adapter)
{
  TAO_CSD_POA *poa = 0;

  ACE_NEW_THROW_EX (poa,
                    TAO_CSD_POA (name,
                             poa_manager,
                             policies,
                             parent,
                             lock,
                             thread_lock,
                             orb_core,
                             object_adapter
                            ),
                    CORBA::NO_MEMORY ());

  TAO_CSD_Strategy_Repository *repo =
    ACE_Dynamic_Service<TAO_CSD_Strategy_Repository>::instance ("TAO_CSD_Strategy_Repository");

  if (repo)
    {
      CSD_Framework::Strategy_var strategy = repo->find (name);

      if (! ::CORBA::is_nil (strategy.in ()))
        {
          poa->set_csd_strategy (strategy.in ());
        }
    }

  return poa;
}

void TAO_CSD_POA::poa_activated_hook ()
{
  this->sds_proxy_->poa_activated_event (this->orb_core_);
}

void TAO_CSD_POA::poa_deactivated_hook ()
{
  this->sds_proxy_->poa_deactivated_event ();
}

void TAO_CSD_POA::servant_activated_hook (PortableServer::Servant servant,
                                          const PortableServer::ObjectId& oid)
{
  this->sds_proxy_->servant_activated_event (servant, oid);
}

void TAO_CSD_POA::servant_deactivated_hook (PortableServer::Servant servant,
                                 const PortableServer::ObjectId& oid)
{
  this->sds_proxy_->servant_deactivated_event (servant, oid);
}

TAO_END_VERSIONED_NAMESPACE_DECL