Java Code Examples for org.omg.CORBA.portable.OutputStream#create_input_stream()
The following examples show how to use
org.omg.CORBA.portable.OutputStream#create_input_stream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StubIORImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public StubIORImpl( org.omg.CORBA.Object obj ) { // write the IOR to an OutputStream and get an InputStream OutputStream ostr = StubAdapter.getORB( obj ).create_output_stream(); ostr.write_Object(obj); InputStream istr = ostr.create_input_stream(); // read the IOR components back from the stream int typeLength = istr.read_long(); typeData = new byte[typeLength]; istr.read_octet_array(typeData, 0, typeLength); int numProfiles = istr.read_long(); profileTags = new int[numProfiles]; profileData = new byte[numProfiles][]; for (int i = 0; i < numProfiles; i++) { profileTags[i] = istr.read_long(); profileData[i] = new byte[istr.read_long()]; istr.read_octet_array(profileData[i], 0, profileData[i].length); } }
Example 2
Source File: StubIORImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public Delegate getDelegate( ORB orb ) { // write the IOR components to an org.omg.CORBA.portable.OutputStream OutputStream ostr = orb.create_output_stream(); ostr.write_long(typeData.length); ostr.write_octet_array(typeData, 0, typeData.length); ostr.write_long(profileTags.length); for (int i = 0; i < profileTags.length; i++) { ostr.write_long(profileTags[i]); ostr.write_long(profileData[i].length); ostr.write_octet_array(profileData[i], 0, profileData[i].length); } InputStream istr = ostr.create_input_stream() ; // read the IOR back from the stream org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object(); return StubAdapter.getDelegate( obj ) ; }
Example 3
Source File: AnyImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * returns an input stream that an Any value can be marshaled out of. * * @result the InputStream to marshal value of Any out of. */ public org.omg.CORBA.portable.InputStream create_input_stream() { // // We create a new InputStream so that multiple threads can call here // and read the streams in parallel without thread safety problems. // //debug.log ("create_input_stream"); if (AnyImpl.isStreamed[realType().kind().value()]) { return stream.dup(); } else { OutputStream os = (OutputStream)orb.create_output_stream(); TCUtility.marshalIn(os, realType(), value, object); return os.create_input_stream(); } }
Example 4
Source File: StubIORImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public StubIORImpl( org.omg.CORBA.Object obj ) { // write the IOR to an OutputStream and get an InputStream OutputStream ostr = StubAdapter.getORB( obj ).create_output_stream(); ostr.write_Object(obj); InputStream istr = ostr.create_input_stream(); // read the IOR components back from the stream int typeLength = istr.read_long(); typeData = new byte[typeLength]; istr.read_octet_array(typeData, 0, typeLength); int numProfiles = istr.read_long(); profileTags = new int[numProfiles]; profileData = new byte[numProfiles][]; for (int i = 0; i < numProfiles; i++) { profileTags[i] = istr.read_long(); profileData[i] = new byte[istr.read_long()]; istr.read_octet_array(profileData[i], 0, profileData[i].length); } }
Example 5
Source File: StubIORImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public Delegate getDelegate( ORB orb ) { // write the IOR components to an org.omg.CORBA.portable.OutputStream OutputStream ostr = orb.create_output_stream(); ostr.write_long(typeData.length); ostr.write_octet_array(typeData, 0, typeData.length); ostr.write_long(profileTags.length); for (int i = 0; i < profileTags.length; i++) { ostr.write_long(profileTags[i]); ostr.write_long(profileData[i].length); ostr.write_octet_array(profileData[i], 0, profileData[i].length); } InputStream istr = ostr.create_input_stream() ; // read the IOR back from the stream org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object(); return StubAdapter.getDelegate( obj ) ; }
Example 6
Source File: StubIORImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public StubIORImpl( org.omg.CORBA.Object obj ) { // write the IOR to an OutputStream and get an InputStream OutputStream ostr = StubAdapter.getORB( obj ).create_output_stream(); ostr.write_Object(obj); InputStream istr = ostr.create_input_stream(); // read the IOR components back from the stream int typeLength = istr.read_long(); typeData = new byte[typeLength]; istr.read_octet_array(typeData, 0, typeLength); int numProfiles = istr.read_long(); profileTags = new int[numProfiles]; profileData = new byte[numProfiles][]; for (int i = 0; i < numProfiles; i++) { profileTags[i] = istr.read_long(); profileData[i] = new byte[istr.read_long()]; istr.read_octet_array(profileData[i], 0, profileData[i].length); } }
Example 7
Source File: StubIORImpl.java From JDKSourceCode1.8 with MIT License | 6 votes |
public Delegate getDelegate( ORB orb ) { // write the IOR components to an org.omg.CORBA.portable.OutputStream OutputStream ostr = orb.create_output_stream(); ostr.write_long(typeData.length); ostr.write_octet_array(typeData, 0, typeData.length); ostr.write_long(profileTags.length); for (int i = 0; i < profileTags.length; i++) { ostr.write_long(profileTags[i]); ostr.write_long(profileData[i].length); ostr.write_octet_array(profileData[i], 0, profileData[i].length); } InputStream istr = ostr.create_input_stream() ; // read the IOR back from the stream org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object(); return StubAdapter.getDelegate( obj ) ; }
Example 8
Source File: AnyImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * returns an input stream that an Any value can be marshaled out of. * * @result the InputStream to marshal value of Any out of. */ public org.omg.CORBA.portable.InputStream create_input_stream() { // // We create a new InputStream so that multiple threads can call here // and read the streams in parallel without thread safety problems. // //debug.log ("create_input_stream"); if (AnyImpl.isStreamed[realType().kind().value()]) { return stream.dup(); } else { OutputStream os = (OutputStream)orb.create_output_stream(); TCUtility.marshalIn(os, realType(), value, object); return os.create_input_stream(); } }
Example 9
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadFixed() { if (System.getProperty("java.vendor").contains("IBM")) { //The ORB in the IBM jdk doesn't support writing fixed //to the stream. return; } OutputStream oStream = orb.create_output_stream(); // create the following fixed // fixed<5,2> oStream.write_fixed(new java.math.BigDecimal("12345.67").movePointRight(2)); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); Fixed fixedType = new Fixed(); fixedType.setDigits(5); fixedType.setScale(2); // These values don't matter to the outcome of the test but are needed during construction QName fixedName = new QName("TestFixed"); QName fixedIdlType = new QName("corbatm:TestFixed"); TypeCode fixedTC = orb.create_fixed_tc((short)fixedType.getDigits(), (short)fixedType.getScale()); CorbaFixedHandler obj = new CorbaFixedHandler(fixedName, fixedIdlType, fixedTC, fixedType); reader.readFixed(obj); assertEquals(obj.getValue(), new java.math.BigDecimal("12345.67")); }
Example 10
Source File: CorbaObjectWriterTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testWriteLongLong() { OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); Long longlongValue = Long.valueOf("-12345678900"); writer.writeLongLong(longlongValue); InputStream iStream = oStream.create_input_stream(); long ll = iStream.read_longlong(); assertTrue(ll == longlongValue.longValue()); }
Example 11
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadWString() { OutputStream oStream = orb.create_output_stream(); oStream.write_wstring("WString"); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); String wstringValue = reader.readWString(); assertEquals("WString", wstringValue); }
Example 12
Source File: CorbaObjectWriterTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testWriteArray() { int[] data = {1, 1, 2, 3, 5, 8, 13, 21}; // create an array of longs QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA); QName arrayIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "array", CorbaConstants.NP_WSDL_CORBA); Array arrayType = new Array(); arrayType.setBound(data.length); arrayType.setElemtype(longIdlType); // name and respoitory ID of the array are not needed for this test // build the object holder for an array. TypeCode arrayTC = orb.create_array_tc(data.length, orb.get_primitive_tc(TCKind.tk_long)); CorbaArrayHandler obj = new CorbaArrayHandler(new QName("Array"), arrayIdlType, arrayTC, arrayType); for (int i = 0; i < data.length; ++i) { CorbaPrimitiveHandler nestedObj = new CorbaPrimitiveHandler(new QName("item"), longIdlType, orb.get_primitive_tc(TCKind.tk_long), null); nestedObj.setValueFromData(Integer.toString(data[i])); obj.addElement(nestedObj); } OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); writer.writeArray(obj); InputStream iStream = oStream.create_input_stream(); for (int i = 0; i < data.length; ++i) { int val = iStream.read_long(); assertTrue(val == data[i]); } }
Example 13
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadOctet() { OutputStream oStream = orb.create_output_stream(); oStream.write_octet((byte)27); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); Byte octetValue = reader.readOctet(); assertTrue(octetValue.byteValue() == (byte)27); }
Example 14
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadBoolean() { OutputStream oStream = orb.create_output_stream(); oStream.write_boolean(true); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); Boolean boolValue = reader.readBoolean(); assertTrue(boolValue.booleanValue()); }
Example 15
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadULongLong() { OutputStream oStream = orb.create_output_stream(); oStream.write_ulonglong(-1000000000L); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); BigInteger ulonglongValue = reader.readULongLong(); assertEquals(1, ulonglongValue.signum()); }
Example 16
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadShort() { OutputStream oStream = orb.create_output_stream(); oStream.write_short((short)-100); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); Short shortValue = reader.readShort(); assertTrue(shortValue.shortValue() == (short)-100); }
Example 17
Source File: CorbaObjectWriterTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testWriteFloat() { OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); Float floatValue = Float.valueOf((float)123456.78); writer.writeFloat(floatValue); InputStream iStream = oStream.create_input_stream(); float f = iStream.read_float(); assertTrue(f == floatValue.floatValue()); }
Example 18
Source File: CorbaObjectWriterTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testWriteLong() { OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); Integer longValue = Integer.valueOf(-1234567); writer.writeLong(longValue); InputStream iStream = oStream.create_input_stream(); int l = iStream.read_long(); assertTrue(l == longValue.intValue()); }
Example 19
Source File: CorbaObjectReaderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testReadEnum() { OutputStream oStream = orb.create_output_stream(); // create the following enum // enum { RED, GREEN, BLUE }; oStream.write_long(1); InputStream iStream = oStream.create_input_stream(); CorbaObjectReader reader = new CorbaObjectReader(iStream); String[] enums = {"RED", "GREEN", "BLUE" }; Enum enumType = new Enum(); Enumerator enumRed = new Enumerator(); enumRed.setValue(enums[0]); Enumerator enumGreen = new Enumerator(); enumGreen.setValue(enums[1]); Enumerator enumBlue = new Enumerator(); enumBlue.setValue(enums[2]); enumType.getEnumerator().add(enumRed); enumType.getEnumerator().add(enumGreen); enumType.getEnumerator().add(enumBlue); // These values don't matter to the outcome of the test but are needed during construction QName enumName = new QName("TestEnum"); QName enumIdlType = new QName("corbatm:TestEnum"); TypeCode enumTC = orb.create_enum_tc("IDL:TestEnum:1.0", enumName.getLocalPart(), enums); CorbaEnumHandler obj = new CorbaEnumHandler(enumName, enumIdlType, enumTC, enumType); reader.readEnum(obj); assertEquals(obj.getValue(), enums[1]); }
Example 20
Source File: CorbaObjectWriterTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testWriteStruct() { // create the following struct // struct TestStruct { // long member1; // string member2; // boolean member3; // } int member1 = 12345; String member2 = "54321"; boolean member3 = true; QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "struct", CorbaConstants.NP_WSDL_CORBA); QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA); QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA); QName boolIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA); Struct structType = new Struct(); structType.setName("TestStruct"); MemberType m1 = new MemberType(); m1.setIdltype(longIdlType); m1.setName("member1"); MemberType m2 = new MemberType(); m2.setIdltype(stringIdlType); m2.setName("member2"); MemberType m3 = new MemberType(); m3.setIdltype(boolIdlType); m3.setName("member3"); structType.getMember().add(m1); structType.getMember().add(m2); structType.getMember().add(m3); // build the object holder StructMember[] structMembers = new StructMember[3]; structMembers[0] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_long), null); structMembers[1] = new StructMember("member2", orb.get_primitive_tc(TCKind.tk_string), null); structMembers[2] = new StructMember("member3", orb.get_primitive_tc(TCKind.tk_boolean), null); TypeCode structTC = orb.create_struct_tc("IDL:org.apache.cxf.TestStruct/1.0", "TestStruct", structMembers); CorbaStructHandler obj = new CorbaStructHandler(new QName("TestStruct"), structIdlType, structTC, structType); CorbaPrimitiveHandler memberObj1 = new CorbaPrimitiveHandler(new QName("member1"), longIdlType, structMembers[0].type, null); CorbaPrimitiveHandler memberObj2 = new CorbaPrimitiveHandler(new QName("member2"), stringIdlType, structMembers[1].type, null); CorbaPrimitiveHandler memberObj3 = new CorbaPrimitiveHandler(new QName("member3"), boolIdlType, structMembers[2].type, null); memberObj1.setValueFromData(Integer.toString(member1)); memberObj2.setValueFromData(member2); memberObj3.setValueFromData(Boolean.toString(member3)); obj.addMember(memberObj1); obj.addMember(memberObj2); obj.addMember(memberObj3); OutputStream oStream = orb.create_output_stream(); CorbaObjectWriter writer = new CorbaObjectWriter(oStream); writer.writeStruct(obj); InputStream iStream = oStream.create_input_stream(); int readMember1 = iStream.read_long(); assertTrue(readMember1 == member1); String readMember2 = iStream.read_string(); assertEquals(readMember2, member2); boolean readMember3 = iStream.read_boolean(); assertTrue(readMember3 == member3); }