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
|
// -*- C++ -*-
#include "tao/PortableServer/LifespanStrategyPersistent.h"
ACE_RCSID (PortableServer,
Lifespan_Strategy,
"$Id$")
#include "tao/PortableServer/Root_POA.h"
#include "tao/PortableServer/POAManager.h"
#include "tao/PortableServer/ImR_Client_Adapter.h"
#include "tao/ORB_Core.h"
#include "ace/OS_NS_sys_time.h"
#include "ace/Dynamic_Service.h"
#include "ace/Service_Config.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
namespace TAO
{
namespace Portable_Server
{
void
LifespanStrategyPersistent::strategy_init (
TAO_Root_POA *poa
ACE_ENV_ARG_DECL)
{
LifespanStrategy::strategy_init (poa ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
this->use_imr_ = this->poa_->orb_core ().use_implrepo ();
}
bool
LifespanStrategyPersistent::validate (
CORBA::Boolean is_persistent,
const TAO::Portable_Server::Temporary_Creation_Time& /*creation_time*/) const
{
return is_persistent;
}
char
LifespanStrategyPersistent::key_type (void) const
{
return 'P';
}
CORBA::Boolean
LifespanStrategyPersistent::is_persistent (void) const
{
return true;
}
void
LifespanStrategyPersistent::create_key (
CORBA::Octet *buffer,
CORBA::ULong& starting_at)
{
// Copy the persistence byte.
buffer[starting_at] = static_cast<CORBA::Octet> (this->key_type ());
starting_at += this->key_type_length ();
}
CORBA::ULong
LifespanStrategyPersistent::key_length () const
{
return this->key_type_length ();
}
void
LifespanStrategyPersistent::notify_startup (ACE_ENV_SINGLE_ARG_DECL)
{
if (this->use_imr_)
{
// The user specified that the ImR should be used.
ImR_Client_Adapter *adapter =
ACE_Dynamic_Service<ImR_Client_Adapter>::instance (
TAO_Root_POA::imr_client_adapter_name ()
);
#if !defined (TAO_AS_STATIC_LIBS)
// In case we build shared, try to load the ImR Client library, in a
// static build we just can't do this, so don't try it, lower layers
// output an error then.
if (adapter == 0)
{
ACE_Service_Config::process_directive (
ACE_DYNAMIC_SERVICE_DIRECTIVE(
"ImR_Client_Adapter", "TAO_ImR_Client",
"_make_ImR_Client_Adapter_Impl", ""));
adapter =
ACE_Dynamic_Service<ImR_Client_Adapter>::instance (
TAO_Root_POA::imr_client_adapter_name ());
}
#endif /* !TAO_AS_STATIC_LIBS */
if (adapter != 0)
{
adapter->imr_notify_startup (this->poa_ ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
else
{
// When we don't have a ImR_Client adapter, but the user
// has specified that the ImR has to be used we have an
// error situation which has to be reported.
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) ERROR: No ImR_Client library ")
ACE_TEXT ("available but use IMR has been specified.\n")));
ACE_THROW (CORBA::INTERNAL ());
}
}
}
void
LifespanStrategyPersistent::notify_shutdown (ACE_ENV_SINGLE_ARG_DECL)
{
ImR_Client_Adapter *adapter =
ACE_Dynamic_Service<ImR_Client_Adapter>::instance (
TAO_Root_POA::imr_client_adapter_name ()
);
if (adapter != 0)
{
adapter->imr_notify_shutdown (this->poa_ ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
}
LifespanStrategyPersistent::LifespanStrategyPersistent() :
use_imr_ (true)
{
}
void
LifespanStrategyPersistent::check_state (ACE_ENV_SINGLE_ARG_DECL)
{
this->poa_->tao_poa_manager().check_state (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
}
::PortableServer::LifespanPolicyValue
LifespanStrategyPersistent::type() const
{
return ::PortableServer::PERSISTENT;
}
bool
LifespanStrategyPersistent::use_imr () const
{
return use_imr_;
}
} /* namespace Portable_Server */
} /* namespace TAO */
TAO_END_VERSIONED_NAMESPACE_DECL
|