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
|
// $Id$
#include "ir_simple_object_impl.h"
#include "tao/corba.h"
ACE_RCSID(ImplRepo, ir_simple_object_impl, "$Id$")
// Constructor
IR_Simple_i::IR_Simple_i (CORBA::ORB_ptr orb_ptr,
PortableServer::POA_ptr poa_ptr,
CORBA::Object_ptr forward_to_ptr)
: orb_var_ (CORBA::ORB::_duplicate (orb_ptr)),
poa_var_ (PortableServer::POA::_duplicate (poa_ptr)),
forward_to_var_ (CORBA::Object::_duplicate (forward_to_ptr))
{
if (CORBA::is_nil (this->forward_to_var_))
ACE_DEBUG ((LM_DEBUG, "Forward_to is nil!\n"));
}
// Destructor
IR_Simple_i::~IR_Simple_i (void)
{
}
// Cube a long
CORBA::Long
IR_Simple_i::simple_method (CORBA::Long l, CORBA::Environment &env)
{
if (!CORBA::is_nil (this->forward_to_var_.in ()))
{
ACE_DEBUG ((LM_DEBUG, "Forwarding...\n"));
PortableServer::ObjectId_var oid =
this->poa_var_->servant_to_id (this, env);
if (env.exception () != 0)
return -1;
PortableServer::Servant servant = this->poa_var_->_servant ();
if (servant == 0)
{
// CORBA::Exception *exception = new Foo::Cannot_Forward;
// env.exception (exception);
return -1;
}
void *ptr = servant->_downcast ("IDL:PortableServer/POA:1.0");
POA_PortableServer::POA *poa = (POA_PortableServer::POA *) ptr;
TAO_POA *tao_poa = ACE_dynamic_cast (TAO_POA *, poa);
tao_poa->forward_object (oid.in (),
this->forward_to_var_.in (),
env);
}
else
{
ACE_DEBUG ((LM_DEBUG, "Forward_to refenence is nil.\n"));
// CORBA::Exception *exception = new Foo::Cannot_Forward;
// env.exception (exception);
return -1;
}
return 0;
}
// Shutdown.
void IR_Simple_i::shutdown (CORBA::Environment &env)
{
ACE_UNUSED_ARG (env);
ACE_DEBUG ((LM_DEBUG, "%s\n", "IR_Simple_i is shutting down"));
TAO_ORB_Core_instance ()->orb ()->shutdown ();
}
|