r2corba 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +159 -0
  3. data/LICENSE +59 -0
  4. data/README +62 -0
  5. data/THANKS +52 -0
  6. data/bin/r2corba +8 -0
  7. data/bin/ridlc +11 -0
  8. data/bin/rins +7 -0
  9. data/ext/ext.mwc +6 -0
  10. data/ext/extload/extload.c +60 -0
  11. data/ext/libr2tao/any.cpp +1543 -0
  12. data/ext/libr2tao/exception.cpp +202 -0
  13. data/ext/libr2tao/exception.h +104 -0
  14. data/ext/libr2tao/longdouble.cpp +173 -0
  15. data/ext/libr2tao/longdouble.h +31 -0
  16. data/ext/libr2tao/object.cpp +1150 -0
  17. data/ext/libr2tao/object.h +38 -0
  18. data/ext/libr2tao/orb.cpp +1029 -0
  19. data/ext/libr2tao/orb.h +36 -0
  20. data/ext/libr2tao/r2tao_export.h +45 -0
  21. data/ext/libr2tao/r2tao_ext.h +38 -0
  22. data/ext/libr2tao/required.cpp +463 -0
  23. data/ext/libr2tao/required.h +187 -0
  24. data/ext/libr2tao/typecode.cpp +888 -0
  25. data/ext/libr2tao/typecode.h +45 -0
  26. data/ext/libr2tao/values.cpp +2938 -0
  27. data/ext/libr2tao/values.h +396 -0
  28. data/ext/librpoa/iortable.cpp +250 -0
  29. data/ext/librpoa/poa.cpp +1076 -0
  30. data/ext/librpoa/poa.h +24 -0
  31. data/ext/librpoa/rpoa_export.h +44 -0
  32. data/ext/librpoa/servant.cpp +1338 -0
  33. data/ext/librpoa/servant.h +116 -0
  34. data/ext/librpoa/srvreq_fix.cpp +283 -0
  35. data/ext/librpoa/srvreq_fix.h +149 -0
  36. data/ext/librpol/policies.cpp +763 -0
  37. data/ext/librpol/policies.h +15 -0
  38. data/ext/librpol/rpol_export.h +44 -0
  39. data/lib/corba/cbase/IORMap.rb +33 -0
  40. data/lib/corba/cbase/ORB.rb +231 -0
  41. data/lib/corba/cbase/Request.rb +134 -0
  42. data/lib/corba/cbase/Streams.rb +129 -0
  43. data/lib/corba/cbase/Stub.rb +19 -0
  44. data/lib/corba/cbase/Typecode.rb +441 -0
  45. data/lib/corba/cbase/Values.rb +129 -0
  46. data/lib/corba/cbase/exception.rb +66 -0
  47. data/lib/corba/cbase/poa.rb +23 -0
  48. data/lib/corba/cbase/policies.rb +78 -0
  49. data/lib/corba/cbase/post_require.rb +14 -0
  50. data/lib/corba/cbase/require.rb +28 -0
  51. data/lib/corba/cmds/base.rb +85 -0
  52. data/lib/corba/cmds/test.rb +30 -0
  53. data/lib/corba/common/Any.rb +91 -0
  54. data/lib/corba/common/IDL.rb +104 -0
  55. data/lib/corba/common/ORB.rb +368 -0
  56. data/lib/corba/common/Object.rb +208 -0
  57. data/lib/corba/common/Request.rb +20 -0
  58. data/lib/corba/common/Servant.rb +108 -0
  59. data/lib/corba/common/Struct.rb +22 -0
  60. data/lib/corba/common/Stub.rb +79 -0
  61. data/lib/corba/common/Typecode.rb +1121 -0
  62. data/lib/corba/common/Union.rb +56 -0
  63. data/lib/corba/common/Values.rb +92 -0
  64. data/lib/corba/common/const.rb +22 -0
  65. data/lib/corba/common/exception.rb +68 -0
  66. data/lib/corba/common/require.rb +27 -0
  67. data/lib/corba/common/version.rb +22 -0
  68. data/lib/corba/idl/IDL.rb +21 -0
  69. data/lib/corba/idl/IORTable.pidl +62 -0
  70. data/lib/corba/idl/TAO_Ext.pidl +46 -0
  71. data/lib/corba/idl/require.rb +20 -0
  72. data/lib/corba/jbase/Any.rb +273 -0
  73. data/lib/corba/jbase/IORMap.rb +36 -0
  74. data/lib/corba/jbase/ORB.rb +99 -0
  75. data/lib/corba/jbase/Object.rb +98 -0
  76. data/lib/corba/jbase/Request.rb +226 -0
  77. data/lib/corba/jbase/Servant.rb +247 -0
  78. data/lib/corba/jbase/ServerRequest.rb +128 -0
  79. data/lib/corba/jbase/Streams.rb +671 -0
  80. data/lib/corba/jbase/Stub.rb +38 -0
  81. data/lib/corba/jbase/Typecode.rb +520 -0
  82. data/lib/corba/jbase/Values.rb +173 -0
  83. data/lib/corba/jbase/exception.rb +106 -0
  84. data/lib/corba/jbase/poa.rb +229 -0
  85. data/lib/corba/jbase/policies.rb +300 -0
  86. data/lib/corba/jbase/post_require.rb +14 -0
  87. data/lib/corba/jbase/require.rb +86 -0
  88. data/lib/corba/naming.rb +14 -0
  89. data/lib/corba/naming_service.rb +15 -0
  90. data/lib/corba/poa.rb +15 -0
  91. data/lib/corba/policies.rb +18 -0
  92. data/lib/corba/require.rb +17 -0
  93. data/lib/corba/svcs/ins/cos_naming.rb +426 -0
  94. data/lib/corba/svcs/ins/ins.rb +526 -0
  95. data/lib/corba/svcs/ins/naming_service.rb +119 -0
  96. data/lib/corba.rb +16 -0
  97. data/lib/ridlbe/ruby/config.rb +336 -0
  98. data/lib/ridlbe/ruby/require.rb +16 -0
  99. data/lib/ridlbe/ruby/walker.rb +1582 -0
  100. data/mkrf_conf_srcgem.rb +186 -0
  101. data/rakelib/bin.rake +80 -0
  102. data/rakelib/bin.rb +146 -0
  103. data/rakelib/build.rake +87 -0
  104. data/rakelib/config.rake +52 -0
  105. data/rakelib/config.rb +450 -0
  106. data/rakelib/ext.rake +242 -0
  107. data/rakelib/ext.rb +308 -0
  108. data/rakelib/ext_r2tao.rb +232 -0
  109. data/rakelib/gem.rake +212 -0
  110. data/rakelib/gem.rb +146 -0
  111. data/rakelib/package.rake +26 -0
  112. data/rakelib/test.rake +23 -0
  113. data/test/BiDirectional/Test.idl +34 -0
  114. data/test/BiDirectional/client.rb +132 -0
  115. data/test/BiDirectional/run_test.rb +68 -0
  116. data/test/BiDirectional/server.rb +169 -0
  117. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -0
  118. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -0
  119. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -0
  120. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -0
  121. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -0
  122. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -0
  123. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -0
  124. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -0
  125. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -0
  126. data/test/CORBA_Services/Naming/Simple/client.rb +84 -0
  127. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -0
  128. data/test/CORBA_Services/Naming/Simple/server.rb +109 -0
  129. data/test/Collocation/Diamond.idl +39 -0
  130. data/test/Collocation/run_test.rb +52 -0
  131. data/test/Collocation/test.rb +195 -0
  132. data/test/Connect_Timeout/Test.idl +27 -0
  133. data/test/Connect_Timeout/client.rb +111 -0
  134. data/test/Connect_Timeout/run_test.rb +52 -0
  135. data/test/DII/Test.idl +27 -0
  136. data/test/DII/client.rb +115 -0
  137. data/test/DII/run_test.rb +69 -0
  138. data/test/DII/server.rb +95 -0
  139. data/test/DSI/Test.idl +27 -0
  140. data/test/DSI/client.rb +66 -0
  141. data/test/DSI/run_test.rb +69 -0
  142. data/test/DSI/server.rb +106 -0
  143. data/test/Exceptions/Test.idl +48 -0
  144. data/test/Exceptions/client.rb +118 -0
  145. data/test/Exceptions/run_test.rb +69 -0
  146. data/test/Exceptions/server.rb +131 -0
  147. data/test/Hello/Test.idl +27 -0
  148. data/test/Hello/client.rb +78 -0
  149. data/test/Hello/run_test.rb +71 -0
  150. data/test/Hello/server.rb +95 -0
  151. data/test/IDL_Test/Test.idl +113 -0
  152. data/test/IDL_Test/Test_inc.idl +17 -0
  153. data/test/IDL_Test/client.rb +102 -0
  154. data/test/IDL_Test/run_test.rb +69 -0
  155. data/test/IDL_Test/server.rb +99 -0
  156. data/test/IORMap/Test.idl +27 -0
  157. data/test/IORMap/client.rb +73 -0
  158. data/test/IORMap/run_test.rb +69 -0
  159. data/test/IORMap/server.rb +114 -0
  160. data/test/IORTable/Test.idl +27 -0
  161. data/test/IORTable/client.rb +75 -0
  162. data/test/IORTable/run_test.rb +69 -0
  163. data/test/IORTable/server.rb +130 -0
  164. data/test/Implicit_Conversion/Test.idl +31 -0
  165. data/test/Implicit_Conversion/client.rb +110 -0
  166. data/test/Implicit_Conversion/run_test.rb +69 -0
  167. data/test/Implicit_Conversion/server.rb +99 -0
  168. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -0
  169. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -0
  170. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -0
  171. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -0
  172. data/test/Multi_Threading/Simple/Test.idl +27 -0
  173. data/test/Multi_Threading/Simple/client.rb +88 -0
  174. data/test/Multi_Threading/Simple/run_test.rb +69 -0
  175. data/test/Multi_Threading/Simple/server.rb +118 -0
  176. data/test/Multi_Threading/Threads/Test.idl +31 -0
  177. data/test/Multi_Threading/Threads/client.rb +80 -0
  178. data/test/Multi_Threading/Threads/run_test.rb +76 -0
  179. data/test/Multi_Threading/Threads/server.rb +119 -0
  180. data/test/Multi_Threading/Threads/watchdog.rb +87 -0
  181. data/test/Multiple_Servant_Interfaces/Test.idl +34 -0
  182. data/test/Multiple_Servant_Interfaces/client.rb +70 -0
  183. data/test/Multiple_Servant_Interfaces/run_test.rb +69 -0
  184. data/test/Multiple_Servant_Interfaces/server.rb +102 -0
  185. data/test/Nil/Test.idl +27 -0
  186. data/test/Nil/run_test.rb +52 -0
  187. data/test/Nil/test.rb +78 -0
  188. data/test/OBV/AbstractInterface/client.rb +179 -0
  189. data/test/OBV/AbstractInterface/run_test.rb +69 -0
  190. data/test/OBV/AbstractInterface/server.rb +149 -0
  191. data/test/OBV/AbstractInterface/test.idl +53 -0
  192. data/test/OBV/Custom/OBV.idl +18 -0
  193. data/test/OBV/Custom/OBV_impl.rb +40 -0
  194. data/test/OBV/Custom/client.rb +86 -0
  195. data/test/OBV/Custom/run_test.rb +69 -0
  196. data/test/OBV/Custom/server.rb +100 -0
  197. data/test/OBV/Simple/OBV.idl +15 -0
  198. data/test/OBV/Simple/OBV_impl.rb +26 -0
  199. data/test/OBV/Simple/client.rb +86 -0
  200. data/test/OBV/Simple/run_test.rb +69 -0
  201. data/test/OBV/Simple/server.rb +100 -0
  202. data/test/OBV/Simple_Event/Event.idl +15 -0
  203. data/test/OBV/Simple_Event/Event_impl.rb +26 -0
  204. data/test/OBV/Simple_Event/client.rb +86 -0
  205. data/test/OBV/Simple_Event/run_test.rb +69 -0
  206. data/test/OBV/Simple_Event/server.rb +100 -0
  207. data/test/OBV/Supports/client.rb +116 -0
  208. data/test/OBV/Supports/run_test.rb +69 -0
  209. data/test/OBV/Supports/server.rb +103 -0
  210. data/test/OBV/Supports/supports.idl +33 -0
  211. data/test/OBV/Supports/supports_impl.rb +57 -0
  212. data/test/OBV/Tree/client.rb +116 -0
  213. data/test/OBV/Tree/run_test.rb +69 -0
  214. data/test/OBV/Tree/server.rb +117 -0
  215. data/test/OBV/Tree/test.idl +32 -0
  216. data/test/OBV/Truncatable/Extra.idl +27 -0
  217. data/test/OBV/Truncatable/Truncatable.idl +105 -0
  218. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -0
  219. data/test/OBV/Truncatable/client.rb +279 -0
  220. data/test/OBV/Truncatable/run_test.rb +69 -0
  221. data/test/OBV/Truncatable/server.rb +89 -0
  222. data/test/OBV/ValueBox/client.rb +497 -0
  223. data/test/OBV/ValueBox/run_test.rb +69 -0
  224. data/test/OBV/ValueBox/server.rb +271 -0
  225. data/test/OBV/ValueBox/valuebox.idl +101 -0
  226. data/test/OBV/ValueBox/vb_basic.idl +75 -0
  227. data/test/OBV/ValueBox/vb_struct.idl +68 -0
  228. data/test/OBV/ValueBox/vb_union.idl +21 -0
  229. data/test/Object/Test.idl +27 -0
  230. data/test/Object/client.rb +103 -0
  231. data/test/Object/run_test.rb +69 -0
  232. data/test/Object/server.rb +126 -0
  233. data/test/POA/Test.idl +27 -0
  234. data/test/POA/run_test.rb +52 -0
  235. data/test/POA/test.rb +112 -0
  236. data/test/Param_Test/Test.idl +182 -0
  237. data/test/Param_Test/client.rb +277 -0
  238. data/test/Param_Test/run_test.rb +69 -0
  239. data/test/Param_Test/server.rb +296 -0
  240. data/test/Performance/Simple/Test.idl +27 -0
  241. data/test/Performance/Simple/client.rb +90 -0
  242. data/test/Performance/Simple/run_test.rb +69 -0
  243. data/test/Performance/Simple/server.rb +95 -0
  244. data/test/Policies/Test.idl +27 -0
  245. data/test/Policies/run_test.rb +52 -0
  246. data/test/Policies/test.rb +144 -0
  247. data/test/Timeout/client.rb +207 -0
  248. data/test/Timeout/run_test.rb +69 -0
  249. data/test/Timeout/server.rb +109 -0
  250. data/test/Timeout/test.idl +19 -0
  251. data/test/lib/assert.rb +43 -0
  252. data/test/lib/test.rb +542 -0
  253. data/test/test_runner.rb +193 -0
  254. 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