1 #ifndef TAO_Notify_Tests_Peer_T_CPP
2 #define TAO_Notify_Tests_Peer_T_CPP
6 #include "ace/Arg_Shifter.h"
8 #include "LookupManager.h"
9 #include "Options_Parser.h"
10 #include "orbsvcs/NotifyExtC.h"
12 template <class Peer_Traits
>
13 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::TAO_Notify_Tests_Peer_T ()
18 template <class Peer_Traits
>
19 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::~TAO_Notify_Tests_Peer_T ()
23 template <class Peer_Traits
>
24 typename TAO_Notify_Tests_Peer_T
<Peer_Traits
>::Proxy_Traits_PTR
25 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::get_proxy ()
30 template <class Peer_Traits
>
31 typename TAO_Notify_Tests_Peer_T
<Peer_Traits
>::Peer_Traits_PTR
32 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::activate ()
34 return this->_this ();
37 template <class Peer_Traits
>
39 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::connect (Proxy_Traits_PTR proxy
,
40 Proxy_Traits_ID proxy_id
)
42 // This will decr the ref count on exit.
43 // Clients of this class should use raw pointers, not vars.
44 PortableServer::ServantBase_var
servant_var (this);
46 typename
Peer_Traits::VAR peer_var
=
49 this->connect_to_peer (proxy
, peer_var
.in ());
52 this->proxy_
= Proxy_Traits_INTERFACE::_duplicate (proxy
);
53 this->proxy_id_
= proxy_id
;
55 // Register the proxy.
56 if (this->proxy_name_
.length () != 0)
58 LOOKUP_MANAGER
->_register (this->proxy_
.in (),
59 this->proxy_name_
.c_str ());
63 template <class Peer_Traits
>
65 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::connect (Admin_Traits_PTR admin_ptr
)
67 typename
Proxy_Traits::VAR proxy_var
=
68 this->obtain_proxy (admin_ptr
);
70 ACE_ASSERT (!CORBA::is_nil (proxy_var
.in ()));
72 this->connect (proxy_var
.in (),
77 template <class Peer_Traits
>
79 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::connect ()
82 PortableServer::POA_var poa
;
83 LOOKUP_MANAGER
->resolve (poa
,
84 this->poa_name_
.c_str ());
87 this->set_poa (poa
.in ());
90 typename
Admin_Traits::VAR admin_var
;
92 LOOKUP_MANAGER
->resolve (admin_var
,
93 this->admin_name_
.c_str ());
95 typename
Admin_Ext_Traits::VAR admin_ext_var
=
96 Admin_Ext_Traits_INTERFACE::_narrow (admin_var
.in ());
98 typename
Proxy_Traits::VAR proxy_var
=
99 this->obtain_proxy (admin_ext_var
.in (),
102 ACE_ASSERT (!CORBA::is_nil (proxy_var
.in ()));
104 // connect supplier to proxy,
105 // also activates the servant as CORBA object in the POA specified.
106 this->connect (proxy_var
.in (),
110 template <class Peer_Traits
>
112 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::set_qos (
113 CosNotification::QoSProperties
& qos
116 this->get_proxy ()->set_qos (qos
);
119 template <class Peer_Traits
>
121 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::status ()
123 #if (TAO_HAS_MINIMUM_CORBA == 0)
126 CORBA::Boolean not_exist
=
127 this->get_proxy ()->_non_existent ();
131 ACE_DEBUG ((LM_DEBUG
,
132 "Peer %s, Proxy does not exist\n",
133 this->name_
.c_str ()));
137 ACE_DEBUG ((LM_DEBUG
,
138 "Peer %s, Proxy exists\n",
139 this->name_
.c_str ()));
142 catch (const CORBA::TRANSIENT
& ex
)
144 ex
._tao_print_exception ("Error: ");
145 ACE_DEBUG ((LM_DEBUG
,
146 "Peer %s is_equivalent transient exception.",
147 this->name_
.c_str ()));
149 catch (const CORBA::Exception
& ex
)
151 ex
._tao_print_exception ("Error: ");
152 ACE_DEBUG ((LM_DEBUG
,
153 "Peer %s is_equivanent other exception.",
154 this->name_
.c_str ()));
156 #endif /* TAO_HAS_MINIMUM_CORBA */
159 template <class Peer_Traits
>
161 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::disconnect ()
163 ACE_ASSERT (!CORBA::is_nil (this->proxy_
.in ()));
167 this->disconnect_from_proxy ();
169 catch (const CORBA::Exception
&)
171 ACE_DEBUG ((LM_DEBUG
,
172 "Peer %s failed to disconnect from proxy.",
173 this->name_
.c_str ()));
180 catch (const CORBA::Exception
&)
182 ACE_DEBUG ((LM_DEBUG
,
183 "Peer %s failed to deactivate.",
184 this->name_
.c_str ()));
188 template <class Peer_Traits
>
189 PortableServer::POA_ptr
190 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::_default_POA (
193 return PortableServer::POA::_duplicate (this->default_POA_
.in ());
196 template <class Peer_Traits
>
198 TAO_Notify_Tests_Peer_T
<Peer_Traits
>::deactivate ()
200 PortableServer::POA_var poa
= this->_default_POA ();
202 PortableServer::ObjectId_var id
=
203 poa
->servant_to_id (this);
205 poa
->deactivate_object (id
.in ());
208 #endif /* TAO_Notify_Tests_Peer_T_CPP */