38 |
|
|
39 |
package org.omg.CORBA; |
package org.omg.CORBA; |
40 |
|
|
41 |
import gnu.CORBA.CDR.uncObjectInputStream; |
import gnu.CORBA.CDR.Vio; |
|
import gnu.CORBA.CDR.uncObjectOutputStream; |
|
42 |
import gnu.CORBA.recordTypeCode; |
import gnu.CORBA.recordTypeCode; |
43 |
|
|
44 |
import org.omg.CORBA.portable.InputStream; |
import org.omg.CORBA.portable.InputStream; |
45 |
import org.omg.CORBA.portable.OutputStream; |
import org.omg.CORBA.portable.OutputStream; |
46 |
|
|
|
import java.io.IOException; |
|
|
import java.io.ObjectInputStream; |
|
|
import java.io.ObjectOutputStream; |
|
47 |
import java.io.Serializable; |
import java.io.Serializable; |
48 |
|
|
49 |
/** |
/** |
91 |
|
|
92 |
/** |
/** |
93 |
* Read the value base from the given input stream. |
* Read the value base from the given input stream. |
|
* This implementation initialises the {@link ObjectInputStream} |
|
|
* and reads from it. |
|
94 |
* |
* |
95 |
* @param istream a stream to read from. |
* @param input a stream to read from. |
96 |
* |
* |
97 |
* @return the loaded value. |
* @return the loaded value. |
98 |
* |
* |
99 |
* @throws MARSHAL if the reading has failed due any reason. |
* @throws MARSHAL if the reading has failed due any reason. |
100 |
*/ |
*/ |
101 |
public static Serializable read(InputStream output) |
public static Serializable read(InputStream input) |
102 |
{ |
{ |
103 |
// Explicitly prevent the stream from closing as we may need |
return Vio.read(input); |
|
// to read the subsequent bytes as well. Stream may be auto-closed |
|
|
// in its finalizer. |
|
|
try |
|
|
{ |
|
|
ObjectInputStream oin = new uncObjectInputStream(output); |
|
|
return (Serializable) oin.readObject(); |
|
|
} |
|
|
catch (Exception ex) |
|
|
{ |
|
|
throw new MARSHAL(ex + ":" + ex.getMessage()); |
|
|
} |
|
104 |
} |
} |
105 |
|
|
106 |
/** |
/** |
114 |
} |
} |
115 |
|
|
116 |
/** |
/** |
117 |
* Write the value base into the given stream. This implementation |
* Write the value base into the given stream. |
|
* initialises the {@link ObjectOutputStream} and writes through it. |
|
118 |
* |
* |
119 |
* @param ostream a stream to write to. |
* If the passed value implements the {@link CustomMarshal}, |
120 |
|
* the helper uses {@link CustomMarshal#marshal} |
121 |
|
* to write the content in a user defined way. Otherwise, |
122 |
|
* this implementation initialises the {@link ObjectOutputStream} |
123 |
|
* and writes through it. |
124 |
|
* |
125 |
|
* @param output a stream to write to. |
126 |
* |
* |
127 |
* @param value a value to write. |
* @param value a value to write. |
128 |
* |
* |
129 |
* @throws MARSHAL if the writing failed due any reason. |
* @throws MARSHAL if the writing failed due any reason. |
130 |
*/ |
*/ |
131 |
public static void write(OutputStream input, Serializable value) |
public static void write(OutputStream output, Serializable value) |
132 |
{ |
{ |
133 |
// Explicitly prevent the stream from closing as we may need |
Vio.write(output, value); |
|
// to read the subsequent bytes as well. Stream may be auto-closed |
|
|
// in its finalizer. |
|
|
try |
|
|
{ |
|
|
ObjectOutputStream oout = new uncObjectOutputStream(input); |
|
|
oout.writeObject(value); |
|
|
oout.flush(); |
|
|
} |
|
|
catch (IOException ex) |
|
|
{ |
|
|
throw new MARSHAL(ex + ":" + ex.getMessage()); |
|
|
} |
|
134 |
} |
} |
135 |
} |
} |