blob: 426ab1c505248752bab17ac162cce1af69d2f6de (
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
|
//
// $Id$
//
#include "tao/ORB_Core.h"
#include "tao/debug.h"
#include "tao/Transport_Cache_Manager.h"
#include "Object_Factory_i.h"
#include "ace/Synch.h"
ACE_RCSID(Test, Test, "$Id$")
Object_Factory_i::Object_Factory_i (CORBA::ORB_ptr orb, CORBA::ULong len)
: orb_ (CORBA::ORB::_duplicate (orb)),
length_(len)
{
}
//factory method to create first object
Two_Objects_Test::First_ptr
Object_Factory_i::create_first (void)
{
First_i *first_impl;
ACE_NEW_THROW_EX (first_impl,
First_i (orb_.in(), two_way_done_ ),
CORBA::NO_MEMORY() );
// Ownership is transfered to the POA.
PortableServer::ServantBase_var safe (first_impl);
CORBA::Object_var poa_object =
this->orb_->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (first_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Two_Objects_Test::First_var first =
Two_Objects_Test::First::_narrow (object.in ());
return first._retn();
}
//factory method to create second object
Two_Objects_Test::Second_ptr
Object_Factory_i::create_second (void)
{
Second_i *second_impl;
ACE_NEW_THROW_EX (second_impl,
Second_i (orb_.in(),
length_, two_way_done_),
CORBA::NO_MEMORY ());
// Ownership is transfered to the POA.
PortableServer::ServantBase_var safe (second_impl);
CORBA::Object_var poa_object =
this->orb_->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (second_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Two_Objects_Test::Second_var second =
Two_Objects_Test::Second::_narrow (object.in ());
return second._retn();
}
|