blob: fd530a1687a007ab50a9d2399f2ae17f97752cf3 (
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
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
|
// $Id$
#include "ace/Arg_Shifter.h"
#include "tao/PortableServer/POAManager.h"
#include "tao/PortableServer/PortableServer.h"
#include "PersistentPoa.h"
PersistentPoa::PersistentPoa ( )
{
} /* end of PersistentPoa::PersistentPoa ( ) */
PersistentPoa::~PersistentPoa ( )
throw ()
{
} /* end of PersistentPoa::~PersistentPoa ( ) */
int PersistentPoa::init (int argc, char *argv[])
{
ACE_Arg_Shifter as(argc, argv);
m_poaName = std::string(as.get_current());
as.ignore_arg();
std::string orbName(as.get_current());
as.ignore_arg();
while(as.is_anything_left())
{
as.ignore_arg();
}
try
{
// left out all safety checks
DllOrb * p_orb = ACE_Dynamic_Service<DllOrb>::instance (orbName.c_str());
mv_orb = p_orb->orb();
CORBA::Object_var v_poa = mv_orb->resolve_initial_references("RootPOA");
mv_rootPOA = PortableServer::POA::_narrow(v_poa.in ());
// Threading policy
CORBA::Policy_var v_threadingPolicy =
mv_rootPOA->create_thread_policy(PortableServer::ORB_CTRL_MODEL);
// Lifespan policy
CORBA::Policy_var v_lifespanPolicy =
mv_rootPOA->create_lifespan_policy(PortableServer::PERSISTENT);
// ID assignment policy
CORBA::Policy_var v_idAssignmentPolicy =
mv_rootPOA->create_id_assignment_policy(PortableServer::USER_ID);
// Policies for the new POA
CORBA::PolicyList policies(3);
policies.length (3);
policies[0] = v_threadingPolicy.in();
policies[1] = v_lifespanPolicy.in();
policies[2] = v_idAssignmentPolicy.in();
mv_thisPOA = mv_rootPOA->create_POA(
m_poaName.c_str(),
PortableServer::POAManager::_nil(),
policies
);
mv_poaManager = mv_thisPOA->the_POAManager();
mv_poaManager->activate();
}
catch(...)
{
ACE_DEBUG ((LM_ERROR, ACE_TEXT ("activate failed\n")));
return -1;
}
ACE_DEBUG ((LM_ERROR, ACE_TEXT ("POA activated\n")));
return 0;
} /* end of PersistentPoa::init ( ) */
int PersistentPoa::fini (void)
{
try
{
mv_poaManager->deactivate(1, 1);
mv_poaManager = PortableServer::POAManager::_nil();
mv_thisPOA->destroy(1, 1);
mv_thisPOA = PortableServer::POA::_nil();
}
catch(...)
{
ACE_DEBUG ((LM_ERROR, ACE_TEXT ("deactivate failed\n")));
return -1;
}
ACE_DEBUG ((LM_ERROR, ACE_TEXT ("POA deactivated\n")));
return 0;
} /* end of PersistentPoa::fini ( ) */
ACE_FACTORY_DEFINE (bug_3252, PersistentPoa)
|