r2corba 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +159 -0
- data/LICENSE +59 -0
- data/README +62 -0
- data/THANKS +52 -0
- data/bin/r2corba +8 -0
- data/bin/ridlc +11 -0
- data/bin/rins +7 -0
- data/ext/ext.mwc +6 -0
- data/ext/extload/extload.c +60 -0
- data/ext/libr2tao/any.cpp +1543 -0
- data/ext/libr2tao/exception.cpp +202 -0
- data/ext/libr2tao/exception.h +104 -0
- data/ext/libr2tao/longdouble.cpp +173 -0
- data/ext/libr2tao/longdouble.h +31 -0
- data/ext/libr2tao/object.cpp +1150 -0
- data/ext/libr2tao/object.h +38 -0
- data/ext/libr2tao/orb.cpp +1029 -0
- data/ext/libr2tao/orb.h +36 -0
- data/ext/libr2tao/r2tao_export.h +45 -0
- data/ext/libr2tao/r2tao_ext.h +38 -0
- data/ext/libr2tao/required.cpp +463 -0
- data/ext/libr2tao/required.h +187 -0
- data/ext/libr2tao/typecode.cpp +888 -0
- data/ext/libr2tao/typecode.h +45 -0
- data/ext/libr2tao/values.cpp +2938 -0
- data/ext/libr2tao/values.h +396 -0
- data/ext/librpoa/iortable.cpp +250 -0
- data/ext/librpoa/poa.cpp +1076 -0
- data/ext/librpoa/poa.h +24 -0
- data/ext/librpoa/rpoa_export.h +44 -0
- data/ext/librpoa/servant.cpp +1338 -0
- data/ext/librpoa/servant.h +116 -0
- data/ext/librpoa/srvreq_fix.cpp +283 -0
- data/ext/librpoa/srvreq_fix.h +149 -0
- data/ext/librpol/policies.cpp +763 -0
- data/ext/librpol/policies.h +15 -0
- data/ext/librpol/rpol_export.h +44 -0
- data/lib/corba/cbase/IORMap.rb +33 -0
- data/lib/corba/cbase/ORB.rb +231 -0
- data/lib/corba/cbase/Request.rb +134 -0
- data/lib/corba/cbase/Streams.rb +129 -0
- data/lib/corba/cbase/Stub.rb +19 -0
- data/lib/corba/cbase/Typecode.rb +441 -0
- data/lib/corba/cbase/Values.rb +129 -0
- data/lib/corba/cbase/exception.rb +66 -0
- data/lib/corba/cbase/poa.rb +23 -0
- data/lib/corba/cbase/policies.rb +78 -0
- data/lib/corba/cbase/post_require.rb +14 -0
- data/lib/corba/cbase/require.rb +28 -0
- data/lib/corba/cmds/base.rb +85 -0
- data/lib/corba/cmds/test.rb +30 -0
- data/lib/corba/common/Any.rb +91 -0
- data/lib/corba/common/IDL.rb +104 -0
- data/lib/corba/common/ORB.rb +368 -0
- data/lib/corba/common/Object.rb +208 -0
- data/lib/corba/common/Request.rb +20 -0
- data/lib/corba/common/Servant.rb +108 -0
- data/lib/corba/common/Struct.rb +22 -0
- data/lib/corba/common/Stub.rb +79 -0
- data/lib/corba/common/Typecode.rb +1121 -0
- data/lib/corba/common/Union.rb +56 -0
- data/lib/corba/common/Values.rb +92 -0
- data/lib/corba/common/const.rb +22 -0
- data/lib/corba/common/exception.rb +68 -0
- data/lib/corba/common/require.rb +27 -0
- data/lib/corba/common/version.rb +22 -0
- data/lib/corba/idl/IDL.rb +21 -0
- data/lib/corba/idl/IORTable.pidl +62 -0
- data/lib/corba/idl/TAO_Ext.pidl +46 -0
- data/lib/corba/idl/require.rb +20 -0
- data/lib/corba/jbase/Any.rb +273 -0
- data/lib/corba/jbase/IORMap.rb +36 -0
- data/lib/corba/jbase/ORB.rb +99 -0
- data/lib/corba/jbase/Object.rb +98 -0
- data/lib/corba/jbase/Request.rb +226 -0
- data/lib/corba/jbase/Servant.rb +247 -0
- data/lib/corba/jbase/ServerRequest.rb +128 -0
- data/lib/corba/jbase/Streams.rb +671 -0
- data/lib/corba/jbase/Stub.rb +38 -0
- data/lib/corba/jbase/Typecode.rb +520 -0
- data/lib/corba/jbase/Values.rb +173 -0
- data/lib/corba/jbase/exception.rb +106 -0
- data/lib/corba/jbase/poa.rb +229 -0
- data/lib/corba/jbase/policies.rb +300 -0
- data/lib/corba/jbase/post_require.rb +14 -0
- data/lib/corba/jbase/require.rb +86 -0
- data/lib/corba/naming.rb +14 -0
- data/lib/corba/naming_service.rb +15 -0
- data/lib/corba/poa.rb +15 -0
- data/lib/corba/policies.rb +18 -0
- data/lib/corba/require.rb +17 -0
- data/lib/corba/svcs/ins/cos_naming.rb +426 -0
- data/lib/corba/svcs/ins/ins.rb +526 -0
- data/lib/corba/svcs/ins/naming_service.rb +119 -0
- data/lib/corba.rb +16 -0
- data/lib/ridlbe/ruby/config.rb +336 -0
- data/lib/ridlbe/ruby/require.rb +16 -0
- data/lib/ridlbe/ruby/walker.rb +1582 -0
- data/mkrf_conf_srcgem.rb +186 -0
- data/rakelib/bin.rake +80 -0
- data/rakelib/bin.rb +146 -0
- data/rakelib/build.rake +87 -0
- data/rakelib/config.rake +52 -0
- data/rakelib/config.rb +450 -0
- data/rakelib/ext.rake +242 -0
- data/rakelib/ext.rb +308 -0
- data/rakelib/ext_r2tao.rb +232 -0
- data/rakelib/gem.rake +212 -0
- data/rakelib/gem.rb +146 -0
- data/rakelib/package.rake +26 -0
- data/rakelib/test.rake +23 -0
- data/test/BiDirectional/Test.idl +34 -0
- data/test/BiDirectional/client.rb +132 -0
- data/test/BiDirectional/run_test.rb +68 -0
- data/test/BiDirectional/server.rb +169 -0
- data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
- data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
- data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
- data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
- data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
- data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
- data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
- data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
- data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
- data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
- data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
- data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
- data/test/Collocation/Diamond.idl +39 -0
- data/test/Collocation/run_test.rb +52 -0
- data/test/Collocation/test.rb +195 -0
- data/test/Connect_Timeout/Test.idl +27 -0
- data/test/Connect_Timeout/client.rb +111 -0
- data/test/Connect_Timeout/run_test.rb +52 -0
- data/test/DII/Test.idl +27 -0
- data/test/DII/client.rb +115 -0
- data/test/DII/run_test.rb +69 -0
- data/test/DII/server.rb +95 -0
- data/test/DSI/Test.idl +27 -0
- data/test/DSI/client.rb +66 -0
- data/test/DSI/run_test.rb +69 -0
- data/test/DSI/server.rb +106 -0
- data/test/Exceptions/Test.idl +48 -0
- data/test/Exceptions/client.rb +118 -0
- data/test/Exceptions/run_test.rb +69 -0
- data/test/Exceptions/server.rb +131 -0
- data/test/Hello/Test.idl +27 -0
- data/test/Hello/client.rb +78 -0
- data/test/Hello/run_test.rb +71 -0
- data/test/Hello/server.rb +95 -0
- data/test/IDL_Test/Test.idl +113 -0
- data/test/IDL_Test/Test_inc.idl +17 -0
- data/test/IDL_Test/client.rb +102 -0
- data/test/IDL_Test/run_test.rb +69 -0
- data/test/IDL_Test/server.rb +99 -0
- data/test/IORMap/Test.idl +27 -0
- data/test/IORMap/client.rb +73 -0
- data/test/IORMap/run_test.rb +69 -0
- data/test/IORMap/server.rb +114 -0
- data/test/IORTable/Test.idl +27 -0
- data/test/IORTable/client.rb +75 -0
- data/test/IORTable/run_test.rb +69 -0
- data/test/IORTable/server.rb +130 -0
- data/test/Implicit_Conversion/Test.idl +31 -0
- data/test/Implicit_Conversion/client.rb +110 -0
- data/test/Implicit_Conversion/run_test.rb +69 -0
- data/test/Implicit_Conversion/server.rb +99 -0
- data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
- data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
- data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
- data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
- data/test/Multi_Threading/Simple/Test.idl +27 -0
- data/test/Multi_Threading/Simple/client.rb +88 -0
- data/test/Multi_Threading/Simple/run_test.rb +69 -0
- data/test/Multi_Threading/Simple/server.rb +118 -0
- data/test/Multi_Threading/Threads/Test.idl +31 -0
- data/test/Multi_Threading/Threads/client.rb +80 -0
- data/test/Multi_Threading/Threads/run_test.rb +76 -0
- data/test/Multi_Threading/Threads/server.rb +119 -0
- data/test/Multi_Threading/Threads/watchdog.rb +87 -0
- data/test/Multiple_Servant_Interfaces/Test.idl +34 -0
- data/test/Multiple_Servant_Interfaces/client.rb +70 -0
- data/test/Multiple_Servant_Interfaces/run_test.rb +69 -0
- data/test/Multiple_Servant_Interfaces/server.rb +102 -0
- data/test/Nil/Test.idl +27 -0
- data/test/Nil/run_test.rb +52 -0
- data/test/Nil/test.rb +78 -0
- data/test/OBV/AbstractInterface/client.rb +179 -0
- data/test/OBV/AbstractInterface/run_test.rb +69 -0
- data/test/OBV/AbstractInterface/server.rb +149 -0
- data/test/OBV/AbstractInterface/test.idl +53 -0
- data/test/OBV/Custom/OBV.idl +18 -0
- data/test/OBV/Custom/OBV_impl.rb +40 -0
- data/test/OBV/Custom/client.rb +86 -0
- data/test/OBV/Custom/run_test.rb +69 -0
- data/test/OBV/Custom/server.rb +100 -0
- data/test/OBV/Simple/OBV.idl +15 -0
- data/test/OBV/Simple/OBV_impl.rb +26 -0
- data/test/OBV/Simple/client.rb +86 -0
- data/test/OBV/Simple/run_test.rb +69 -0
- data/test/OBV/Simple/server.rb +100 -0
- data/test/OBV/Simple_Event/Event.idl +15 -0
- data/test/OBV/Simple_Event/Event_impl.rb +26 -0
- data/test/OBV/Simple_Event/client.rb +86 -0
- data/test/OBV/Simple_Event/run_test.rb +69 -0
- data/test/OBV/Simple_Event/server.rb +100 -0
- data/test/OBV/Supports/client.rb +116 -0
- data/test/OBV/Supports/run_test.rb +69 -0
- data/test/OBV/Supports/server.rb +103 -0
- data/test/OBV/Supports/supports.idl +33 -0
- data/test/OBV/Supports/supports_impl.rb +57 -0
- data/test/OBV/Tree/client.rb +116 -0
- data/test/OBV/Tree/run_test.rb +69 -0
- data/test/OBV/Tree/server.rb +117 -0
- data/test/OBV/Tree/test.idl +32 -0
- data/test/OBV/Truncatable/Extra.idl +27 -0
- data/test/OBV/Truncatable/Truncatable.idl +105 -0
- data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
- data/test/OBV/Truncatable/client.rb +279 -0
- data/test/OBV/Truncatable/run_test.rb +69 -0
- data/test/OBV/Truncatable/server.rb +89 -0
- data/test/OBV/ValueBox/client.rb +497 -0
- data/test/OBV/ValueBox/run_test.rb +69 -0
- data/test/OBV/ValueBox/server.rb +271 -0
- data/test/OBV/ValueBox/valuebox.idl +101 -0
- data/test/OBV/ValueBox/vb_basic.idl +75 -0
- data/test/OBV/ValueBox/vb_struct.idl +68 -0
- data/test/OBV/ValueBox/vb_union.idl +21 -0
- data/test/Object/Test.idl +27 -0
- data/test/Object/client.rb +103 -0
- data/test/Object/run_test.rb +69 -0
- data/test/Object/server.rb +126 -0
- data/test/POA/Test.idl +27 -0
- data/test/POA/run_test.rb +52 -0
- data/test/POA/test.rb +112 -0
- data/test/Param_Test/Test.idl +182 -0
- data/test/Param_Test/client.rb +277 -0
- data/test/Param_Test/run_test.rb +69 -0
- data/test/Param_Test/server.rb +296 -0
- data/test/Performance/Simple/Test.idl +27 -0
- data/test/Performance/Simple/client.rb +90 -0
- data/test/Performance/Simple/run_test.rb +69 -0
- data/test/Performance/Simple/server.rb +95 -0
- data/test/Policies/Test.idl +27 -0
- data/test/Policies/run_test.rb +52 -0
- data/test/Policies/test.rb +144 -0
- data/test/Timeout/client.rb +207 -0
- data/test/Timeout/run_test.rb +69 -0
- data/test/Timeout/server.rb +109 -0
- data/test/Timeout/test.idl +19 -0
- data/test/lib/assert.rb +43 -0
- data/test/lib/test.rb +542 -0
- data/test/test_runner.rb +193 -0
- metadata +334 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# Request.rb - Java/JacORB CORBA Request definitions
|
3
|
+
#
|
4
|
+
# Author: Martin Corino
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the R2CORBA LICENSE which is
|
8
|
+
# included with this program.
|
9
|
+
#
|
10
|
+
# Copyright (c) Remedy IT Expertise BV
|
11
|
+
# Chamber of commerce Rotterdam nr.276339, The Netherlands
|
12
|
+
#--------------------------------------------------------------------
|
13
|
+
module R2CORBA
|
14
|
+
module CORBA
|
15
|
+
|
16
|
+
module Request
|
17
|
+
@@wrapper_klass = Class.new do
|
18
|
+
include CORBA::Request
|
19
|
+
def initialize(nreq, target)
|
20
|
+
@req_ = nreq
|
21
|
+
@target = target
|
22
|
+
end
|
23
|
+
attr_reader :req_
|
24
|
+
attr_reader :target
|
25
|
+
end
|
26
|
+
|
27
|
+
def self._wrap_native(nreq, target)
|
28
|
+
raise ArgumentError, 'Expected org.omg.CORBA.Request' unless nreq.nil? || nreq.is_a?(Native::Request)
|
29
|
+
nreq.nil?() ? nreq : @@wrapper_klass.new(nreq, target)
|
30
|
+
end
|
31
|
+
|
32
|
+
def operation
|
33
|
+
begin
|
34
|
+
self.req_.operation()
|
35
|
+
rescue ::NativeException
|
36
|
+
CORBA::Exception.native2r($!)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_in_arg(tc, val, nm='')
|
41
|
+
begin
|
42
|
+
self.req_.arguments.add_value(nm, Any.to_any(val, tc).to_java(self.req_.target._orb), CORBA::ARG_IN)
|
43
|
+
rescue ::NativeException
|
44
|
+
CORBA::Exception.native2r($!)
|
45
|
+
end
|
46
|
+
self.req_.arguments.count
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_out_arg(tc, nm='')
|
50
|
+
begin
|
51
|
+
self.req_.arguments.add_value(nm, Any.to_any(nil, tc).to_java(self.req_.target._orb), CORBA::ARG_OUT)
|
52
|
+
rescue ::NativeException
|
53
|
+
CORBA::Exception.native2r($!)
|
54
|
+
end
|
55
|
+
self.req_.arguments.count
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_inout_arg(tc, val, nm='')
|
59
|
+
begin
|
60
|
+
self.req_.arguments.add_value(nm, Any.to_any(val, tc).to_java(self.req_.target._orb), CORBA::ARG_INOUT)
|
61
|
+
rescue ::NativeException
|
62
|
+
CORBA::Exception.native2r($!)
|
63
|
+
end
|
64
|
+
self.req_.arguments.count
|
65
|
+
end
|
66
|
+
|
67
|
+
def arguments
|
68
|
+
begin
|
69
|
+
nvl = self.req_.arguments
|
70
|
+
(0..nvl.count).to_a.collect do |i|
|
71
|
+
nv = nvl.item(i)
|
72
|
+
[nv.name,
|
73
|
+
nv.flags,
|
74
|
+
CORBA::TypeCode.from_java(nv.value.type),
|
75
|
+
Any.from_java(nv.value, self.req_.target._orb)]
|
76
|
+
end
|
77
|
+
rescue
|
78
|
+
CORBA::Exception.native2r($!)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def arguments=(*args)
|
83
|
+
if args.size == 1
|
84
|
+
raise ArgumentError, 'invalid argument list' unless ::Array === args.first && args.first.all? {|a| ::Array === a }
|
85
|
+
args = args.first
|
86
|
+
else
|
87
|
+
raise ArgumentError, 'invalid argument list' unless args.all? {|a| ::Array === a }
|
88
|
+
end
|
89
|
+
# clear current arguments
|
90
|
+
begin
|
91
|
+
nvl = self.req_.arguments
|
92
|
+
nvl.remove(0) while nvl.count>0
|
93
|
+
rescue
|
94
|
+
CORBA::Exception.native2r($!)
|
95
|
+
end
|
96
|
+
# add new arguments
|
97
|
+
args.each do |nm, flag, tc, val|
|
98
|
+
case flag
|
99
|
+
when CORBA::ARG_IN
|
100
|
+
self.add_in_arg(tc, val, nm)
|
101
|
+
when CORBA::ARG_OUT
|
102
|
+
self.add_out_arg(tc, nm)
|
103
|
+
when CORBA::ARG_INOUT
|
104
|
+
self.add_inout_arg(tc, val, nm)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def exceptions
|
110
|
+
begin
|
111
|
+
exl = self.req_.exceptions
|
112
|
+
(0..exl.count).to_a.collect do |i|
|
113
|
+
CORBA::TypeCode.from_java(exl.item(i))
|
114
|
+
end
|
115
|
+
rescue
|
116
|
+
CORBA::Exception.native2r($!)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def exceptions=(exl)
|
121
|
+
begin
|
122
|
+
# clear current exceptions
|
123
|
+
jexl = self.req_.exceptions
|
124
|
+
jexl.remove(0) while jexl.count>0
|
125
|
+
# add new exceptions
|
126
|
+
exl.each do |extc|
|
127
|
+
jexl.add(extc.tc_)
|
128
|
+
end
|
129
|
+
rescue
|
130
|
+
CORBA::Exception.native2r($!)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def set_return_type(tc)
|
135
|
+
@return_type = tc
|
136
|
+
begin
|
137
|
+
self.req_.set_return_type(tc.tc_)
|
138
|
+
rescue ::NativeException
|
139
|
+
CORBA::Exception.native2r($!)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def return_value
|
144
|
+
begin
|
145
|
+
Any.from_java(self.req_.return_value, self.req_.target._orb, @return_type)
|
146
|
+
rescue ::NativeException
|
147
|
+
CORBA::Exception.native2r($!)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def invoke
|
152
|
+
begin
|
153
|
+
self.req_.invoke
|
154
|
+
rescue ::NativeException
|
155
|
+
CORBA::Exception.native2r($!)
|
156
|
+
end
|
157
|
+
jex = self.req_.env().exception()
|
158
|
+
unless jex.nil?
|
159
|
+
STDERR.puts "#{jex}\n#{jex.backtrace.join("\n")}" if $VERBOSE
|
160
|
+
if jex.is_a?(CORBA::Native::SystemException)
|
161
|
+
CORBA::SystemException._raise(jex)
|
162
|
+
elsif jex.is_a?(CORBA::Native::UnknownUserException)
|
163
|
+
CORBA::UserException._raise(jex)
|
164
|
+
else
|
165
|
+
raise CORBA::UNKNOWN.new(jex.getMessage(),0,CORBA::COMPLETED_MAYBE)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
self.result
|
169
|
+
end
|
170
|
+
|
171
|
+
def send_oneway
|
172
|
+
begin
|
173
|
+
self.req_.send_oneway
|
174
|
+
rescue ::NativeException
|
175
|
+
CORBA::Exception.native2r($!)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def send_deferred
|
180
|
+
begin
|
181
|
+
self.req_.send_deferred
|
182
|
+
rescue ::NativeException
|
183
|
+
CORBA::Exception.native2r($!)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def poll_response
|
188
|
+
begin
|
189
|
+
self.req_.poll_response
|
190
|
+
rescue ::NativeException
|
191
|
+
CORBA::Exception.native2r($!)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def get_response
|
196
|
+
begin
|
197
|
+
self.req_.get_response
|
198
|
+
rescue ::NativeException
|
199
|
+
CORBA::Exception.native2r($!)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
protected
|
204
|
+
|
205
|
+
def result
|
206
|
+
rc = self.req_.return_value.type.kind.value == CORBA::TK_VOID ? [] : [self.return_value]
|
207
|
+
begin
|
208
|
+
nvl = self.req_.arguments
|
209
|
+
nvl.count.times do |i|
|
210
|
+
nv = nvl.item(i)
|
211
|
+
rc << Any.from_java(nv.value,self.req_.target._orb) unless nv.flags == CORBA::ARG_IN
|
212
|
+
end
|
213
|
+
rescue
|
214
|
+
CORBA::Exception.native2r($!)
|
215
|
+
end
|
216
|
+
if rc.size<2
|
217
|
+
return rc.shift
|
218
|
+
else
|
219
|
+
return *rc
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end # CORBA
|
226
|
+
end # R2CORBA
|
@@ -0,0 +1,247 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# Servant.rb - R2TAO CORBA Servant support
|
3
|
+
#
|
4
|
+
# Author: Martin Corino
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the R2CORBA LICENSE which is
|
8
|
+
# included with this program.
|
9
|
+
#
|
10
|
+
# Copyright (c) Remedy IT Expertise BV
|
11
|
+
# Chamber of commerce Rotterdam nr.276339, The Netherlands
|
12
|
+
#--------------------------------------------------------------------
|
13
|
+
|
14
|
+
module R2CORBA
|
15
|
+
|
16
|
+
module PortableServer
|
17
|
+
|
18
|
+
module DSI
|
19
|
+
|
20
|
+
class Servant < PortableServer::Native::DynamicImplementation
|
21
|
+
def self.new_instance(rsrv)
|
22
|
+
srv = PortableServer::DSI::Servant.new
|
23
|
+
srv.__send__(:init, rsrv)
|
24
|
+
srv
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def init(rsrv)
|
29
|
+
@rsrv = rsrv
|
30
|
+
end
|
31
|
+
|
32
|
+
public
|
33
|
+
def rbServant
|
34
|
+
@rsrv
|
35
|
+
end
|
36
|
+
|
37
|
+
def detach_rbServant()
|
38
|
+
@rsrv = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def invoke(jsrvreq)
|
42
|
+
begin
|
43
|
+
raise CORBA::NO_IMPLEMENT.new('',0,CORBA::COMPLETED_NO) unless @rsrv
|
44
|
+
rsrvreq = CORBA::ServerRequest._wrap_native(jsrvreq, self._orb())
|
45
|
+
begin
|
46
|
+
case rsrvreq.srvreq_.operation()
|
47
|
+
when '_is_a'
|
48
|
+
rsrvreq.describe({:arg_list => [['', CORBA::ARG_IN, CORBA._tc_string]], :result_type => CORBA._tc_boolean})
|
49
|
+
rc = self._is_a(*rsrvreq.arguments)
|
50
|
+
jany = rsrvreq.orb_.create_any()
|
51
|
+
jany.insert_boolean(rc == true)
|
52
|
+
jsrvreq.set_result(jany)
|
53
|
+
when '_non_existent'
|
54
|
+
rsrvreq.describe({:arg_list => [], :result_type => CORBA._tc_boolean})
|
55
|
+
rc = self._non_existent(*rsrvreq.arguments)
|
56
|
+
jany = rsrvreq.orb_.create_any()
|
57
|
+
jany.insert_boolean(rc == true)
|
58
|
+
jsrvreq.set_result(jany)
|
59
|
+
when '_repository_id'
|
60
|
+
rsrvreq.describe({:arg_list => [], :result_type => CORBA._tc_string})
|
61
|
+
rc = self._repository_id(*rsrvreq.arguments)
|
62
|
+
jany = rsrvreq.orb_.create_any()
|
63
|
+
jany.insert_string(rc)
|
64
|
+
jsrvreq.set_result(jany)
|
65
|
+
when '_component'
|
66
|
+
rsrvreq.describe({:arg_list => [], :result_type => CORBA._tc_Object})
|
67
|
+
rc = self._get_component(*rsrvreq.arguments)
|
68
|
+
jany = rsrvreq.orb_.create_any()
|
69
|
+
jany.insert_Object(rc.objref_)
|
70
|
+
jsrvreq.set_result(jany)
|
71
|
+
else
|
72
|
+
@rsrv.is_a?(PortableServer::DynamicImplementation) ? self.invoke_DSI(rsrvreq) : self.invoke_SI(rsrvreq)
|
73
|
+
end
|
74
|
+
rescue NativeException => ex_
|
75
|
+
CORBA::Exception.native2r(ex_)
|
76
|
+
end
|
77
|
+
rescue CORBA::UserException => ex_
|
78
|
+
STDERR.puts "#{ex_}\n#{ex_.backtrace.join("\n")}" if $VERBOSE
|
79
|
+
if rsrvreq.exc_list_.nil? || rsrvreq.exc_list_.any? {|extc| extc.id == ex_.class._tc.id }
|
80
|
+
jsrvreq.set_exception(CORBA::Any.to_any(ex_).to_java(self._orb()))
|
81
|
+
else
|
82
|
+
STDERR.puts "#{ex_}\n#{ex_.backtrace.join("\n")}" unless $VERBOSE
|
83
|
+
if jsrvreq.respond_to?(:setSystemException) # JacORB special
|
84
|
+
jsrvreq.setSystemException(CORBA::Native::UNKNOWN.new("#{ex_}",0,CORBA::Native::CompletionStatus.from_int(CORBA::COMPLETED_MAYBE)))
|
85
|
+
else
|
86
|
+
jsrvreq.set_exception(CORBA::Any.to_any(CORBA::UNKNOWN.new("#{ex_}",0,CORBA::COMPLETED_MAYBE)).to_java(self._orb()))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
rescue CORBA::SystemException => ex_
|
90
|
+
STDERR.puts "#{ex_}\n#{ex_.backtrace.join("\n")}" if $VERBOSE
|
91
|
+
if jsrvreq.respond_to?(:setSystemException) # JacORB special
|
92
|
+
jex_klass = CORBA::Native.const_get(ex_.class::Name)
|
93
|
+
jsrvreq.setSystemException(jex_klass.new(ex_.reason, ex_.minor, CORBA::Native::CompletionStatus.from_int(ex_.completed)))
|
94
|
+
else
|
95
|
+
jsrvreq.set_exception(CORBA::Any.to_any(ex_).to_java(self._orb()))
|
96
|
+
end
|
97
|
+
rescue Exception => ex_
|
98
|
+
STDERR.puts "#{ex_}\n#{ex_.backtrace.join("\n")}"
|
99
|
+
if jsrvreq.respond_to?(:setSystemException) # JacORB special
|
100
|
+
jsrvreq.setSystemException(CORBA::Native::UNKNOWN.new("#{ex_}",0,CORBA::Native::CompletionStatus.from_int(CORBA::COMPLETED_MAYBE)))
|
101
|
+
else
|
102
|
+
jsrvreq.set_exception(CORBA::Any.to_any(CORBA::UNKNOWN.new("#{ex_}",0,CORBA::COMPLETED_MAYBE)).to_java(self._orb()))
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def _all_interfaces(poa, oid)
|
108
|
+
if @rsrv.nil?
|
109
|
+
return [].to_java(:string)
|
110
|
+
elsif @rsrv.respond_to?(:_ids)
|
111
|
+
return @rsrv._ids.to_java(:string)
|
112
|
+
elsif @rsrv.class.constants.any? {|c| c.to_sym == :Ids }
|
113
|
+
return @rsrv.class::Ids.to_java(:string)
|
114
|
+
elsif @rsrv.respond_to?(:_primary_interface)
|
115
|
+
return [@rsrv._primary_interface(oid, poa)].to_java(:string)
|
116
|
+
else
|
117
|
+
return [].to_java(:string)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def _is_a(repo_id)
|
122
|
+
if @rsrv.nil?
|
123
|
+
return false
|
124
|
+
elsif @rsrv.respond_to?('_is_a?'.to_sym)
|
125
|
+
return @rsrv._is_a?(repo_id)
|
126
|
+
else
|
127
|
+
begin
|
128
|
+
return @rsrv.class::Ids.include?(repo_id)
|
129
|
+
rescue
|
130
|
+
return super
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def _repository_id
|
136
|
+
if @rsrv.nil?
|
137
|
+
return ''
|
138
|
+
elsif @rsrv.respond_to?(:_repository_id)
|
139
|
+
return @rsrv._repository_id
|
140
|
+
else
|
141
|
+
return (@rsrv.class.const_get(:Id) rescue '')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def _non_existent()
|
146
|
+
if @rsrv.nil?
|
147
|
+
return true
|
148
|
+
elsif @rsrv.respond_to?(:_non_existent)
|
149
|
+
return @rsrv._non_existent
|
150
|
+
else
|
151
|
+
return super
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def _get_component()
|
156
|
+
if @rsrv.nil?
|
157
|
+
return nil
|
158
|
+
elsif @rsrv.respond_to?(:_get_component)
|
159
|
+
return @rsrv._get_component
|
160
|
+
else
|
161
|
+
return super
|
162
|
+
end
|
163
|
+
end
|
164
|
+
protected
|
165
|
+
def invoke_SI(rsrvreq)
|
166
|
+
opsym = rsrvreq.srvreq_.operation().to_sym
|
167
|
+
opsig = @rsrv.get_operation_signature(opsym)
|
168
|
+
# explicitly define empty (but not nil) exceptionlist if not yet specified
|
169
|
+
opsig[:exc_list] = [] if (Hash === opsig) && !opsig.has_key?(:exc_list)
|
170
|
+
rsrvreq.describe(opsig)
|
171
|
+
alt_opsym = opsig[:op_sym]
|
172
|
+
opsym = alt_opsym if alt_opsym && alt_opsym.is_a?(Symbol)
|
173
|
+
results = @rsrv.__send__(opsym, *rsrvreq.arguments)
|
174
|
+
unless rsrvreq.result_type_.nil?
|
175
|
+
result_value = (rsrvreq.arg_out_>0 ? results.shift : results) unless rsrvreq.result_type_.kind == CORBA::TK_VOID
|
176
|
+
if rsrvreq.arg_out_>0
|
177
|
+
rsrvreq.nvlist_.count().times do |i|
|
178
|
+
jnv = rsrvreq.nvlist_.item(i)
|
179
|
+
if [CORBA::ARG_OUT, CORBA::ARG_INOUT].include?(jnv.flags)
|
180
|
+
rval = results.shift
|
181
|
+
rtc = rsrvreq.arg_list_[i][2]
|
182
|
+
CORBA::Any.to_any(rval, rtc).to_java(self._orb(), jnv.value())
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
unless rsrvreq.result_type_.kind == CORBA::TK_VOID
|
187
|
+
rsrvreq.srvreq_.set_result(CORBA::Any.to_any(result_value, rsrvreq.result_type_).to_java(self._orb()))
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def invoke_DSI(rsrvreq)
|
193
|
+
results = @rsrv.invoke(rsrvreq)
|
194
|
+
unless rsrvreq.result_type_.nil?
|
195
|
+
result_value = (rsrvreq.arg_out_>0 ? results.shift : results) unless rsrvreq.result_type_.kind == CORBA::TK_VOID
|
196
|
+
if rsrvreq.arg_out_>0
|
197
|
+
rsrvreq.nvlist_.count().times do |i|
|
198
|
+
jnv = rsrvreq.nvlist_.item(i)
|
199
|
+
if [CORBA::ARG_OUT, CORBA::ARG_INOUT].include?(jnv.flags)
|
200
|
+
rval = results.shift
|
201
|
+
rtc = rsrvreq.arg_list_[i][2]
|
202
|
+
CORBA::Any.to_any(rval, rtc).to_java(self._orb(), jnv.value())
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
unless rsrvreq.result_type_.kind == CORBA::TK_VOID
|
207
|
+
rsrvreq.srvreq_.set_result(CORBA::Any.to_any(result_value, rsrvreq.result_type_).to_java(self._orb()))
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end # Servant
|
212
|
+
|
213
|
+
end # DSI
|
214
|
+
|
215
|
+
class Servant
|
216
|
+
def srvref_
|
217
|
+
@srvref_ ||= PortableServer::DSI::Servant.new_instance(self)
|
218
|
+
end
|
219
|
+
|
220
|
+
def _default_POA()
|
221
|
+
begin
|
222
|
+
return PortableServer::POA._narrow(CORBA::Object._wrap_native(self.srvref_._default_POA()))
|
223
|
+
rescue ::NativeException
|
224
|
+
CORBA::Exception.native2r($!)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def _this()
|
229
|
+
unless @srvref_.nil?
|
230
|
+
begin
|
231
|
+
return CORBA::Object._wrap_native(self.srvref_._this_object())
|
232
|
+
rescue NativeException
|
233
|
+
# not in call context or not associated with ORB yet
|
234
|
+
end
|
235
|
+
end
|
236
|
+
raise CORBA::BAD_INV_ORDER.new('no ORB initialized',0,CORBA::COMPLETED_NO) if CORBA::ORB._orb.nil?
|
237
|
+
begin
|
238
|
+
return CORBA::Object._wrap_native(self.srvref_._this_object(CORBA::ORB._orb))
|
239
|
+
rescue ::NativeException
|
240
|
+
CORBA::Exception.native2r($!)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end # Servant
|
244
|
+
|
245
|
+
end # PortableServer
|
246
|
+
|
247
|
+
end # R2CORBA
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# ServerRequest.rb - R2TAO CORBA ServerRequest support
|
3
|
+
#
|
4
|
+
# Author: Martin Corino
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the R2CORBA LICENSE which is
|
8
|
+
# included with this program.
|
9
|
+
#
|
10
|
+
# Copyright (c) Remedy IT Expertise BV
|
11
|
+
# Chamber of commerce Rotterdam nr.276339, The Netherlands
|
12
|
+
#--------------------------------------------------------------------
|
13
|
+
|
14
|
+
module R2CORBA
|
15
|
+
|
16
|
+
module CORBA
|
17
|
+
|
18
|
+
module ServerRequest
|
19
|
+
@@wrapper_klass = Class.new do
|
20
|
+
include CORBA::ServerRequest
|
21
|
+
def initialize(jsrvreq, jorb)
|
22
|
+
@srvreq_ = jsrvreq
|
23
|
+
@orb_ = jorb
|
24
|
+
@nvlist_ = nil
|
25
|
+
@result_type_ = nil
|
26
|
+
@arg_list_ = nil
|
27
|
+
@exc_list_ = nil
|
28
|
+
@arg_ = nil
|
29
|
+
@arg_index_ = nil
|
30
|
+
@arg_out_ = 0
|
31
|
+
end
|
32
|
+
attr_reader :srvreq_
|
33
|
+
attr_reader :orb_
|
34
|
+
attr_reader :arg_list_
|
35
|
+
attr_reader :result_type_
|
36
|
+
attr_reader :exc_list_
|
37
|
+
attr_reader :nvlist_
|
38
|
+
attr_reader :arg_out_
|
39
|
+
end
|
40
|
+
|
41
|
+
def self._wrap_native(jsrvreq, jorb)
|
42
|
+
raise ArgumentError, 'Expected org.omg.CORBA.ServerRequest' unless jsrvreq.is_a?(Native::ServerRequest)
|
43
|
+
raise ArgumentError, 'Expected org.omg.CORBA.ORB' unless jorb.is_a?(Native::ORB)
|
44
|
+
@@wrapper_klass.new(jsrvreq, jorb)
|
45
|
+
end
|
46
|
+
|
47
|
+
def operation
|
48
|
+
begin
|
49
|
+
self.srvreq_.operation
|
50
|
+
rescue ::NativeException
|
51
|
+
CORBA::Exception.native2r($!)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def describe(opsig)
|
56
|
+
raise CORBA::BAD_INV_ORDER.new('',0,CORBA::COMPLETED_NO) if @nvlist_
|
57
|
+
raise CORBA::NO_IMPLEMENT.new('',0,CORBA::COMPLETED_NO) unless opsig && (Hash === opsig)
|
58
|
+
@arg_list_ = opsig[:arg_list]
|
59
|
+
@result_type_ = opsig[:result_type]
|
60
|
+
@exc_list_ = opsig[:exc_list]
|
61
|
+
raise CORBA::BAD_PARAM.new('',0,CORBA::COMPLETED_NO) unless (@arg_list_.nil? || @arg_list_.is_a?(Array)) &&
|
62
|
+
(@result_type_.nil? || @result_type_.is_a?(CORBA::TypeCode)) &&
|
63
|
+
(@exc_list_.nil? || @exc_list_.is_a?(Array))
|
64
|
+
@nvlist_ = extract_arguments_(@arg_list_)
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
def arguments
|
69
|
+
raise CORBA::BAD_INV_ORDER.new('',0,CORBA::COMPLETED_NO) unless @nvlist_
|
70
|
+
unless @arg_
|
71
|
+
@arg_ = []
|
72
|
+
@nvlist_.count().times do |i|
|
73
|
+
jnv = @nvlist_.item(i)
|
74
|
+
@arg_ << CORBA::Any.from_java(jnv.value, self.orb_, @arg_list_[i][2]) if [CORBA::ARG_IN, CORBA::ARG_INOUT].include?(jnv.flags)
|
75
|
+
@arg_out_ += 1 if [CORBA::ARG_OUT, CORBA::ARG_INOUT].include?(jnv.flags)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
@arg_
|
79
|
+
end
|
80
|
+
|
81
|
+
def [](key)
|
82
|
+
self.arguments # make sure the @arg_ member has been initialized
|
83
|
+
key = arg_index_from_name(key) if String === key
|
84
|
+
key = key.to_i if key
|
85
|
+
raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETD_NO) unless key && (key>=0) && (key<@arg_.size)
|
86
|
+
@arg_[key]
|
87
|
+
end
|
88
|
+
|
89
|
+
def []=(key, val)
|
90
|
+
self.arguments # make sure the @arg_ member has been initialized
|
91
|
+
key = arg_index_from_name(key) if String === key
|
92
|
+
key = key.to_i if key
|
93
|
+
raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETD_NO) unless key && (key>=0) && (key<@arg_.size)
|
94
|
+
jnv = @nvlist_.item(key)
|
95
|
+
rtc = @arg_list_[key][2]
|
96
|
+
CORBA::Any.to_any(val, rtc).to_java(self.orb_, jnv.value())
|
97
|
+
@arg_[key] = val
|
98
|
+
end
|
99
|
+
|
100
|
+
protected
|
101
|
+
def arg_index_from_name(arg_name)
|
102
|
+
unless @arg_index_
|
103
|
+
@arg_index_ = {}
|
104
|
+
@nvlist_.count().times do |i|
|
105
|
+
jnv = @nvlist_.item(i)
|
106
|
+
@arg_index_[jnv.name] = i
|
107
|
+
end
|
108
|
+
end
|
109
|
+
@arg_index_[arg_name]
|
110
|
+
end
|
111
|
+
|
112
|
+
def extract_arguments_(arg_list)
|
113
|
+
jnvlist = self.orb_.create_list(0)
|
114
|
+
unless arg_list.nil?
|
115
|
+
arg_list.each do |argnm, argf, argtc|
|
116
|
+
raise CORBA::BAD_PARAM.new('', 0, CORBA::COMPLETED_NO) if argf.nil? || argtc.nil? || !argtc.is_a?(CORBA::TypeCode)
|
117
|
+
jnvlist.add_value(argnm.to_s, Any.to_any(nil,argtc).to_java(@orb_), argf.to_i)
|
118
|
+
end
|
119
|
+
self.srvreq_.arguments(jnvlist)
|
120
|
+
end
|
121
|
+
jnvlist
|
122
|
+
end
|
123
|
+
|
124
|
+
end # ServerRequest
|
125
|
+
|
126
|
+
end # CORBA
|
127
|
+
|
128
|
+
end # R2CORBA
|