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
107
108
109
110
|
// $Id$
#ifndef APPHELPER_H
#define APPHELPER_H
#include "CSD_TP_Test_Export.h"
#include "TestAppExceptionC.h"
#include "tao/PortableServer/PortableServer.h"
#include "tao/ORB.h"
#include "ace/OS.h"
#include "ace/Log_Msg.h"
template <typename T>
struct RefHelper
{
typedef typename T::_ptr_type T_ptr;
typedef typename T::_var_type T_var;
static T_ptr string_to_ref(CORBA::ORB_ptr orb,
const char* ior
ACE_ENV_ARG_DECL)
{
CORBA::Object_var obj = orb->string_to_object(ior ACE_ENV_ARG_PARAMETER);
if (CORBA::is_nil(obj.in()))
{
ACE_ERROR((LM_ERROR,
"(%P|%t) Failed to convert IOR string to obj ref.\n"));
ACE_THROW_RETURN (TestAppException(), T::_nil ());
}
T_var t_obj = T::_narrow(obj.in() ACE_ENV_ARG_PARAMETER);
if (CORBA::is_nil(t_obj.in()))
{
ACE_ERROR((LM_ERROR,
"(%P|%t) Failed to narrow obj ref to T interface.\n"));
ACE_THROW_RETURN (TestAppException(), T::_nil ());
}
return t_obj._retn();
}
static T_ptr resolve_initial_ref(CORBA::ORB_ptr orb,
const char* name
ACE_ENV_ARG_DECL)
{
CORBA::Object_var obj
= orb->resolve_initial_references(name ACE_ENV_ARG_PARAMETER);
if (CORBA::is_nil(obj.in()))
{
ACE_ERROR((LM_ERROR,
"(%P|%t) Failed to resolve initial ref for '%s'.\n",
name));
ACE_THROW_RETURN (TestAppException(), T::_nil ());
}
T_var t_obj = T::_narrow(obj.in() ACE_ENV_ARG_PARAMETER);
if (CORBA::is_nil(t_obj.in()))
{
ACE_ERROR((LM_ERROR,
"(%P|%t) Failed to narrow resolved initial ref '%s'.\n",
name));
ACE_THROW_RETURN (TestAppException(), T::_nil ());
}
return t_obj._retn();
}
};
struct CSD_TP_Test_Export AppHelper
{
static void ref_to_file(CORBA::ORB_ptr orb,
CORBA::Object_ptr obj,
const char* filename
ACE_ENV_ARG_DECL);
static PortableServer::POA_ptr create_poa
(const char* name,
PortableServer::POA_ptr root_poa,
PortableServer::POAManager_ptr mgr,
CORBA::PolicyList& policies
ACE_ENV_ARG_DECL);
static CORBA::Object_ptr activate_servant(PortableServer::POA_ptr poa,
PortableServer::Servant servant
ACE_ENV_ARG_DECL);
// This helper method is used because there is a chance that the
// initial CORBA request made to the target ORB will fail during
// connection establishment with a TRANSIENT CORBA SystemException.
// This occurs for some platforms (ie, windows) when several clients
// make their initial CORBA request to the same ORB at the same time,
// causing the ORB to attempt to handle several connection establishments
// at one time. Apparently, under certain conditions, it will throw the
// TRANSIENT exception to tell the client application to "try again later".
// The analogy is making a phone call. Sometimes you get a busy tone.
// This means "try again later".
// This helper function will retry until the connection establishment
// works - or until it decides that enough is enough.
static bool validate_connection (CORBA::Object_ptr obj);
};
#endif
|