r2corba 1.4.1-x86-mingw32 → 1.5.1-x86-mingw32

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 -7
  2. data/CHANGES +173 -159
  3. data/LICENSE +59 -59
  4. data/README +62 -62
  5. data/THANKS +54 -52
  6. data/bin/r2corba +1 -1
  7. data/bin/ridlc +1 -1
  8. data/bin/rins +1 -1
  9. data/lib/corba.rb +16 -16
  10. data/lib/corba/cbase/IORMap.rb +33 -33
  11. data/lib/corba/cbase/ORB.rb +237 -231
  12. data/lib/corba/cbase/Request.rb +133 -133
  13. data/lib/corba/cbase/Streams.rb +129 -129
  14. data/lib/corba/cbase/Stub.rb +19 -19
  15. data/lib/corba/cbase/Typecode.rb +441 -441
  16. data/lib/corba/cbase/Values.rb +129 -129
  17. data/lib/corba/cbase/exception.rb +66 -66
  18. data/lib/corba/cbase/poa.rb +23 -23
  19. data/lib/corba/cbase/policies.rb +77 -77
  20. data/lib/corba/cbase/post_require.rb +13 -13
  21. data/lib/corba/cbase/require.rb +28 -28
  22. data/lib/corba/cmds/base.rb +85 -85
  23. data/lib/corba/cmds/test.rb +30 -30
  24. data/lib/corba/common/Any.rb +91 -91
  25. data/lib/corba/common/IDL.rb +104 -104
  26. data/lib/corba/common/ORB.rb +368 -368
  27. data/lib/corba/common/Object.rb +208 -208
  28. data/lib/corba/common/Request.rb +19 -19
  29. data/lib/corba/common/Servant.rb +108 -108
  30. data/lib/corba/common/Struct.rb +21 -21
  31. data/lib/corba/common/Stub.rb +79 -79
  32. data/lib/corba/common/Typecode.rb +1121 -1121
  33. data/lib/corba/common/Union.rb +55 -55
  34. data/lib/corba/common/Values.rb +91 -91
  35. data/lib/corba/common/const.rb +22 -22
  36. data/lib/corba/common/exception.rb +68 -68
  37. data/lib/corba/common/require.rb +27 -27
  38. data/lib/corba/common/version.rb +22 -22
  39. data/lib/corba/idl/IDL.rb +21 -21
  40. data/lib/corba/idl/IORTable.pidl +62 -62
  41. data/lib/corba/idl/TAO_Ext.pidl +46 -46
  42. data/lib/corba/idl/require.rb +20 -20
  43. data/lib/corba/jbase/Any.rb +273 -273
  44. data/lib/corba/jbase/IORMap.rb +35 -35
  45. data/lib/corba/jbase/ORB.rb +112 -99
  46. data/lib/corba/jbase/Object.rb +99 -98
  47. data/lib/corba/jbase/Request.rb +225 -225
  48. data/lib/corba/jbase/Servant.rb +247 -246
  49. data/lib/corba/jbase/ServerRequest.rb +127 -127
  50. data/lib/corba/jbase/Streams.rb +670 -670
  51. data/lib/corba/jbase/Stub.rb +38 -38
  52. data/lib/corba/jbase/Typecode.rb +520 -520
  53. data/lib/corba/jbase/Values.rb +173 -173
  54. data/lib/corba/jbase/exception.rb +106 -106
  55. data/lib/corba/jbase/poa.rb +228 -228
  56. data/lib/corba/jbase/policies.rb +299 -299
  57. data/lib/corba/jbase/post_require.rb +14 -14
  58. data/lib/corba/jbase/require.rb +89 -86
  59. data/lib/corba/naming.rb +14 -14
  60. data/lib/corba/naming_service.rb +15 -15
  61. data/lib/corba/poa.rb +15 -15
  62. data/lib/corba/policies.rb +18 -18
  63. data/lib/corba/require.rb +17 -17
  64. data/lib/corba/svcs/ins/cos_naming.rb +426 -426
  65. data/lib/corba/svcs/ins/ins.rb +526 -526
  66. data/lib/corba/svcs/ins/naming_service.rb +119 -119
  67. data/lib/ridlbe/ruby/config.rb +336 -336
  68. data/lib/ridlbe/ruby/orb.pidlc +0 -0
  69. data/lib/ridlbe/ruby/require.rb +16 -16
  70. data/lib/ridlbe/ruby/walker.rb +1582 -1582
  71. data/mkrf_conf_bingem.rb +151 -101
  72. data/rakelib/bin.rake +80 -80
  73. data/rakelib/bin.rb +145 -145
  74. data/rakelib/build.rake +87 -87
  75. data/rakelib/config.rake +51 -51
  76. data/rakelib/config.rb +543 -449
  77. data/rakelib/ext.rake +242 -242
  78. data/rakelib/ext.rb +316 -308
  79. data/rakelib/ext_r2tao.rb +235 -232
  80. data/rakelib/gem.rake +235 -211
  81. data/rakelib/gem.rb +145 -145
  82. data/rakelib/package.rake +26 -26
  83. data/rakelib/test.rake +23 -23
  84. data/test/BiDirectional/Test.idl +34 -34
  85. data/test/BiDirectional/client.rb +131 -131
  86. data/test/BiDirectional/run_test.rb +68 -68
  87. data/test/BiDirectional/server.ior +1 -1
  88. data/test/BiDirectional/server.rb +169 -169
  89. data/test/CORBA_Services/Naming/BindingIterator/Test.idl +27 -27
  90. data/test/CORBA_Services/Naming/BindingIterator/client.rb +121 -121
  91. data/test/CORBA_Services/Naming/BindingIterator/ins.ior +1 -1
  92. data/test/CORBA_Services/Naming/BindingIterator/run_test.rb +82 -82
  93. data/test/CORBA_Services/Naming/BindingIterator/server.rb +109 -109
  94. data/test/CORBA_Services/Naming/Corbaname/Test.idl +27 -27
  95. data/test/CORBA_Services/Naming/Corbaname/client.rb +85 -85
  96. data/test/CORBA_Services/Naming/Corbaname/ins.ior +1 -1
  97. data/test/CORBA_Services/Naming/Corbaname/run_test.rb +88 -88
  98. data/test/CORBA_Services/Naming/Corbaname/server.rb +135 -135
  99. data/test/CORBA_Services/Naming/Simple/Test.idl +27 -27
  100. data/test/CORBA_Services/Naming/Simple/client.rb +84 -84
  101. data/test/CORBA_Services/Naming/Simple/ins.ior +1 -1
  102. data/test/CORBA_Services/Naming/Simple/run_test.rb +82 -82
  103. data/test/CORBA_Services/Naming/Simple/server.rb +109 -109
  104. data/test/Collocation/Diamond.idl +39 -39
  105. data/test/Collocation/run_test.rb +52 -52
  106. data/test/Collocation/test.rb +195 -195
  107. data/test/Connect_Timeout/Test.idl +27 -27
  108. data/test/Connect_Timeout/client.rb +111 -111
  109. data/test/Connect_Timeout/run_test.rb +52 -52
  110. data/test/DII/Test.idl +27 -27
  111. data/test/DII/client.rb +115 -115
  112. data/test/DII/run_test.rb +69 -69
  113. data/test/DII/server.ior +1 -1
  114. data/test/DII/server.rb +95 -95
  115. data/test/DSI/Test.idl +27 -27
  116. data/test/DSI/client.rb +66 -66
  117. data/test/DSI/run_test.rb +69 -69
  118. data/test/DSI/server.ior +1 -1
  119. data/test/DSI/server.rb +106 -106
  120. data/test/Exceptions/Test.idl +48 -48
  121. data/test/Exceptions/client.rb +117 -117
  122. data/test/Exceptions/run_test.rb +69 -69
  123. data/test/Exceptions/server.ior +1 -1
  124. data/test/Exceptions/server.rb +131 -131
  125. data/test/Hello/Test.idl +27 -27
  126. data/test/Hello/client.rb +78 -78
  127. data/test/Hello/run_test.rb +71 -71
  128. data/test/Hello/server.rb +95 -95
  129. data/test/IDL_Test/Test.idl +113 -113
  130. data/test/IDL_Test/Test_inc.idl +17 -17
  131. data/test/IDL_Test/client.rb +102 -102
  132. data/test/IDL_Test/run_test.rb +69 -69
  133. data/test/IDL_Test/server.ior +1 -1
  134. data/test/IDL_Test/server.rb +99 -99
  135. data/test/IORMap/Test.idl +27 -27
  136. data/test/IORMap/client.rb +73 -73
  137. data/test/IORMap/run_test.rb +69 -69
  138. data/test/IORMap/server.ior +1 -1
  139. data/test/IORMap/server.rb +114 -114
  140. data/test/IORTable/Test.idl +27 -27
  141. data/test/IORTable/client.rb +75 -75
  142. data/test/IORTable/run_test.rb +69 -69
  143. data/test/IORTable/server.ior +1 -1
  144. data/test/IORTable/server.rb +130 -130
  145. data/test/Implicit_Conversion/Test.idl +31 -31
  146. data/test/Implicit_Conversion/client.rb +110 -110
  147. data/test/Implicit_Conversion/run_test.rb +69 -69
  148. data/test/Implicit_Conversion/server.ior +1 -1
  149. data/test/Implicit_Conversion/server.rb +99 -99
  150. data/test/Multi_Threading/Multiple_ORB/Test.idl +27 -27
  151. data/test/Multi_Threading/Multiple_ORB/client.rb +82 -82
  152. data/test/Multi_Threading/Multiple_ORB/run_test.rb +71 -71
  153. data/test/Multi_Threading/Multiple_ORB/server.rb +108 -108
  154. data/test/Multi_Threading/Multiple_ORB/server0.ior +1 -1
  155. data/test/Multi_Threading/Multiple_ORB/server1.ior +1 -1
  156. data/test/Multi_Threading/Simple/Test.idl +27 -27
  157. data/test/Multi_Threading/Simple/client.rb +93 -88
  158. data/test/Multi_Threading/Simple/run_test.rb +69 -69
  159. data/test/Multi_Threading/Simple/server.ior +1 -1
  160. data/test/Multi_Threading/Simple/server.rb +117 -117
  161. data/test/Multi_Threading/Threads/Test.idl +31 -31
  162. data/test/Multi_Threading/Threads/client.rb +80 -80
  163. data/test/Multi_Threading/Threads/run_test.rb +76 -76
  164. data/test/Multi_Threading/Threads/server.ior +1 -1
  165. data/test/Multi_Threading/Threads/server.rb +119 -119
  166. data/test/Multi_Threading/Threads/watchdog.ior +1 -1
  167. data/test/Multi_Threading/Threads/watchdog.rb +87 -87
  168. data/test/Multiple_Servant_Interfaces/Test.idl +34 -34
  169. data/test/Multiple_Servant_Interfaces/client.rb +70 -70
  170. data/test/Multiple_Servant_Interfaces/run_test.rb +69 -69
  171. data/test/Multiple_Servant_Interfaces/server.ior +1 -1
  172. data/test/Multiple_Servant_Interfaces/server.rb +102 -102
  173. data/test/Nil/Test.idl +27 -27
  174. data/test/Nil/run_test.rb +52 -52
  175. data/test/Nil/test.rb +78 -78
  176. data/test/OBV/AbstractInterface/client.rb +179 -179
  177. data/test/OBV/AbstractInterface/run_test.rb +69 -69
  178. data/test/OBV/AbstractInterface/server.ior +1 -1
  179. data/test/OBV/AbstractInterface/server.rb +149 -149
  180. data/test/OBV/AbstractInterface/test.idl +53 -53
  181. data/test/OBV/Custom/OBV.idl +18 -18
  182. data/test/OBV/Custom/OBV_impl.rb +40 -40
  183. data/test/OBV/Custom/client.rb +86 -86
  184. data/test/OBV/Custom/run_test.rb +69 -69
  185. data/test/OBV/Custom/server.ior +1 -1
  186. data/test/OBV/Custom/server.rb +100 -100
  187. data/test/OBV/Simple/OBV.idl +15 -15
  188. data/test/OBV/Simple/OBV_impl.rb +26 -26
  189. data/test/OBV/Simple/client.rb +86 -86
  190. data/test/OBV/Simple/run_test.rb +69 -69
  191. data/test/OBV/Simple/server.ior +1 -1
  192. data/test/OBV/Simple/server.rb +100 -100
  193. data/test/OBV/Simple_Event/Event.idl +15 -15
  194. data/test/OBV/Simple_Event/Event_impl.rb +26 -26
  195. data/test/OBV/Simple_Event/client.rb +86 -86
  196. data/test/OBV/Simple_Event/run_test.rb +69 -69
  197. data/test/OBV/Simple_Event/server.ior +1 -1
  198. data/test/OBV/Simple_Event/server.rb +100 -100
  199. data/test/OBV/Supports/client.rb +116 -116
  200. data/test/OBV/Supports/run_test.rb +69 -69
  201. data/test/OBV/Supports/server.ior +1 -1
  202. data/test/OBV/Supports/server.rb +103 -103
  203. data/test/OBV/Supports/supports.idl +33 -33
  204. data/test/OBV/Supports/supports_impl.rb +57 -57
  205. data/test/OBV/Tree/client.rb +116 -116
  206. data/test/OBV/Tree/run_test.rb +69 -69
  207. data/test/OBV/Tree/server.ior +1 -1
  208. data/test/OBV/Tree/server.rb +117 -117
  209. data/test/OBV/Tree/test.idl +32 -32
  210. data/test/OBV/Truncatable/Extra.idl +27 -27
  211. data/test/OBV/Truncatable/Truncatable.idl +105 -105
  212. data/test/OBV/Truncatable/Truncatable_impl.rb +86 -86
  213. data/test/OBV/Truncatable/client.rb +279 -279
  214. data/test/OBV/Truncatable/run_test.rb +69 -69
  215. data/test/OBV/Truncatable/server.ior +1 -1
  216. data/test/OBV/Truncatable/server.rb +89 -89
  217. data/test/OBV/ValueBox/client.rb +497 -497
  218. data/test/OBV/ValueBox/run_test.rb +69 -69
  219. data/test/OBV/ValueBox/server.ior +1 -1
  220. data/test/OBV/ValueBox/server.rb +271 -271
  221. data/test/OBV/ValueBox/valuebox.idl +101 -101
  222. data/test/OBV/ValueBox/vb_basic.idl +75 -75
  223. data/test/OBV/ValueBox/vb_struct.idl +68 -68
  224. data/test/OBV/ValueBox/vb_union.idl +21 -21
  225. data/test/Object/Test.idl +27 -27
  226. data/test/Object/client.rb +112 -103
  227. data/test/Object/run_test.rb +69 -69
  228. data/test/Object/server.ior +1 -1
  229. data/test/Object/server.rb +126 -126
  230. data/test/POA/Test.idl +27 -27
  231. data/test/POA/run_test.rb +52 -52
  232. data/test/POA/test.rb +111 -111
  233. data/test/Param_Test/Test.idl +182 -182
  234. data/test/Param_Test/client.rb +277 -277
  235. data/test/Param_Test/run_test.rb +69 -69
  236. data/test/Param_Test/server.ior +1 -1
  237. data/test/Param_Test/server.rb +296 -296
  238. data/test/Performance/Simple/Test.idl +27 -27
  239. data/test/Performance/Simple/client.rb +90 -90
  240. data/test/Performance/Simple/run_test.rb +69 -69
  241. data/test/Performance/Simple/server.ior +1 -1
  242. data/test/Performance/Simple/server.rb +95 -95
  243. data/test/Policies/Test.idl +27 -27
  244. data/test/Policies/run_test.rb +52 -52
  245. data/test/Policies/test.rb +144 -144
  246. data/test/Timeout/client.rb +207 -207
  247. data/test/Timeout/run_test.rb +69 -69
  248. data/test/Timeout/server.ior +1 -1
  249. data/test/Timeout/server.rb +109 -109
  250. data/test/Timeout/test.idl +19 -19
  251. data/test/lib/assert.rb +43 -43
  252. data/test/lib/test.rb +542 -542
  253. data/test/test_runner.rb +193 -193
  254. metadata +141 -137
@@ -1,14 +1,14 @@
1
- #--------------------------------------------------------------------
2
- # require.rb - R2CORBA loader finalizer
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
- require 'corba/jbase/IORMap'
1
+ #--------------------------------------------------------------------
2
+ # require.rb - R2CORBA loader finalizer
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
+ require 'corba/jbase/IORMap'
@@ -1,86 +1,89 @@
1
- #--------------------------------------------------------------------
2
- # require.rb - R2CORBA loader
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
- require 'rbconfig'
14
- require 'java'
15
-
16
- module R2CORBA
17
- if ENV['JACORB_HOME'] && File.exists?(File.join(ENV['JACORB_HOME'], 'lib', 'jacorb.jar'))
18
- JACORB_HOME = ENV['JACORB_HOME']
19
- else
20
- # find jacorb.jar in library search path
21
- JACORB_HOME = File.dirname(($:.find { |path| File.exists?(File.join(path, 'jacorb.jar')) }).to_s)
22
- end
23
-
24
- $LOAD_PATH << File.join(JACORB_HOME, 'lib')
25
- module JavaLang
26
- include_package 'java.lang'
27
- prop = System.getProperties['java.endorsed.dirs']
28
- System.setProperty('java.endorsed.dirs', "#{File.join(R2CORBA::JACORB_HOME, 'lib')}:#{prop}")
29
- System.setProperty('jacorb.home', "#{R2CORBA::JACORB_HOME}")
30
- System.setProperty('org.omg.CORBA.ORBClass', 'org.jacorb.orb.ORB')
31
- System.setProperty('org.omg.CORBA.ORBSingletonClass', 'org.jacorb.orb.ORBSingleton')
32
- System.setProperty('jacorb.orb.print_version', $VERBOSE ? 'on' : 'off')
33
- System.setProperty('jacorb.log.default.verbosity', $VERBOSE ? '3' : '1')
34
- end
35
- end
36
-
37
- # add required JAR files for JacORB from searchpath
38
- Dir.glob(File.join(R2CORBA::JACORB_HOME, 'lib', '*.jar')).each do |jar|
39
- require File.basename(jar)
40
- end
41
-
42
- module R2CORBA
43
- module CORBA
44
- module Native
45
- # first include CORBA::Object separately to avoid 'Object' replacement warnings
46
- java_import 'org.omg.CORBA.Object'
47
- include_package 'org.omg.CORBA'
48
- module Portable
49
- include_package 'org.omg.CORBA.portable'
50
- end
51
- module V2_3
52
- include_package 'org.omg.CORBA_2_3'
53
- module Portable
54
- include_package 'org.omg.CORBA.portable'
55
- end
56
- end
57
- module V2_5
58
- include_package 'org.omg.CORBA_2_5'
59
- end
60
- module V3_0
61
- include_package 'org.omg.CORBA_3_0'
62
- end
63
- module Jacorb
64
- module Util
65
- java_import org.jacorb.util.Version
66
- end
67
- VERSION = Util::Version.version
68
- va = VERSION.split('.')
69
- MAJOR_VERSION = va.shift.to_i
70
- MINOR_VERSION = va.shift.to_i
71
- RELEASE_NR = va.shift.to_i
72
- end
73
- end
74
- end
75
- end
76
-
77
- [ 'exception',
78
- 'Object',
79
- 'ORB',
80
- 'Request',
81
- 'Stub',
82
- 'Typecode',
83
- 'Any',
84
- 'Values',
85
- 'Streams'
86
- ].each { |f| require "corba/jbase/#{f}.rb" }
1
+ #--------------------------------------------------------------------
2
+ # require.rb - R2CORBA loader
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
+ require 'rbconfig'
14
+ require 'java'
15
+
16
+ module R2CORBA
17
+ if ENV['JACORB_HOME'] &&
18
+ (File.exists?(File.join(ENV['JACORB_HOME'], 'lib', 'jacorb.jar')) ||
19
+ Dir[File.join(ENV['JACORB_HOME'], 'lib', 'jacorb-*.jar')].any? {|p| p =~ /\/jacorb\-\d\.\d\.jar\Z/})
20
+ JACORB_HOME = ENV['JACORB_HOME']
21
+ else
22
+ # find jacorb.jar in library search path
23
+ JACORB_HOME = File.dirname(($:.find { |path| Dir[File.join(path, 'jacorb-*.jar')].any? {|p| p =~ /\/jacorb(\.jar|\-\d\.\d\.jar)\Z/} }).to_s)
24
+ end
25
+
26
+ $LOAD_PATH << File.join(JACORB_HOME, 'lib')
27
+ module JavaLang
28
+ include_package 'java.lang'
29
+ ## Only works if passed as Java commandline arg
30
+ # prop = System.getProperties['java.endorsed.dirs']
31
+ # System.setProperty('java.endorsed.dirs', "#{File.join(R2CORBA::JACORB_HOME, 'lib')}:#{prop}")
32
+ System.setProperty('jacorb.home', "#{R2CORBA::JACORB_HOME}")
33
+ System.setProperty('org.omg.CORBA.ORBClass', 'org.jacorb.orb.ORB')
34
+ System.setProperty('org.omg.CORBA.ORBSingletonClass', 'org.jacorb.orb.ORBSingleton')
35
+ System.setProperty('jacorb.orb.print_version', $VERBOSE ? 'on' : 'off')
36
+ System.setProperty('jacorb.log.default.verbosity', $VERBOSE ? '3' : '1')
37
+ end
38
+ end
39
+
40
+ # add required JAR files for JacORB from searchpath
41
+ Dir.glob(File.join(R2CORBA::JACORB_HOME, 'lib', '*.jar')).each do |jar|
42
+ require File.basename(jar)
43
+ end
44
+
45
+ module R2CORBA
46
+ module CORBA
47
+ module Native
48
+ # first include CORBA::Object separately to avoid 'Object' replacement warnings
49
+ java_import 'org.omg.CORBA.Object'
50
+ include_package 'org.omg.CORBA'
51
+ module Portable
52
+ include_package 'org.omg.CORBA.portable'
53
+ end
54
+ module V2_3
55
+ include_package 'org.omg.CORBA_2_3'
56
+ module Portable
57
+ include_package 'org.omg.CORBA.portable'
58
+ end
59
+ end
60
+ module V2_5
61
+ include_package 'org.omg.CORBA_2_5'
62
+ end
63
+ module V3_0
64
+ include_package 'org.omg.CORBA_3_0'
65
+ end
66
+ module Jacorb
67
+ module Util
68
+ java_import org.jacorb.util.Version
69
+ end
70
+ VERSION = Util::Version.version
71
+ va = VERSION.split('.')
72
+ MAJOR_VERSION = va.shift.to_i
73
+ MINOR_VERSION = va.shift.to_i
74
+ RELEASE_NR = va.shift.to_i
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ [ 'exception',
81
+ 'Object',
82
+ 'ORB',
83
+ 'Request',
84
+ 'Stub',
85
+ 'Typecode',
86
+ 'Any',
87
+ 'Values',
88
+ 'Streams'
89
+ ].each { |f| require "corba/jbase/#{f}.rb" }
data/lib/corba/naming.rb CHANGED
@@ -1,14 +1,14 @@
1
- #--------------------------------------------------------------------
2
- # naming.rb - R2CORBA CosNaming client definitions loader
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
- require 'corba/idl/CosNamingC'
1
+ #--------------------------------------------------------------------
2
+ # naming.rb - R2CORBA CosNaming client definitions loader
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
+ require 'corba/idl/CosNamingC'
@@ -1,15 +1,15 @@
1
- #--------------------------------------------------------------------
2
- # naming_service.rb - R2CORBA CosNaming server definitions loader
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
- require 'corba/naming.rb'
15
- require 'corba/idl/CosNamingS'
1
+ #--------------------------------------------------------------------
2
+ # naming_service.rb - R2CORBA CosNaming server definitions loader
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
+ require 'corba/naming.rb'
15
+ require 'corba/idl/CosNamingS'
data/lib/corba/poa.rb CHANGED
@@ -1,15 +1,15 @@
1
- #--------------------------------------------------------------------
2
- # poa.rb - R2CORBA POA loader
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
- require 'corba.rb'
15
- require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/poa.rb"
1
+ #--------------------------------------------------------------------
2
+ # poa.rb - R2CORBA POA loader
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
+ require 'corba.rb'
15
+ require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/poa.rb"
@@ -1,18 +1,18 @@
1
- #--------------------------------------------------------------------
2
- # policies.rb - R2CORBA Policy support loader
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
- require 'corba.rb'
15
- require 'corba/poa.rb'
16
- require 'corba/idl/BiDirPolicyC'
17
- require 'corba/idl/MessagingC'
18
- require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/policies.rb"
1
+ #--------------------------------------------------------------------
2
+ # policies.rb - R2CORBA Policy support loader
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
+ require 'corba.rb'
15
+ require 'corba/poa.rb'
16
+ require 'corba/idl/BiDirPolicyC'
17
+ require 'corba/idl/MessagingC'
18
+ require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/policies.rb"
data/lib/corba/require.rb CHANGED
@@ -1,17 +1,17 @@
1
- #--------------------------------------------------------------------
2
- # require.rb - R2CORBA loader
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
- require 'corba/common/require'
15
- require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/require"
16
- require 'corba/idl/require'
17
- require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/post_require"
1
+ #--------------------------------------------------------------------
2
+ # require.rb - R2CORBA loader
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
+ require 'corba/common/require'
15
+ require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/require"
16
+ require 'corba/idl/require'
17
+ require "corba/#{defined?(JRUBY_VERSION)?'jbase':'cbase'}/post_require"
@@ -1,426 +1,426 @@
1
- #--------------------------------------------------------------------
2
- # cos_naming.rb - Implementation of CosNaming servants
3
- # for full featured naming service
4
- #
5
- # Author: Martin Corino
6
- #
7
- # $Id: $
8
- #
9
- # This program is free software; you can redistribute it and/or
10
- # modify it under the terms of the R2CORBA LICENSE which is
11
- # included with this program.
12
- #
13
- # Copyright (c) Remedy IT Expertise BV
14
- # Chamber of commerce Rotterdam nr.276339, The Netherlands
15
- #--------------------------------------------------------------------
16
-
17
- require 'corba/naming_service'
18
- if (defined?(JRUBY_VERSION) or R2CORBA::TAO::RUBY_THREAD_SUPPORT)
19
- require 'monitor'
20
- end
21
-
22
- module CosNaming
23
- # add some useful methods to CosNaming::NameComponent
24
- class NameComponent
25
- # create key value for registering in context map
26
- def to_key
27
- "#{self.r_id}|#{self.kind}"
28
- end
29
- # convert NameComponent to stringified format according to spec
30
- def to_string
31
- s = ''
32
- s = self.r_id.gsub(/([\/\.\\])/,'\\\1') unless self.r_id.to_s.empty?
33
- s << '.' if s.empty? or !self.kind.to_s.empty?
34
- s << self.kind.gsub(/([\/\.\\])/,'\\\1') unless self.kind.to_s.empty?
35
- s
36
- end
37
- # convert stringified name back to NameComponent
38
- def self.from_string(snc)
39
- raise CosNaming::NamingContext::InvalidName.new if snc.empty?
40
- esc_ = false
41
- id_ = ''
42
- off_ = 0
43
- snc.size.times do |i|
44
- case snc[i, 1]
45
- when '\\'
46
- esc_ = !esc_
47
- when '.'
48
- unless esc_
49
- raise CosNaming::NamingContext::InvalidName.new if off_>0
50
- id_ = snc[0, i].gsub(/\\(\.|\\)/, '\1')
51
- off_ = i+1
52
- end
53
- esc_ = false
54
- else
55
- esc_ = false
56
- end
57
- end
58
- kind_ = snc[off_, snc.size].gsub(/\\(\.|\\)/, '\1')
59
- self.new(id_, kind_)
60
- end
61
- end
62
- end
63
-
64
- module R2CORBA
65
- module INS
66
-
67
- ##
68
- # Binding iterator servant class
69
- #
70
- class BindingIterator < POA::CosNaming::BindingIterator
71
- def initialize(reglist, iterator_id)
72
- @rl = reglist
73
- @id = iterator_id
74
- end
75
-
76
- attr_accessor :oid
77
-
78
- def next_one
79
- reg = @rl.shift
80
- [!reg.nil?, reg ? CosNaming::Binding.new(reg[:name], reg[:type]) : nil]
81
- end
82
-
83
- def next_n(how_many)
84
- raise CORBA::BAD_PARAM.new if how_many < 1
85
- bindings = []
86
- while how_many>0 and !@rl.empty?
87
- reg = @rl.shift
88
- bindings << CosNaming::Binding.new(reg[:name], reg[:type])
89
- how_many -= 1
90
- end
91
- [!bindings.empty?, bindings]
92
- end
93
-
94
- def destroy
95
- poa = self._default_POA
96
- poa.deactivate_object(self.oid)
97
- @rl.clear
98
- INS::NamingContext.clear_iterator(@id)
99
- end
100
- end
101
-
102
- ##
103
- # Naming context servant class
104
- #
105
- class NamingContext < POA::CosNaming::NamingContextExt
106
-
107
- # Map type to store bindings.
108
- # Use synchronized version for multithreading capable implementations.
109
- #
110
- if (defined?(JRUBY_VERSION) or R2CORBA::TAO::RUBY_THREAD_SUPPORT)
111
- MAP_TYPE = Class.new(Monitor) do
112
- def initialize
113
- super
114
- @map_ = {}
115
- end
116
- def size()
117
- rc = 0
118
- synchronize do
119
- rc = @map_.size
120
- end
121
- return rc
122
- end
123
- def has_key?(key)
124
- rc = false
125
- synchronize do
126
- rc = @map_.has_key?(key)
127
- end
128
- return rc
129
- end
130
- def [](key)
131
- rc = nil
132
- synchronize do
133
- rc = @map_[key]
134
- end
135
- return rc
136
- end
137
- def []=(key, value)
138
- synchronize do
139
- @map_[key] = value
140
- end
141
- value
142
- end
143
- def delete(key)
144
- rc = nil
145
- synchronize do
146
- rc = @map_.delete(key)
147
- end
148
- return rc
149
- end
150
- def values
151
- rc = nil
152
- synchronize do
153
- rc = @map_.values
154
- end
155
- return rc
156
- end
157
- def each(&block)
158
- synchronize do
159
- @map_.each &block
160
- end
161
- end
162
- end
163
- else
164
- MAP_TYPE = Class.new(::Hash) do
165
- def synchronize(&block)
166
- yield
167
- end
168
- end
169
- end
170
-
171
- @@iterators = MAP_TYPE.new
172
- @@iterator_max = 100
173
-
174
- def self.set_iterator_max(max)
175
- @@iterator_max = max.to_i
176
- end
177
-
178
- def self.clear_iterator(id)
179
- @@iterators.delete(id)
180
- end
181
-
182
- def self.alloc_iterator(reglist)
183
- @@iterators.synchronize do
184
- unless @@iterators.size < @@iterator_max
185
- oldest_id, oldest_it = @iterators.min
186
- oldest_it.destroy
187
- end
188
- itid = Time.now
189
- return (@@iterators[itid] = INS::BindingIterator.new(reglist, itid))
190
- end
191
- end
192
-
193
- def initialize(orb)
194
- @orb = orb
195
- @map = MAP_TYPE.new
196
- end
197
-
198
- attr_accessor :oid
199
-
200
- # CosNaming::NamingContext methods
201
- #
202
- def bind(n, obj)
203
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
204
- if n.size>1
205
- nc = find_context(n)
206
- nc.bind(n, obj)
207
- else
208
- register_object(n.first, n, CosNaming::Nobject, obj)
209
- end
210
- end
211
-
212
- def rebind(n, obj)
213
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
214
- if n.size>1
215
- nc = find_context(n)
216
- nc.rebind(n, obj)
217
- else
218
- reregister_object(n.first, n, CosNaming::Nobject, obj)
219
- end
220
- end
221
-
222
- def bind_context(n, nc_new)
223
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
224
- if n.size>1
225
- nc = find_context(n)
226
- nc.bind_context(n, nc_new)
227
- else
228
- register_object(n.first, n, CosNaming::Ncontext, nc_new)
229
- end
230
- end
231
-
232
- def rebind_context(n, nc_new)
233
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
234
- if n.size>1
235
- nc = find_context(n)
236
- nc.rebind_context(n, nc_new)
237
- else
238
- reregister_object(n.first, n, CosNaming::Ncontext, nc_new)
239
- end
240
- end
241
-
242
- def resolve(n)
243
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
244
- find_object(n)
245
- end
246
-
247
- def unbind(n)
248
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
249
- if n.size>1
250
- nc = find_context(n)
251
- nc.unbind(n)
252
- else
253
- @map.synchronize do
254
- raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Missing_node,
255
- n) if !@map.has_key?(n.first.r_id)
256
- @map.delete(n.last.r_id)
257
- end
258
- end
259
- end
260
-
261
- def new_context()
262
- poa = self._default_POA
263
- naming_srv = NamingContext.new(@orb)
264
- naming_srv.oid = poa.activate_object(naming_srv)
265
- ::CosNaming::NamingContextExt::_narrow(poa.id_to_reference(naming_srv.oid))
266
- end
267
-
268
- def bind_new_context(n)
269
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
270
- nc = self.new_context()
271
- self.bind_context(n, nc)
272
- nc
273
- end
274
-
275
- def destroy()
276
- raise CosNaming::NamingContext::NotEmpty.new if @map.size>0
277
- return if self.oid.nil? ## no oid for root context
278
- poa = self._default_POA
279
- poa.deactivate_object(self.oid)
280
- @orb = nil
281
- end
282
-
283
- def list(how_many)
284
- reglist = @map.values
285
- bindings = []
286
- while how_many>0 and !reglist.empty?
287
- reg = reglist.shift
288
- bindings << CosNaming::Binding.new(reg[:name], reg[:type])
289
- how_many -= 1
290
- end
291
- bi_obj = nil
292
- if !reglist.empty?
293
- bi = INS::NamingContext.alloc_iterator(reglist)
294
- poa = self._default_POA
295
- bi.oid = poa.activate_object(bi)
296
- bi_obj = poa.id_to_reference(bi.oid)
297
- end
298
- [bindings, CosNaming::BindingIterator._narrow(bi_obj)]
299
- end
300
-
301
- # CosNaming::NamingContextExt methods
302
- #
303
- def to_string(n)
304
- raise CosNaming::NamingContext::InvalidName.new if n.size<1
305
- n.collect { |nc| nc.to_string }.join('/')
306
- end
307
-
308
- def to_name(sn)
309
- raise CosNaming::NamingContext::InvalidName.new if sn.to_s.empty?
310
- snc_arr = []
311
- off_ = 0
312
- esc_ = false
313
- sn.size.times do |i|
314
- case sn[i,1]
315
- when '\\'
316
- esc_ = !esc_
317
- when '/'
318
- unless esc_
319
- snc_arr << sn[off_, i-off_]
320
- off_ = i+1
321
- end
322
- esc_ = false
323
- else
324
- esc_ = false
325
- end
326
- end
327
- snc_arr << sn[off_, sn.size]
328
- [snc_arr.collect { |snc| CosNaming::NameComponent.from_string(snc) }]
329
- end
330
-
331
- def to_url(addr, sn)
332
- raise CosNaming::NamingContext::InvalidName.new if addr.to_s.empty? or sn.to_s.empty?
333
- url = 'corbaname:'+addr+'#'
334
- sn.scan(/./) do |ch|
335
- if /[a-zA-Z0-9;\/:\?@=+\$,\-_\.!~*\'\(\)]/ =~ ch
336
- url << ch
337
- else
338
- url << '%' << ch.unpack('H2').first
339
- end
340
- end
341
- url
342
- end
343
-
344
- def resolve_str(sn)
345
- self.resolve(self.to_name(sn).first)
346
- end
347
-
348
- # Helper methods
349
- #
350
- protected
351
-
352
- # register the object reference for a certain NameComponent id
353
- # no reregistering or duplicates allowed
354
- #
355
- def register_object(name, full_name, type, obj)
356
- key_ = name.to_key
357
- @map.synchronize do
358
- raise CosNaming::NamingContext::AlreadyBound.new if @map.has_key?(key_)
359
- @map[key_] = {
360
- :name => full_name,
361
- :type => type,
362
- :object => obj
363
- }
364
- end
365
- end
366
-
367
- # reregister the object reference for a certain NameComponent id
368
- #
369
- def reregister_object(name, full_name, type, obj)
370
- key_ = name.to_key
371
- @map.synchronize do
372
- if @map.has_key?(key_) and @map[key_][:type] != type
373
- why = (type == CosNaming::Nobject ? CosNaming::NamingContext::Not_object : CosNaming::NamingContext::Not_context)
374
- raise CosNaming::NamingContext::NotFound.new(why, [])
375
- end
376
- @map[key_] = {
377
- :name => full_name,
378
- :type => type,
379
- :object => obj
380
- }
381
- end
382
- end
383
-
384
- # walk all segments of the given CosNaming::Name to find the object
385
- # bound by this full name
386
- # NOTE that #find_context is used when the Name contains > 1 level
387
- # which will automatically shift the segments of Name 1 level while
388
- # resolving the context levels
389
- #
390
- def find_object(n)
391
- if n.size>1
392
- nc = find_context(n)
393
- nc.resolve(n)
394
- else
395
- key_ = n.first.to_key
396
- @map.synchronize do
397
- raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Missing_node,
398
- n) if !@map.has_key?(key_)
399
- @map[key_][:object]
400
- end
401
- end
402
- end
403
-
404
- # check if there exists a naming context in the current context
405
- # with the id from the first segment of the given CosNaming::Name
406
- # return the object reference to the naming context if found
407
- # NOTE that #shift is used to get AND remove the first Name segment
408
- # if the naming context is found so that after this call the
409
- # first segment of the Name is shifted one level
410
- #
411
- def find_context(n)
412
- key_ = n.first.to_key
413
- @map.synchronize do
414
- raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Missing_node,
415
- n) if !@map.has_key?(key_)
416
- raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Not_context,
417
- n) if @map[key_][:type] != CosNaming::Ncontext
418
- n.shift
419
- @map[key_][:object]
420
- end
421
- end
422
-
423
- end #of NamingContext servant
424
-
425
- end
426
- end
1
+ #--------------------------------------------------------------------
2
+ # cos_naming.rb - Implementation of CosNaming servants
3
+ # for full featured naming service
4
+ #
5
+ # Author: Martin Corino
6
+ #
7
+ # $Id: $
8
+ #
9
+ # This program is free software; you can redistribute it and/or
10
+ # modify it under the terms of the R2CORBA LICENSE which is
11
+ # included with this program.
12
+ #
13
+ # Copyright (c) Remedy IT Expertise BV
14
+ # Chamber of commerce Rotterdam nr.276339, The Netherlands
15
+ #--------------------------------------------------------------------
16
+
17
+ require 'corba/naming_service'
18
+ if (defined?(JRUBY_VERSION) or R2CORBA::TAO::RUBY_THREAD_SUPPORT)
19
+ require 'monitor'
20
+ end
21
+
22
+ module CosNaming
23
+ # add some useful methods to CosNaming::NameComponent
24
+ class NameComponent
25
+ # create key value for registering in context map
26
+ def to_key
27
+ "#{self.r_id}|#{self.kind}"
28
+ end
29
+ # convert NameComponent to stringified format according to spec
30
+ def to_string
31
+ s = ''
32
+ s = self.r_id.gsub(/([\/\.\\])/,'\\\1') unless self.r_id.to_s.empty?
33
+ s << '.' if s.empty? or !self.kind.to_s.empty?
34
+ s << self.kind.gsub(/([\/\.\\])/,'\\\1') unless self.kind.to_s.empty?
35
+ s
36
+ end
37
+ # convert stringified name back to NameComponent
38
+ def self.from_string(snc)
39
+ raise CosNaming::NamingContext::InvalidName.new if snc.empty?
40
+ esc_ = false
41
+ id_ = ''
42
+ off_ = 0
43
+ snc.size.times do |i|
44
+ case snc[i, 1]
45
+ when '\\'
46
+ esc_ = !esc_
47
+ when '.'
48
+ unless esc_
49
+ raise CosNaming::NamingContext::InvalidName.new if off_>0
50
+ id_ = snc[0, i].gsub(/\\(\.|\\)/, '\1')
51
+ off_ = i+1
52
+ end
53
+ esc_ = false
54
+ else
55
+ esc_ = false
56
+ end
57
+ end
58
+ kind_ = snc[off_, snc.size].gsub(/\\(\.|\\)/, '\1')
59
+ self.new(id_, kind_)
60
+ end
61
+ end
62
+ end
63
+
64
+ module R2CORBA
65
+ module INS
66
+
67
+ ##
68
+ # Binding iterator servant class
69
+ #
70
+ class BindingIterator < POA::CosNaming::BindingIterator
71
+ def initialize(reglist, iterator_id)
72
+ @rl = reglist
73
+ @id = iterator_id
74
+ end
75
+
76
+ attr_accessor :oid
77
+
78
+ def next_one
79
+ reg = @rl.shift
80
+ [!reg.nil?, reg ? CosNaming::Binding.new(reg[:name], reg[:type]) : nil]
81
+ end
82
+
83
+ def next_n(how_many)
84
+ raise CORBA::BAD_PARAM.new if how_many < 1
85
+ bindings = []
86
+ while how_many>0 and !@rl.empty?
87
+ reg = @rl.shift
88
+ bindings << CosNaming::Binding.new(reg[:name], reg[:type])
89
+ how_many -= 1
90
+ end
91
+ [!bindings.empty?, bindings]
92
+ end
93
+
94
+ def destroy
95
+ poa = self._default_POA
96
+ poa.deactivate_object(self.oid)
97
+ @rl.clear
98
+ INS::NamingContext.clear_iterator(@id)
99
+ end
100
+ end
101
+
102
+ ##
103
+ # Naming context servant class
104
+ #
105
+ class NamingContext < POA::CosNaming::NamingContextExt
106
+
107
+ # Map type to store bindings.
108
+ # Use synchronized version for multithreading capable implementations.
109
+ #
110
+ if (defined?(JRUBY_VERSION) or R2CORBA::TAO::RUBY_THREAD_SUPPORT)
111
+ MAP_TYPE = Class.new(Monitor) do
112
+ def initialize
113
+ super
114
+ @map_ = {}
115
+ end
116
+ def size()
117
+ rc = 0
118
+ synchronize do
119
+ rc = @map_.size
120
+ end
121
+ return rc
122
+ end
123
+ def has_key?(key)
124
+ rc = false
125
+ synchronize do
126
+ rc = @map_.has_key?(key)
127
+ end
128
+ return rc
129
+ end
130
+ def [](key)
131
+ rc = nil
132
+ synchronize do
133
+ rc = @map_[key]
134
+ end
135
+ return rc
136
+ end
137
+ def []=(key, value)
138
+ synchronize do
139
+ @map_[key] = value
140
+ end
141
+ value
142
+ end
143
+ def delete(key)
144
+ rc = nil
145
+ synchronize do
146
+ rc = @map_.delete(key)
147
+ end
148
+ return rc
149
+ end
150
+ def values
151
+ rc = nil
152
+ synchronize do
153
+ rc = @map_.values
154
+ end
155
+ return rc
156
+ end
157
+ def each(&block)
158
+ synchronize do
159
+ @map_.each &block
160
+ end
161
+ end
162
+ end
163
+ else
164
+ MAP_TYPE = Class.new(::Hash) do
165
+ def synchronize(&block)
166
+ yield
167
+ end
168
+ end
169
+ end
170
+
171
+ @@iterators = MAP_TYPE.new
172
+ @@iterator_max = 100
173
+
174
+ def self.set_iterator_max(max)
175
+ @@iterator_max = max.to_i
176
+ end
177
+
178
+ def self.clear_iterator(id)
179
+ @@iterators.delete(id)
180
+ end
181
+
182
+ def self.alloc_iterator(reglist)
183
+ @@iterators.synchronize do
184
+ unless @@iterators.size < @@iterator_max
185
+ oldest_id, oldest_it = @iterators.min
186
+ oldest_it.destroy
187
+ end
188
+ itid = Time.now
189
+ return (@@iterators[itid] = INS::BindingIterator.new(reglist, itid))
190
+ end
191
+ end
192
+
193
+ def initialize(orb)
194
+ @orb = orb
195
+ @map = MAP_TYPE.new
196
+ end
197
+
198
+ attr_accessor :oid
199
+
200
+ # CosNaming::NamingContext methods
201
+ #
202
+ def bind(n, obj)
203
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
204
+ if n.size>1
205
+ nc = find_context(n)
206
+ nc.bind(n, obj)
207
+ else
208
+ register_object(n.first, n, CosNaming::Nobject, obj)
209
+ end
210
+ end
211
+
212
+ def rebind(n, obj)
213
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
214
+ if n.size>1
215
+ nc = find_context(n)
216
+ nc.rebind(n, obj)
217
+ else
218
+ reregister_object(n.first, n, CosNaming::Nobject, obj)
219
+ end
220
+ end
221
+
222
+ def bind_context(n, nc_new)
223
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
224
+ if n.size>1
225
+ nc = find_context(n)
226
+ nc.bind_context(n, nc_new)
227
+ else
228
+ register_object(n.first, n, CosNaming::Ncontext, nc_new)
229
+ end
230
+ end
231
+
232
+ def rebind_context(n, nc_new)
233
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
234
+ if n.size>1
235
+ nc = find_context(n)
236
+ nc.rebind_context(n, nc_new)
237
+ else
238
+ reregister_object(n.first, n, CosNaming::Ncontext, nc_new)
239
+ end
240
+ end
241
+
242
+ def resolve(n)
243
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
244
+ find_object(n)
245
+ end
246
+
247
+ def unbind(n)
248
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
249
+ if n.size>1
250
+ nc = find_context(n)
251
+ nc.unbind(n)
252
+ else
253
+ @map.synchronize do
254
+ raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Missing_node,
255
+ n) if !@map.has_key?(n.first.r_id)
256
+ @map.delete(n.last.r_id)
257
+ end
258
+ end
259
+ end
260
+
261
+ def new_context()
262
+ poa = self._default_POA
263
+ naming_srv = NamingContext.new(@orb)
264
+ naming_srv.oid = poa.activate_object(naming_srv)
265
+ ::CosNaming::NamingContextExt::_narrow(poa.id_to_reference(naming_srv.oid))
266
+ end
267
+
268
+ def bind_new_context(n)
269
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
270
+ nc = self.new_context()
271
+ self.bind_context(n, nc)
272
+ nc
273
+ end
274
+
275
+ def destroy()
276
+ raise CosNaming::NamingContext::NotEmpty.new if @map.size>0
277
+ return if self.oid.nil? ## no oid for root context
278
+ poa = self._default_POA
279
+ poa.deactivate_object(self.oid)
280
+ @orb = nil
281
+ end
282
+
283
+ def list(how_many)
284
+ reglist = @map.values
285
+ bindings = []
286
+ while how_many>0 and !reglist.empty?
287
+ reg = reglist.shift
288
+ bindings << CosNaming::Binding.new(reg[:name], reg[:type])
289
+ how_many -= 1
290
+ end
291
+ bi_obj = nil
292
+ if !reglist.empty?
293
+ bi = INS::NamingContext.alloc_iterator(reglist)
294
+ poa = self._default_POA
295
+ bi.oid = poa.activate_object(bi)
296
+ bi_obj = poa.id_to_reference(bi.oid)
297
+ end
298
+ [bindings, CosNaming::BindingIterator._narrow(bi_obj)]
299
+ end
300
+
301
+ # CosNaming::NamingContextExt methods
302
+ #
303
+ def to_string(n)
304
+ raise CosNaming::NamingContext::InvalidName.new if n.size<1
305
+ n.collect { |nc| nc.to_string }.join('/')
306
+ end
307
+
308
+ def to_name(sn)
309
+ raise CosNaming::NamingContext::InvalidName.new if sn.to_s.empty?
310
+ snc_arr = []
311
+ off_ = 0
312
+ esc_ = false
313
+ sn.size.times do |i|
314
+ case sn[i,1]
315
+ when '\\'
316
+ esc_ = !esc_
317
+ when '/'
318
+ unless esc_
319
+ snc_arr << sn[off_, i-off_]
320
+ off_ = i+1
321
+ end
322
+ esc_ = false
323
+ else
324
+ esc_ = false
325
+ end
326
+ end
327
+ snc_arr << sn[off_, sn.size]
328
+ [snc_arr.collect { |snc| CosNaming::NameComponent.from_string(snc) }]
329
+ end
330
+
331
+ def to_url(addr, sn)
332
+ raise CosNaming::NamingContext::InvalidName.new if addr.to_s.empty? or sn.to_s.empty?
333
+ url = 'corbaname:'+addr+'#'
334
+ sn.scan(/./) do |ch|
335
+ if /[a-zA-Z0-9;\/:\?@=+\$,\-_\.!~*\'\(\)]/ =~ ch
336
+ url << ch
337
+ else
338
+ url << '%' << ch.unpack('H2').first
339
+ end
340
+ end
341
+ url
342
+ end
343
+
344
+ def resolve_str(sn)
345
+ self.resolve(self.to_name(sn).first)
346
+ end
347
+
348
+ # Helper methods
349
+ #
350
+ protected
351
+
352
+ # register the object reference for a certain NameComponent id
353
+ # no reregistering or duplicates allowed
354
+ #
355
+ def register_object(name, full_name, type, obj)
356
+ key_ = name.to_key
357
+ @map.synchronize do
358
+ raise CosNaming::NamingContext::AlreadyBound.new if @map.has_key?(key_)
359
+ @map[key_] = {
360
+ :name => full_name,
361
+ :type => type,
362
+ :object => obj
363
+ }
364
+ end
365
+ end
366
+
367
+ # reregister the object reference for a certain NameComponent id
368
+ #
369
+ def reregister_object(name, full_name, type, obj)
370
+ key_ = name.to_key
371
+ @map.synchronize do
372
+ if @map.has_key?(key_) and @map[key_][:type] != type
373
+ why = (type == CosNaming::Nobject ? CosNaming::NamingContext::Not_object : CosNaming::NamingContext::Not_context)
374
+ raise CosNaming::NamingContext::NotFound.new(why, [])
375
+ end
376
+ @map[key_] = {
377
+ :name => full_name,
378
+ :type => type,
379
+ :object => obj
380
+ }
381
+ end
382
+ end
383
+
384
+ # walk all segments of the given CosNaming::Name to find the object
385
+ # bound by this full name
386
+ # NOTE that #find_context is used when the Name contains > 1 level
387
+ # which will automatically shift the segments of Name 1 level while
388
+ # resolving the context levels
389
+ #
390
+ def find_object(n)
391
+ if n.size>1
392
+ nc = find_context(n)
393
+ nc.resolve(n)
394
+ else
395
+ key_ = n.first.to_key
396
+ @map.synchronize do
397
+ raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Missing_node,
398
+ n) if !@map.has_key?(key_)
399
+ @map[key_][:object]
400
+ end
401
+ end
402
+ end
403
+
404
+ # check if there exists a naming context in the current context
405
+ # with the id from the first segment of the given CosNaming::Name
406
+ # return the object reference to the naming context if found
407
+ # NOTE that #shift is used to get AND remove the first Name segment
408
+ # if the naming context is found so that after this call the
409
+ # first segment of the Name is shifted one level
410
+ #
411
+ def find_context(n)
412
+ key_ = n.first.to_key
413
+ @map.synchronize do
414
+ raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Missing_node,
415
+ n) if !@map.has_key?(key_)
416
+ raise CosNaming::NamingContext::NotFound.new(CosNaming::NamingContext::Not_context,
417
+ n) if @map[key_][:type] != CosNaming::Ncontext
418
+ n.shift
419
+ @map[key_][:object]
420
+ end
421
+ end
422
+
423
+ end #of NamingContext servant
424
+
425
+ end
426
+ end