summaryrefslogtreecommitdiff
path: root/TAO/tao/CSD_Framework/CSD_POA.cpp
blob: f3cc8e605f577c5d1210d08bf6225c927e36f169 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// $Id$

#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"

ACE_RCSID (CSD_Framework,
           CSD_POA,
           "$Id$")

#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
                   ACE_ENV_ARG_DECL)
: TAO_Regular_POA (name,
                   poa_manager,
                   policies,
                   parent,
                   lock,
                   thread_lock,
                   orb_core,
                   object_adapter
                   ACE_ENV_ARG_PARAMETER)
{
  ACE_NEW_THROW_EX (this->sds_proxy_,
                    TAO::CSD::Strategy_Proxy (),
                    CORBA::NO_MEMORY ());
  ACE_CHECK;
}


// 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
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((
    CORBA::SystemException
  ))
{
  if (CORBA::is_nil (strategy))
    {
      ACE_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
                      ACE_ENV_ARG_DECL)
{
  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
                             ACE_ENV_ARG_PARAMETER),
                    CORBA::NO_MEMORY ());
  ACE_CHECK_RETURN (0);

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


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

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

  return poa;
}

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

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
                               ACE_ENV_ARG_DECL)
{
  this->sds_proxy_->servant_activated_event (servant, oid ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
}

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

TAO_END_VERSIONED_NAMESPACE_DECL