r2corba 1.4.1-x86-mingw32
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/r2corba.bat +20 -0
- data/bin/ridlc +11 -0
- data/bin/ridlc.bat +23 -0
- data/bin/rins +7 -0
- data/bin/rins.bat +19 -0
- data/ext/.keep +0 -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/BiDirPolicyC.rb +63 -0
- data/lib/corba/idl/CosNamingC.rb +461 -0
- data/lib/corba/idl/CosNamingS.rb +309 -0
- data/lib/corba/idl/IDL.rb +21 -0
- data/lib/corba/idl/IORTable.pidl +62 -0
- data/lib/corba/idl/IORTableC.rb +117 -0
- data/lib/corba/idl/MessagingC.rb +904 -0
- data/lib/corba/idl/POAC.rb +930 -0
- data/lib/corba/idl/TAO_Ext.pidl +46 -0
- data/lib/corba/idl/TAO_ExtC.rb +179 -0
- data/lib/corba/idl/r2c_orb.rb +572 -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/orb.pidlc +0 -0
- data/lib/ridlbe/ruby/require.rb +16 -0
- data/lib/ridlbe/ruby/walker.rb +1582 -0
- data/mkrf_conf_bingem.rb +101 -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.ior +1 -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/ins.ior +1 -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/corbaname.ior +1 -0
- data/test/CORBA_Services/Naming/Corbaname/ins.ior +1 -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/ins.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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/Multiple_ORB/server0.ior +1 -0
- data/test/Multi_Threading/Multiple_ORB/server1.ior +1 -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.ior +1 -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.ior +1 -0
- data/test/Multi_Threading/Threads/server.rb +119 -0
- data/test/Multi_Threading/Threads/watchdog.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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.ior +1 -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 +342 -0
@@ -0,0 +1,273 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# Any.rb - CORBA Any 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
|
+
module R2CORBA
|
14
|
+
module CORBA
|
15
|
+
module Native
|
16
|
+
module Dynamic
|
17
|
+
include_package 'org.omg.DynamicAny'
|
18
|
+
end
|
19
|
+
module Reflect
|
20
|
+
java_import java.lang.reflect.Array
|
21
|
+
end
|
22
|
+
end
|
23
|
+
class Any
|
24
|
+
def to_java(jorb=nil,jany=nil)
|
25
|
+
rtc = self._tc
|
26
|
+
rval = self._value.nil? ? self._value : rtc.validate(self._value)
|
27
|
+
restc = rtc.resolved_tc
|
28
|
+
begin
|
29
|
+
if [TK_VALUE, TK_VALUE_BOX, TK_ABSTRACT_INTERFACE].include?(restc.kind) ||
|
30
|
+
(!rval.nil? && [TK_NULL,TK_ANY,TK_BOOLEAN,TK_SHORT,TK_LONG,TK_USHORT,
|
31
|
+
TK_WCHAR,TK_ULONG,TK_LONGLONG,TK_ULONGLONG,TK_OCTET,
|
32
|
+
TK_FLOAT,TK_DOUBLE,TK_LONGDOUBLE,TK_CHAR,TK_STRING,TK_WSTRING,
|
33
|
+
TK_VALUE, TK_VALUE_BOX,TK_TYPECODE,TK_OBJREF,TK_PRINCIPAL].include?(restc.kind))
|
34
|
+
jorb ||= CORBA::ORB._orb
|
35
|
+
jany ||= jorb.create_any()
|
36
|
+
case restc.kind
|
37
|
+
when TK_NULL
|
38
|
+
# leave any as is
|
39
|
+
when TK_ANY
|
40
|
+
jany.insert_any(rval.to_java(jorb))
|
41
|
+
when TK_BOOLEAN
|
42
|
+
jany.insert_boolean(rval)
|
43
|
+
when TK_SHORT
|
44
|
+
jany.insert_short(rval)
|
45
|
+
when TK_LONG
|
46
|
+
jany.insert_long(rval)
|
47
|
+
when TK_USHORT
|
48
|
+
jany.insert_ushort([rval].pack('S').unpack('s').first)
|
49
|
+
when TK_WCHAR
|
50
|
+
jany.insert_wchar(rval)
|
51
|
+
when TK_ULONG
|
52
|
+
jany.insert_ulong([rval].pack('L').unpack('l').first)
|
53
|
+
when TK_LONGLONG
|
54
|
+
jany.insert_longlong(rval)
|
55
|
+
when TK_ULONGLONG
|
56
|
+
jany.insert_ulonglong([rval].pack('Q').unpack('q').first)
|
57
|
+
when TK_OCTET
|
58
|
+
jany.insert_octet([rval].pack('C').unpack('c').first)
|
59
|
+
when TK_FLOAT
|
60
|
+
jany.insert_float(rval)
|
61
|
+
when TK_DOUBLE
|
62
|
+
jany.insert_double(rval)
|
63
|
+
when TK_LONGDOUBLE
|
64
|
+
raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
|
65
|
+
when TK_FIXED
|
66
|
+
jany.insert_fixed(java.math.BigDecimal.new(rval.to_s))
|
67
|
+
when TK_CHAR
|
68
|
+
jany.insert_char(rval[0])
|
69
|
+
when TK_STRING
|
70
|
+
jany.insert_string(rval)
|
71
|
+
when TK_WSTRING
|
72
|
+
jany.insert_wstring(rval.inject('') {|s,b| s << b.chr})
|
73
|
+
when TK_VALUE
|
74
|
+
jany.insert_Value(rval, rtc.tc_)
|
75
|
+
when TK_VALUE_BOX
|
76
|
+
rtc.get_type::Factory._check_factory(jorb) # make sure valuebox factory has been registered
|
77
|
+
rval = rtc.get_type.new(rval) unless rval.nil? || rval.is_a?(CORBA::Portable::BoxedValueBase)
|
78
|
+
jany.insert_Value(rval, rtc.tc_)
|
79
|
+
when TK_TYPECODE
|
80
|
+
jany.insert_TypeCode(rtc.tc_)
|
81
|
+
when TK_OBJREF
|
82
|
+
jany.insert_Object(rval.objref_)
|
83
|
+
when TK_ABSTRACT_INTERFACE
|
84
|
+
if rval.is_a?(CORBA::Object)
|
85
|
+
# since we know what we're doing use this convenience method provided
|
86
|
+
# by JacORB so we only make a shallow copy of the object ref
|
87
|
+
# insert_Object() will throw an exception because the typecode is not
|
88
|
+
# an objref tc but rather an abstract interface tc
|
89
|
+
if CORBA::Native::Jacorb::MAJOR_VERSION < 3
|
90
|
+
jany.insert_object(rtc.tc_, rval.objref_)
|
91
|
+
else
|
92
|
+
jany.insert(rtc.tc_, rval.objref_)
|
93
|
+
end
|
94
|
+
else
|
95
|
+
jany.insert_Value(rval, rtc.tc_)
|
96
|
+
end
|
97
|
+
when TK_PRINCIPAL
|
98
|
+
raise CORBA::NO_IMPLEMENT.new('Principal not supported',0,CORBA::COMPLETED_NO)
|
99
|
+
## TODO: TK_NATIVE
|
100
|
+
else
|
101
|
+
raise CORBA::MARSHAL.new("unknown kind [#{rtc.kind}]",0,CORBA::COMPLETED_NO)
|
102
|
+
end
|
103
|
+
return jany
|
104
|
+
else
|
105
|
+
dynFactory = CORBA::Native::Dynamic::DynAnyFactoryHelper.narrow(
|
106
|
+
(jorb || CORBA::ORB._orb).resolve_initial_references("DynAnyFactory"))
|
107
|
+
jdynany = dynFactory.create_dyn_any_from_type_code(rtc.tc_)
|
108
|
+
begin
|
109
|
+
unless rval.nil?
|
110
|
+
restc = rtc.resolved_tc
|
111
|
+
case restc.kind
|
112
|
+
when TK_ENUM
|
113
|
+
jdynany.set_as_ulong(rval)
|
114
|
+
when TK_ARRAY
|
115
|
+
jelems = CORBA::Native::Reflect::Array.newInstance(CORBA::Native::Any.java_class, rval.size)
|
116
|
+
rval.each_with_index {|e,i| jelems[i] = Any.to_any(e, restc.content_type).to_java(jorb) }
|
117
|
+
jdynany.set_elements(jelems)
|
118
|
+
when TK_SEQUENCE
|
119
|
+
jelems = CORBA::Native::Reflect::Array.newInstance(CORBA::Native::Any.java_class, rval.size)
|
120
|
+
rval.each_with_index {|e,i| jelems[i] = Any.to_any(e, restc.content_type).to_java(jorb) }
|
121
|
+
jdynany.set_elements(jelems)
|
122
|
+
when TK_STRUCT, TK_EXCEPT
|
123
|
+
jmembers = CORBA::Native::Reflect::Array.newInstance(CORBA::Native::Dynamic::NameValuePair.java_class, restc.members.size)
|
124
|
+
rtc.members.each_with_index {|(mn, mt),i| jmembers[i] = CORBA::Native::Dynamic::NameValuePair.new(mn, Any.to_any(rval.__send__(mn.intern), mt).to_java(jorb)) }
|
125
|
+
jdynany.set_members(jmembers)
|
126
|
+
when TK_UNION
|
127
|
+
if rval._is_at_default?
|
128
|
+
jdynany.set_to_default_member
|
129
|
+
elsif rval._disc.nil?
|
130
|
+
jdynany.set_to_no_active_member
|
131
|
+
else
|
132
|
+
jdynany.set_discriminator(dynFactory.create_dyn_any(Any.to_any(rval._disc, restc.discriminator_type).to_java(jorb)))
|
133
|
+
end
|
134
|
+
unless rval._disc.nil? || rval._value.nil?
|
135
|
+
jdynany.member.from_any(Any.to_any(rval._value, rval._value_tc).to_java(jorb))
|
136
|
+
end
|
137
|
+
else
|
138
|
+
raise CORBA::MARSHAL.new("unknown kind [#{rtc.kind}]",0,CORBA::COMPLETED_NO)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
if jany.nil?
|
142
|
+
jany = jdynany.to_any
|
143
|
+
else
|
144
|
+
jany.read_value(jdynany.to_any.create_input_stream(), rtc.tc_)
|
145
|
+
end
|
146
|
+
ensure
|
147
|
+
jdynany.destroy
|
148
|
+
end
|
149
|
+
return jany
|
150
|
+
end
|
151
|
+
rescue ::NativeException
|
152
|
+
CORBA::Exception.native2r($!)
|
153
|
+
end
|
154
|
+
end # to_java
|
155
|
+
|
156
|
+
def Any.from_java(jany, jorb=nil, rtc=nil)
|
157
|
+
rtc ||= CORBA::TypeCode.from_native(jany.type)
|
158
|
+
rval = nil
|
159
|
+
begin
|
160
|
+
if [TK_NULL,TK_VOID,TK_ANY,TK_BOOLEAN,TK_SHORT,TK_LONG,TK_USHORT,
|
161
|
+
TK_WCHAR,TK_ULONG,TK_LONGLONG,TK_ULONGLONG,TK_OCTET,
|
162
|
+
TK_FLOAT,TK_DOUBLE,TK_LONGDOUBLE,TK_CHAR,TK_STRING,TK_WSTRING,
|
163
|
+
TK_VALUE, TK_VALUE_BOX,TK_TYPECODE,TK_OBJREF,
|
164
|
+
TK_ABSTRACT_INTERFACE,TK_PRINCIPAL].include?(rtc.resolved_tc.kind)
|
165
|
+
case rtc.resolved_tc.kind
|
166
|
+
when TK_NULL, TK_VOID
|
167
|
+
# leave as is
|
168
|
+
when TK_ANY
|
169
|
+
rval = Any.from_java(jany.extract_any(), jorb)
|
170
|
+
when TK_BOOLEAN
|
171
|
+
rval = jany.extract_boolean()
|
172
|
+
when TK_SHORT
|
173
|
+
rval = jany.extract_short()
|
174
|
+
when TK_LONG
|
175
|
+
rval = jany.extract_long()
|
176
|
+
when TK_USHORT
|
177
|
+
rval = [jany.extract_ushort()].pack('s').unpack('S').first
|
178
|
+
when TK_WCHAR
|
179
|
+
rval = jany.extract_wchar()
|
180
|
+
when TK_ULONG
|
181
|
+
rval = [jany.extract_ulong()].pack('l').unpack('L').first
|
182
|
+
when TK_LONGLONG
|
183
|
+
rval = jany.extract_longlong()
|
184
|
+
when TK_ULONGLONG
|
185
|
+
rval = [jany.extract_ulonglong()].pack('q').unpack('Q').first
|
186
|
+
when TK_OCTET
|
187
|
+
rval = [jany.extract_octet()].pack('c').unpack('C').first
|
188
|
+
when TK_FLOAT
|
189
|
+
rval = jany.extract_float()
|
190
|
+
when TK_DOUBLE
|
191
|
+
rval = jany.extract_double()
|
192
|
+
when TK_LONGDOUBLE
|
193
|
+
raise CORBA::NO_IMPLEMENT.new('LongDouble not supported',0,CORBA::COMPLETED_NO)
|
194
|
+
when TK_FIXED
|
195
|
+
rval = BigDecimal.new(jany.extract_fixed().toString())
|
196
|
+
when TK_CHAR
|
197
|
+
rval = jany.extract_char().chr
|
198
|
+
when TK_STRING
|
199
|
+
rval = jany.extract_string()
|
200
|
+
when TK_WSTRING
|
201
|
+
rval = jany.extract_wstring()
|
202
|
+
when TK_VALUE
|
203
|
+
rval = jany.extract_Value()
|
204
|
+
when TK_VALUE_BOX
|
205
|
+
rtc.get_type::Factory._check_factory(jorb || CORBA::ORB._orb) # make sure valuebox factory has been registered
|
206
|
+
rval = jany.extract_Value()
|
207
|
+
rval = rval.value unless rval.nil?
|
208
|
+
when TK_TYPECODE
|
209
|
+
rval = CORBA::TypeCode.from_native(jany.extract_TypeCode())
|
210
|
+
when TK_OBJREF
|
211
|
+
rval = CORBA::Object._wrap_native(jany.extract_Object())
|
212
|
+
rval = rtc.get_type._narrow(rval) if rval
|
213
|
+
when TK_ABSTRACT_INTERFACE
|
214
|
+
jobj = jany.create_input_stream().read_abstract_interface()
|
215
|
+
rval = if jobj.is_a?(CORBA::Native::Object)
|
216
|
+
rtc.get_type._narrow(CORBA::Object._wrap_native(jobj))
|
217
|
+
else
|
218
|
+
jobj
|
219
|
+
end
|
220
|
+
when TK_PRINCIPAL
|
221
|
+
raise CORBA::NO_IMPLEMENT.new('Principal not supported',0,CORBA::COMPLETED_NO)
|
222
|
+
## TODO: TK_NATIVE
|
223
|
+
else
|
224
|
+
raise CORBA::MARSHAL.new("unknown kind [#{rtc.kind}]",0,CORBA::COMPLETED_NO)
|
225
|
+
end
|
226
|
+
else
|
227
|
+
dynFactory = CORBA::Native::Dynamic::DynAnyFactoryHelper.narrow(
|
228
|
+
(jorb || CORBA::ORB._orb).resolve_initial_references("DynAnyFactory"))
|
229
|
+
jdynany = dynFactory.create_dyn_any(jany)
|
230
|
+
begin
|
231
|
+
restc = rtc.resolved_tc
|
232
|
+
case restc.kind
|
233
|
+
when TK_ENUM
|
234
|
+
rval = jdynany.get_as_ulong()
|
235
|
+
when TK_ARRAY
|
236
|
+
rval = rtc.get_type.new
|
237
|
+
jdynany.get_elements().each {|e| rval << Any.from_java(e, jorb, restc.content_type) }
|
238
|
+
when TK_SEQUENCE
|
239
|
+
rval = rtc.get_type.new
|
240
|
+
jdynany.get_elements().each {|e| rval << Any.from_java(e, jorb, restc.content_type) }
|
241
|
+
when TK_STRUCT, TK_EXCEPT
|
242
|
+
rval = rtc.get_type.new
|
243
|
+
jdynany.get_members().each_with_index {|nvp,i| rval.__send__("#{nvp.id}=".intern, Any.from_java(nvp.value, jorb, restc.member_type(i))) }
|
244
|
+
when TK_UNION
|
245
|
+
rval = rtc.get_type.new
|
246
|
+
if jdynany.get_discriminator().type().kind().value() == CORBA::TK_OCTET
|
247
|
+
rdisc = jdynany.get_discriminator().get_octet()
|
248
|
+
# Octet 0 designates default member
|
249
|
+
rdisc = rdisc == 0 ? :default : rdisc
|
250
|
+
else
|
251
|
+
rdisc = Any.from_java(jdynany.get_discriminator().to_any(), jorb, restc.discriminator_type)
|
252
|
+
end
|
253
|
+
rval.instance_variable_set('@discriminator', rdisc)
|
254
|
+
unless jdynany.has_no_active_member
|
255
|
+
minx = rtc.label_index(rdisc)
|
256
|
+
rval.instance_variable_set('@value', Any.from_java(jdynany.member.to_any, jorb, restc.member_type(minx)))
|
257
|
+
end
|
258
|
+
else
|
259
|
+
raise CORBA::MARSHAL.new("unknown kind [#{rtc.kind}]",0,CORBA::COMPLETED_NO)
|
260
|
+
end
|
261
|
+
ensure
|
262
|
+
jdynany.destroy
|
263
|
+
end
|
264
|
+
end
|
265
|
+
rescue ::NativeException
|
266
|
+
CORBA::Exception.native2r($!)
|
267
|
+
end
|
268
|
+
return rval
|
269
|
+
end # from_java
|
270
|
+
|
271
|
+
end # Any
|
272
|
+
end # CORBA
|
273
|
+
end # R2CORBA
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# iormap.rb - Java/JacORB IORMap 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
|
+
|
14
|
+
module R2CORBA
|
15
|
+
class IORMap
|
16
|
+
def initialize(orb)
|
17
|
+
@orb = orb
|
18
|
+
end
|
19
|
+
|
20
|
+
def map_ior(object_key, ior)
|
21
|
+
begin
|
22
|
+
@orb.orb_.addObjectKey(object_key, ior)
|
23
|
+
rescue ::NativeException
|
24
|
+
CORBA::Exception.native2r($!)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def unmap_ior(object_key)
|
29
|
+
begin
|
30
|
+
@orb.orb_.addObjectKey(object_key, nil)
|
31
|
+
rescue ::NativeException
|
32
|
+
CORBA::Exception.native2r($!)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# ORB.rb - Java/JacORB CORBA ORB 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
|
+
|
14
|
+
module R2CORBA
|
15
|
+
module CORBA
|
16
|
+
|
17
|
+
module ORB
|
18
|
+
|
19
|
+
## init() or init(arg1, arg2[, ...]) or init(orb_id, prop = {}) or init(argv, orb_id, prop={}) or init(argv, prop={})
|
20
|
+
def self.init(*args)
|
21
|
+
n_orb = if args.empty?
|
22
|
+
CORBA::Native::ORB.init
|
23
|
+
else
|
24
|
+
argv = []
|
25
|
+
orb_id = nil
|
26
|
+
prop = nil
|
27
|
+
a1, a2, a3 = args
|
28
|
+
if Array === a1
|
29
|
+
raise ArgumentError, "Incorrect nr. of arguments; #{args.size}" if args.size>3
|
30
|
+
argv = a1
|
31
|
+
orb_id = (Hash === a2 ? nil : a2)
|
32
|
+
prop = (Hash === a2 ? a2 : a3)
|
33
|
+
elsif args.size == 1 || Hash === a2
|
34
|
+
raise ArgumentError, "Incorrect nr. of arguments; #{args.size}" if args.size>2
|
35
|
+
orb_id = a1
|
36
|
+
prop = a2
|
37
|
+
else
|
38
|
+
argv = args
|
39
|
+
end
|
40
|
+
raise ArgumentError, "Invalid argument #{prop.class}; expected Hash" unless prop.nil? || Hash === prop
|
41
|
+
jprop = Java::JavaUtil::Properties.new
|
42
|
+
jprop.setProperty('ORBid', orb_id) if orb_id
|
43
|
+
prop.each { |k,v| jprop.setProperty(k.to_s, v.to_s) } if prop
|
44
|
+
@@cached_orb = CORBA::Native::ORB.init(argv.collect {|a| a.to_s }.to_java(:string), jprop)
|
45
|
+
end
|
46
|
+
@@wrapper_klass.new(n_orb)
|
47
|
+
end
|
48
|
+
|
49
|
+
#str ::String
|
50
|
+
#ret ::CORBA::Object
|
51
|
+
def string_to_object(str)
|
52
|
+
begin
|
53
|
+
begin
|
54
|
+
Object._wrap_native(self.orb_.string_to_object(str))
|
55
|
+
rescue ::NativeException
|
56
|
+
CORBA::Exception.native2r($!)
|
57
|
+
end
|
58
|
+
rescue CORBA::BAD_PARAM ## JacORB throws MARSHAL exception on invalid IORs which is not spec compliant
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# boolean wait_for_completion
|
64
|
+
# ret void
|
65
|
+
def shutdown(wait_for_completion = false)
|
66
|
+
if wait_for_completion
|
67
|
+
# need to start this in separate thread otherwise this will lead to deadlock
|
68
|
+
# (JacORB problem)
|
69
|
+
(Thread.new do
|
70
|
+
begin
|
71
|
+
self.orb_.shutdown(wait_for_completion)
|
72
|
+
rescue ::NativeException
|
73
|
+
CORBA::Exception.native2r($!)
|
74
|
+
end
|
75
|
+
end).join()
|
76
|
+
else
|
77
|
+
# need to start a shutdown *with* waiting in a thread because JacORB
|
78
|
+
# occasionally fails with a comm error when #shutdown(false) is called
|
79
|
+
# from within a servant callback
|
80
|
+
Thread.new do
|
81
|
+
begin
|
82
|
+
self.orb_.shutdown(true)
|
83
|
+
rescue ::NativeException
|
84
|
+
CORBA::Exception.native2r($!)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# custom R2CORBA extension : IORMap
|
91
|
+
|
92
|
+
def ior_map
|
93
|
+
@iormap ||= R2CORBA::IORMap.new(self)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end # CORBA
|
99
|
+
end # R2CORBA
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#--------------------------------------------------------------------
|
2
|
+
# Object.rb - Java/JacORB CORBA Object 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 Object
|
17
|
+
|
18
|
+
#ret InterfaceDef
|
19
|
+
def _get_interface()
|
20
|
+
raise ::CORBA::NO_IMPLEMENT
|
21
|
+
#ifdef_obj = self.objref_._get_interface_def rescue CORBA::Exception.native2r($!)
|
22
|
+
#(ifdef_obj = CORBA::Native::InterfaceDefHelper.narrow(ifdef_obj) rescue CORBA::Exception.native2r($!)) unless ifdef_obj.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
# ::String logical_type_id
|
26
|
+
# ret boolean
|
27
|
+
def _is_a?(logical_type_id)
|
28
|
+
raise CORBA::INV_OBJREF.new if self._is_nil?()
|
29
|
+
## JacORB's LocalObjects throw NO_IMPLEMENT on _is_a?() and _ids() is also not always defined
|
30
|
+
return true if self.objref_.is_a?(CORBA::Native::LocalObject) &&
|
31
|
+
(!self.objref_.respond_to?(:_ids) || self.objref_._ids().include?(logical_type_id))
|
32
|
+
begin
|
33
|
+
self.objref_._is_a(logical_type_id)
|
34
|
+
rescue ::NativeException
|
35
|
+
CORBA::Exception.native2r($!)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# ret ::String
|
40
|
+
def _repository_id()
|
41
|
+
raise CORBA::INV_OBJREF.new if self._is_nil?()
|
42
|
+
## if this object ref has already been narrowed
|
43
|
+
return self._interface_repository_id if self.respond_to?(:_interface_repository_id)
|
44
|
+
## ask the remote side
|
45
|
+
## have to do this ourselves since JacORB does not support this method
|
46
|
+
## and we can't use #invoke since this should work without narrowing
|
47
|
+
req = self._request('_repository_id')
|
48
|
+
req.set_return_type(CORBA._tc_string)
|
49
|
+
return req.invoke
|
50
|
+
end
|
51
|
+
|
52
|
+
#ret ::CORBA::Object
|
53
|
+
def _get_component()
|
54
|
+
raise CORBA::INV_OBJREF.new if self._is_nil?()
|
55
|
+
## ask the remote side
|
56
|
+
## have to do this ourselves since JacORB does not support this method
|
57
|
+
## and we can't use #invoke since this should work without narrowing
|
58
|
+
req = self._request('_component')
|
59
|
+
req.set_return_type(CORBA._tc_Object)
|
60
|
+
return req.invoke
|
61
|
+
end
|
62
|
+
|
63
|
+
#def PolicyType policy_type
|
64
|
+
# ret Policy
|
65
|
+
def _get_policy(policy_type)
|
66
|
+
raise ::CORBA::NO_IMPLEMENT
|
67
|
+
end
|
68
|
+
|
69
|
+
#PolicyList policies
|
70
|
+
#SetOverrideType set_add
|
71
|
+
#ret ::CORBA::Object
|
72
|
+
def _set_policy_overrides(policies, set_add )
|
73
|
+
raise ::CORBA::NO_IMPLEMENT
|
74
|
+
end
|
75
|
+
|
76
|
+
#int[] types
|
77
|
+
#ret PolicyList
|
78
|
+
def _get_policy_overrides(types)
|
79
|
+
raise ::CORBA::NO_IMPLEMENT
|
80
|
+
end
|
81
|
+
|
82
|
+
#PolicyList inconsistent_policies
|
83
|
+
#ret bool
|
84
|
+
def _validate_connection(inconsistent_policies)
|
85
|
+
raise ::CORBA::NO_IMPLEMENT
|
86
|
+
end
|
87
|
+
|
88
|
+
def _request(operation)
|
89
|
+
begin
|
90
|
+
CORBA::Request._wrap_native(self.objref_._request(operation.to_s), self)
|
91
|
+
rescue ::NativeException
|
92
|
+
CORBA::Exception.native2r($!)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end # Object
|
97
|
+
end # CORBA
|
98
|
+
end # R2CORBA
|