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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%
%%
-module(orber_test_server_impl).
-include_lib("orber/include/corba.hrl").
-include("idl_output/orber_test_server.hrl").
%%--------------- specified functions ------------------------
-export([stop_normal/2,
stop_brutal/2,
print/2,
%% Testing code and decode arguments
testing_iiop_float/3,
testing_iiop_double/3,
testing_iiop_short/3,
testing_iiop_ushort/3,
testing_iiop_long/3,
testing_iiop_longlong/3,
testing_iiop_ulong/3,
testing_iiop_ulonglong/3,
testing_iiop_char/3,
testing_iiop_wchar/3,
testing_iiop_bool/3,
testing_iiop_octet/3,
testing_iiop_any/3,
testing_iiop_obj/3,
testing_iiop_string/3,
testing_iiop_wstring/3,
testing_iiop_struct/3,
testing_iiop_union/3,
testing_iiop_union_d/3,
testing_iiop_enum/3,
testing_iiop_seq/3,
testing_iiop_uni_seq/3,
testing_iiop_struc_seq/3,
testing_iiop_array/3,
testing_iiop_fixed/3,
testing_iiop_void/2,
testing_iiop_context/2,
testing_iiop_server_marshal/3,
testing_iiop_rec_any/3,
testing_iiop_rec_struct/3,
testing_iiop_rec_union/3,
relay_call/3,
relay_cast/3,
%% Testing pseudo calls.
pseudo_call/2,
pseudo_cast/2,
pseudo_call_delay/3,
pseudo_cast_delay/3,
pseudo_call_raise_exc/3,
%% Testing raise locally defined exception.
raise_local_exception/2,
raise_complex_local_exception/2,
%% Test timeout functionality
testing_iiop_oneway_delay/3,
testing_iiop_twoway_delay/3]).
%%--------------- gen_server specific ------------------------
-export([init/1, terminate/2]).
-export([handle_call/3, handle_cast/2, handle_info/2, code_change/3]).
%%--------------- LOCAL DATA ---------------------------------
%%------------------------------------------------------------
%% function : init, terminate
%%------------------------------------------------------------
init(State) ->
process_flag(trap_exit,true),
{ok, State}.
terminate(Reason, State) ->
io:format("orber_test_server:terminate(~p ~p)~n",[Reason, State]),
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
handle_call(_,_, State) ->
{noreply, State}.
handle_cast(_, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
%%--------------- SERVER FUNCTIONS ---------------------------
print(Self, State) ->
io:format("orber_test_server:print(~p ~p)~n",[Self, State]),
{reply, ok, State}.
stop_normal(_Self, State) ->
{stop, normal, ok, State}.
stop_brutal(_Self, _State) ->
exit("killed_brutal").
%% Testing code and decode arguments
testing_iiop_float(_Self, State, Float) ->
{reply, {ok, Float}, State}.
testing_iiop_double(_Self, State, Double) ->
{reply, {ok, Double}, State}.
testing_iiop_short(_Self, State, Short) ->
{reply, {ok, Short}, State}.
testing_iiop_ushort(_Self, State, Ushort) ->
{reply, {ok, Ushort}, State}.
testing_iiop_long(_Self, State, Long) ->
{reply, {ok, Long}, State}.
testing_iiop_longlong(_Self, State, LLong) ->
{reply, {ok, LLong}, State}.
testing_iiop_ulong(_Self, State, Ulong) ->
{reply, {ok, Ulong}, State}.
testing_iiop_ulonglong(_Self, State, ULlong) ->
{reply, {ok, ULlong}, State}.
testing_iiop_char(_Self, State, Char) ->
{reply, {ok, Char}, State}.
testing_iiop_wchar(_Self, State, WChar) ->
{reply, {ok, WChar}, State}.
testing_iiop_bool(_Self, State, Boolean) ->
{reply, {ok, Boolean}, State}.
testing_iiop_octet(_Self, State, Octet) ->
{reply, {ok, Octet}, State}.
testing_iiop_any(_Self, State, Any) ->
{reply, {ok, Any}, State}.
testing_iiop_obj(_Self, State, Obj) ->
{reply, {ok, Obj}, State}.
testing_iiop_string(_Self, State, String) ->
{reply, {ok, String}, State}.
testing_iiop_wstring(_Self, State, WString) ->
{reply, {ok, WString}, State}.
testing_iiop_struct(_Self, State, Struct) ->
{reply, {ok, Struct}, State}.
testing_iiop_union(_Self, State, Union) ->
{reply, {ok, Union}, State}.
testing_iiop_union_d(_Self, State, Union) ->
{reply, {ok, Union}, State}.
testing_iiop_enum(_Self, State, Enum) ->
{reply, {ok, Enum}, State}.
testing_iiop_seq(_Self, State, Sequence) ->
{reply, {ok, Sequence}, State}.
testing_iiop_uni_seq(_Self, State, Sequence) ->
{reply, {ok, Sequence}, State}.
testing_iiop_struc_seq(_Self, State, Sequence) ->
{reply, {ok, Sequence}, State}.
testing_iiop_array(_Self, State, Array) ->
{reply, {ok, Array}, State}.
testing_iiop_fixed(_Self, State, Fixed) ->
{reply, {ok, Fixed}, State}.
testing_iiop_void(_Self, State) ->
{reply, ok, State}.
testing_iiop_context(_Self, State) ->
Ctx = get(oe_server_in_context),
io:format("orber_test_server:testing_iiop_context( ~p )~n", [Ctx]),
{reply, ok, State}.
testing_iiop_server_marshal(_Self, State, _String) ->
{reply, {ok, false}, State}.
testing_iiop_rec_any(_Self, State, RAny) ->
{reply, RAny, State}.
testing_iiop_rec_struct(_Self, State, RecS) ->
{reply, RecS, State}.
testing_iiop_rec_union(_Self, State, RecU) ->
{reply, RecU, State}.
testing_iiop_oneway_delay(_Self, State, Time) ->
timer:sleep(Time),
{noreply, State}.
testing_iiop_twoway_delay(_Self, State, Time) ->
timer:sleep(Time),
{reply, ok, State}.
raise_local_exception(_Self, State) ->
corba:raise(#'orber_test_server_UserDefinedException'{}),
{reply, ok, State}.
raise_complex_local_exception(_Self, State) ->
corba:raise(#'orber_test_server_ComplexUserDefinedException'{strseq=
[#orber_test_server_struc{a=1, b=2}]}),
{reply, ok, State}.
%% Testing relay calls/casts to, for example, test that sending implicit
%% Contexts works.
relay_call(_Self, State, Target) ->
io:format("orber_test_server:relay_call( ~p ) Pre~n", [get(oe_server_in_context)]),
orber_test_server:testing_iiop_context(Target),
io:format("orber_test_server:relay_call( ~p ) Post~n", [get(oe_server_in_context)]),
{reply, ok, State}.
relay_cast(_Self, State, Target) ->
io:format("orber_test_server:relay_cast( ~p ) Pre~n", [get(oe_server_in_context)]),
orber_test_server:testing_iiop_context(Target),
io:format("orber_test_server:relay_cast( ~p ) Post~n", [get(oe_server_in_context)]),
{noreply, State}.
%% Testing pseudo calls.
pseudo_call(_Self, State) ->
io:format("orber_test_server:pseudo_call( ~p )~n", [erlang:timestamp()]),
{reply, ok, State}.
pseudo_cast(_Self, State) ->
io:format("orber_test_server:pseudo_cast( ~p )~n", [erlang:timestamp()]),
{noreply, State}.
pseudo_call_delay(_Self, State, Time) ->
io:format("orber_test_server:pseudo_call_delay( ~p )~n", [erlang:timestamp()]),
timer:sleep(Time),
io:format("orber_test_server:pseudo_call_delay( ~p )~n", [erlang:timestamp()]),
{reply, {ok, Time}, State}.
pseudo_cast_delay(_Self, State, Time) ->
io:format("orber_test_server:pseudo_cast_delay( ~p )~n", [erlang:timestamp()]),
timer:sleep(Time),
io:format("orber_test_server:pseudo_cast_delay( ~p )~n", [erlang:timestamp()]),
{noreply, State}.
pseudo_call_raise_exc(_Self, State, 1) ->
io:format("orber_test_server:pseudo_call_raise_exc( ~p )~n",[1]),
{reply, {'EXCEPTION', #'BAD_QOS'{completion_status=?COMPLETED_NO}}, State};
pseudo_call_raise_exc(_Self, State, 2) ->
io:format("orber_test_server:pseudo_call_raise_exc( ~p )~n",[2]),
corba:raise(#'BAD_QOS'{completion_status=?COMPLETED_NO}),
{reply, ok, State}.
%%--------------- LOCAL FUNCTIONS ----------------------------
%%--------------- END OF MODULE ------------------------------
|