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
111
112
|
// $Id$
#include "Echo_i.h"
ACE_RCSID(Echo, Echo_i, "$Id$")
// Constructor.
Echo_i::Echo_i (void)
{
}
// Old g++ fooler.
Echo_i::Echo_i (Echo_i &foo)
: POA_Echo (foo)
{
}
// Destructor.
Echo_i::~Echo_i (void)
{
}
// Set the ORB pointer.
void
Echo_i::orb (CORBA::ORB_ptr o)
{
this->orb_ = CORBA::ORB::_duplicate (o);
}
// Return a list of object references.
Echo::List *
Echo_i::echo_list (const char *,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
Echo::List_var list;
{
Echo::List *tmp;
ACE_NEW_RETURN (tmp,
Echo::List (3),
0);
// Pass ownership to the _var, pitty that ACE_NEW_RETURN cannot
// assign to T_vars directly.
list = tmp;
}
list->length (3);
// Just do something to get a list of object references.
list[CORBA::ULong(0)] =
orb_->resolve_initial_references ("NameService",
ACE_TRY_ENV);
ACE_CHECK_RETURN (0);
list[CORBA::ULong(1)] =
orb_->resolve_initial_references ("NameService",
ACE_TRY_ENV);;
ACE_CHECK_RETURN (0);
list[CORBA::ULong(2)] =
orb_->resolve_initial_references ("NameService",
ACE_TRY_ENV);
ACE_CHECK_RETURN (0);
return list._retn ();
}
// Return the mesg string from the server
char *
Echo_i::echo_string (const char *mesg,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
// The pointer mesg was NULL, return.
if (mesg == 0)
return 0;
CORBA::String_var str = CORBA::string_dup (mesg);
// if <CORBA::string_dup> returns a 0 pointer, an exception is
// raised.
if (str.in () == 0)
ACE_THROW_RETURN (CORBA::NO_MEMORY (), 0);
// Got thru! now, make a deep copy of the mesg string and send it
// back to the client.
return str._retn ();
// The _retn is used as it allows the conversion of
// CORBA::String_var to char* without causing any compiler errors.
}
// Shutdown the server application.
void
Echo_i::shutdown (CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_DEBUG ((LM_DEBUG,
"\n%s\n",
"The echo server is shutting down"));
// Instruct the ORB to shutdown.
this->orb_->shutdown ();
}
|