summaryrefslogtreecommitdiff
path: root/TAO/tao/PortableServer/Active_Policy_Strategies.cpp
blob: cbb9434cf714fa9d3a65a1d5eaeb32ecd0d5487b (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// -*- C++ -*-
#include "tao/PortableServer/Active_Policy_Strategies.h"
#include "tao/PortableServer/POA_Cached_Policies.h"

#include "tao/PortableServer/ThreadStrategy.h"
#include "tao/PortableServer/ThreadStrategyFactory.h"
#include "tao/PortableServer/RequestProcessingStrategy.h"
#include "tao/PortableServer/RequestProcessingStrategyFactory.h"
#include "tao/PortableServer/IdAssignmentStrategy.h"
#include "tao/PortableServer/IdAssignmentStrategyFactory.h"
#include "tao/PortableServer/LifespanStrategy.h"
#include "tao/PortableServer/LifespanStrategyFactory.h"
#include "tao/PortableServer/IdUniquenessStrategy.h"
#include "tao/PortableServer/IdUniquenessStrategyFactory.h"
#include "tao/PortableServer/ImplicitActivationStrategy.h"
#include "tao/PortableServer/ImplicitActivationStrategyFactory.h"
#include "tao/PortableServer/ServantRetentionStrategy.h"
#include "tao/PortableServer/ServantRetentionStrategyFactory.h"

#include "tao/PortableServer/IdAssignmentPolicyC.h"
#include "tao/PortableServer/IdUniquenessPolicyC.h"
#include "tao/PortableServer/ImplicitActivationPolicyC.h"
#include "tao/PortableServer/LifespanPolicyC.h"
#include "tao/PortableServer/RequestProcessingPolicyC.h"
#include "tao/PortableServer/ServantRetentionPolicyC.h"
#include "tao/PortableServer/ThreadPolicyC.h"
#include "tao/PortableServer/ServantRetentionPolicyC.h"

#include "ace/Dynamic_Service.h"

#if !defined (__ACE_INLINE__)
# include "tao/PortableServer/Active_Policy_Strategies.inl"
#endif /* __ACE_INLINE__ */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  namespace Portable_Server
  {
    Active_Policy_Strategies::Active_Policy_Strategies ()
      : thread_strategy_ (0),
        request_processing_strategy_ (0),
        id_assignment_strategy_ (0),
        lifespan_strategy_ (0),
        id_uniqueness_strategy_ (0),
        implicit_activation_strategy_ (0),
        servant_retention_strategy_ (0),
        thread_strategy_factory_ (0),
        servant_retention_strategy_factory_ (0),
        request_processing_strategy_factory_ (0),
        lifespan_strategy_factory_ (0),
        implicit_activation_strategy_factory_ (0),
        id_uniqueness_strategy_factory_ (0),
        id_assignment_strategy_factory_ (0)
    {
    }

    void
    Active_Policy_Strategies::update (Cached_Policies &policies,
                                      ::TAO_Root_POA *poa)
    {
      this->thread_strategy_factory_ =
        ACE_Dynamic_Service<ThreadStrategyFactory>::instance ("ThreadStrategyFactory");

      if (this->thread_strategy_factory_ != 0)
        this->thread_strategy_ =
          this->thread_strategy_factory_->create (policies.thread());

      /**/

      this->id_assignment_strategy_factory_ =
        ACE_Dynamic_Service<IdAssignmentStrategyFactory>::instance ("IdAssignmentStrategyFactory");

      if (this->id_assignment_strategy_factory_ != 0)
        this->id_assignment_strategy_ =
          this->id_assignment_strategy_factory_->create (policies.id_assignment());

      /**/

      this->id_uniqueness_strategy_factory_ =
        ACE_Dynamic_Service<IdUniquenessStrategyFactory>::instance ("IdUniquenessStrategyFactory");

      if (this->id_uniqueness_strategy_factory_ != 0)
        this->id_uniqueness_strategy_ =
          this->id_uniqueness_strategy_factory_->create (policies.id_uniqueness());

      /**/

      this->servant_retention_strategy_factory_ =
        ACE_Dynamic_Service<ServantRetentionStrategyFactory>::instance ("ServantRetentionStrategyFactory");

      if (this->servant_retention_strategy_factory_ != 0)
        this->servant_retention_strategy_ =
          this->servant_retention_strategy_factory_->create (policies.servant_retention());

      /**/

      this->request_processing_strategy_factory_ =
        ACE_Dynamic_Service<RequestProcessingStrategyFactory>::instance ("RequestProcessingStrategyFactory");

      if (this->request_processing_strategy_factory_ != 0)
        this->request_processing_strategy_ =
          this->request_processing_strategy_factory_->create (policies.request_processing(), policies.servant_retention());

      /**/

      this->lifespan_strategy_factory_ =
        ACE_Dynamic_Service<LifespanStrategyFactory>::instance ("LifespanStrategyFactory");

      if (this->lifespan_strategy_factory_ != 0)
        this->lifespan_strategy_ =
          this->lifespan_strategy_factory_->create (policies.lifespan());

      /**/

      this->implicit_activation_strategy_factory_ =
        ACE_Dynamic_Service<ImplicitActivationStrategyFactory>::instance ("ImplicitActivationStrategyFactory");

      if (this->implicit_activation_strategy_factory_ != 0)
        this->implicit_activation_strategy_ =
          this->implicit_activation_strategy_factory_->create (policies.implicit_activation());

      /**/

      if (this->lifespan_strategy_ != 0)
        {
          this->lifespan_strategy_->strategy_init (poa);
        }

      if (this->request_processing_strategy_ != 0)
        {
          this->request_processing_strategy_->strategy_init (poa, policies.servant_retention());
        }

      if (this->id_uniqueness_strategy_ != 0)
        {
          this->id_uniqueness_strategy_->strategy_init (poa);
        }

      if (this->implicit_activation_strategy_ != 0)
        {
          this->implicit_activation_strategy_->strategy_init (poa);
        }

      if (this->thread_strategy_ != 0)
        {
          this->thread_strategy_->strategy_init (poa);
        }

      if (this->servant_retention_strategy_ != 0)
        {
          this->servant_retention_strategy_->strategy_init (poa);
        }

      if (this->id_assignment_strategy_ != 0)
        {
          this->id_assignment_strategy_->strategy_init (poa);
        }
    }

    void
    Active_Policy_Strategies::cleanup ()
    {
      if (this->lifespan_strategy_ != 0)
        {
          this->lifespan_strategy_factory_->destroy (lifespan_strategy_);

          this->lifespan_strategy_ = 0;
        }

      if (this->request_processing_strategy_ != 0)
        {
          this->request_processing_strategy_factory_->destroy (request_processing_strategy_);

          this->request_processing_strategy_ = 0;
        }

      if (this->id_uniqueness_strategy_ != 0)
        {
          this->id_uniqueness_strategy_factory_->destroy (id_uniqueness_strategy_);

          this->id_uniqueness_strategy_ = 0;
        }

      if (this->implicit_activation_strategy_ != 0)
        {
          this->implicit_activation_strategy_factory_->destroy (implicit_activation_strategy_);

          this->implicit_activation_strategy_ = 0;
        }

      if (this->thread_strategy_ != 0)
        {
          this->thread_strategy_factory_->destroy (thread_strategy_);

          this->thread_strategy_ = 0;
        }

      if (this->servant_retention_strategy_ != 0)
        {
          this->servant_retention_strategy_factory_->destroy (servant_retention_strategy_);

          this->servant_retention_strategy_ = 0;
        }

      if (this->id_assignment_strategy_ != 0)
        {
          this->id_assignment_strategy_factory_->destroy (id_assignment_strategy_);

          this->id_assignment_strategy_ = 0;
        }
    }
  }
}

TAO_END_VERSIONED_NAMESPACE_DECL