blob: f5c5e4cbc49c22b3fcd7092379dcee814f42008f (
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
|
#include "ace/Arg_Shifter.h"
#include "tao/PortableServer/POAManager.h"
#include "tao/PortableServer/PortableServer.h"
#include "PersistentPoa.h"
PersistentPoa::PersistentPoa ()
{
}
PersistentPoa::~PersistentPoa () noexcept
{
}
int PersistentPoa::init (int argc, ACE_TCHAR *argv[])
{
ACE_Arg_Shifter as (argc, argv);
m_poaName = std::string (ACE_TEXT_ALWAYS_CHAR (as.get_current ()));
as.ignore_arg ();
std::string orbName (ACE_TEXT_ALWAYS_CHAR (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 ());
// Policies for the new POA
CORBA::PolicyList policies (3);
policies.length (3);
policies[0] = mv_rootPOA->create_thread_policy (PortableServer::ORB_CTRL_MODEL);
policies[1] = mv_rootPOA->create_lifespan_policy (PortableServer::PERSISTENT);
policies[2] = mv_rootPOA->create_id_assignment_policy (PortableServer::USER_ID);
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;
}
int PersistentPoa::fini ()
{
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;
}
ACE_FACTORY_DEFINE (bug_3251, PersistentPoa)
|