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
|
// $Id$
#include "orbsvcs/FtRtEvent/EventChannel/IOGR_Maker.h"
#include "orbsvcs/FtRtEvent/EventChannel/Replication_Service.h"
#include "ace/Synch_T.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
template <class EC_PROXY_ADMIN, class Proxy,
class ProxyInterface, class State>
FT_ProxyAdmin<EC_PROXY_ADMIN, Proxy, ProxyInterface, State>::FT_ProxyAdmin(
EC_PROXY_ADMIN* admin, PortableServer::POA_var poa)
: FT_ProxyAdmin_Base(admin, poa), admin_(admin)
{
}
template <class EC_PROXY_ADMIN, class Proxy,
class ProxyInterface, class State>
void
FT_ProxyAdmin<EC_PROXY_ADMIN, Proxy, ProxyInterface,State>::obtain_proxy (
const FtRtecEventChannelAdmin::Operation& op)
{
Request_Context_Repository().set_object_id(op.object_id);
ProxyInterface_var result
= admin_->obtain();
FTRTEC::Replication_Service* svc = FTRTEC::Replication_Service::instance();
try{
ACE_Read_Guard<FTRTEC::Replication_Service> locker(*svc);
svc->replicate_request(op,
Proxy::rollback_obtain);
}
catch (...){
admin_->disconnect(result.in());
throw;
}
}
template <class EC_PROXY_ADMIN, class Proxy,
class ProxyInterface, class State>
typename FT_ProxyAdmin<EC_PROXY_ADMIN, Proxy, ProxyInterface, State>::ProxyInterface_ptr
FT_ProxyAdmin<EC_PROXY_ADMIN, Proxy, ProxyInterface, State>::obtain_proxy (void)
{
CORBA::Any_var any = Request_Context_Repository().get_cached_result();
CORBA::Object_var obj;
if (any >>= CORBA::Any::to_object(obj))
return ProxyInterface::_narrow(obj.in());
FtRtecEventChannelAdmin::ObjectId oid;
Request_Context_Repository().generate_object_id(oid);
FtRtecEventChannelAdmin::Operation update;
update.object_id = oid;
update.param._d(EC_PROXY_ADMIN::OBTAIN_ID);
ProxyInterface_var result
= admin_->obtain();
try{
FTRTEC::Replication_Service* svc = FTRTEC::Replication_Service::instance();
ACE_Read_Guard<FTRTEC::Replication_Service> locker(*svc);
obj = IOGR_Maker::instance()->forge_iogr(result.in());
result = ProxyInterface::_narrow(obj.in());
svc->replicate_request(update,
Proxy::rollback_obtain);
}
catch (...){
admin_->disconnect(result.in());
throw;
}
return result._retn();
}
template <class EC_PROXY_ADMIN, class Proxy,
class ProxyInterface, class State>
void FT_ProxyAdmin<EC_PROXY_ADMIN, Proxy, ProxyInterface, State>::get_state(
State& state)
{
typename EC_PROXY_ADMIN::StateWorker worker(state.proxies);
admin_->for_each(&worker);
}
template <class EC_PROXY_ADMIN, class Proxy,
class ProxyInterface, class State>
void FT_ProxyAdmin<EC_PROXY_ADMIN, Proxy, ProxyInterface, State>::set_state(
const State& state)
{
for (size_t i =0; i < state.proxies.length(); ++i)
{
const typename Proxy::State& proxy_state
= state.proxies[i];
Request_Context_Repository().set_object_id(proxy_state.object_id);
ProxyInterface_var
proxy_ior = admin_->obtain();
typedef typename Proxy::Skeleton Skeleton;
const void *temp = &proxy_state.object_id;
const PortableServer::ObjectId *oid =
reinterpret_cast<const PortableServer::ObjectId *> (temp);
const PortableServer::Servant servant =
poa_->id_to_servant (*oid);
Skeleton skeleton = dynamic_cast<Skeleton> (servant);
static_cast<Proxy*> (skeleton)->set_state(proxy_state);
}
}
TAO_END_VERSIONED_NAMESPACE_DECL
|