61 |
public RMIMarshalledObjectOutputStream(OutputStream objStream) throws IOException |
public RMIMarshalledObjectOutputStream(OutputStream objStream) throws IOException |
62 |
{ |
{ |
63 |
super(objStream); |
super(objStream); |
64 |
|
locBytesStream = new ByteArrayOutputStream(256); |
65 |
|
locStream = new ObjectOutputStream(locBytesStream); |
66 |
} |
} |
67 |
|
|
68 |
//This method overrides RMIObjectOutputStream's. |
//This method overrides RMIObjectOutputStream's. |
69 |
protected void setAnnotation(String annotation) throws IOException{ |
protected void setAnnotation(String annotation) throws IOException{ |
|
synchronized(this){ |
|
|
if(locStream == null){ |
|
|
locBytesStream = new ByteArrayOutputStream(); |
|
|
locStream = new ObjectOutputStream(locBytesStream); |
|
|
} |
|
|
} |
|
70 |
locStream.writeObject(annotation); |
locStream.writeObject(annotation); |
71 |
} |
} |
72 |
|
|
|
//This method overrides ObjectOutputStream's to replace Remote to RemoteStub |
|
|
protected Object replaceObject(Object obj) throws IOException |
|
|
{ |
|
|
if((obj instanceof Remote) && !(obj instanceof RemoteStub)) |
|
|
{ |
|
|
UnicastServerRef ref = new UnicastServerRef(new ObjID(), 0, null); |
|
|
try{ |
|
|
return ref.exportObject((Remote)obj); |
|
|
}catch(Exception e){} |
|
|
} |
|
|
return obj; |
|
|
} |
|
|
|
|
73 |
public void flush() throws IOException { |
public void flush() throws IOException { |
74 |
super.flush(); |
super.flush(); |
75 |
if(locStream != null) |
locStream.flush(); |
|
locStream.flush(); |
|
76 |
} |
} |
77 |
|
|
78 |
public byte[] getLocBytes(){ |
public byte[] getLocBytes(){ |
79 |
if(locStream != null) |
return locBytesStream.toByteArray(); |
|
return locBytesStream.toByteArray(); |
|
|
return null; |
|
80 |
} |
} |
81 |
|
|
82 |
} // End of RMIMarshalledObjectOutputStream |
} // End of RMIMarshalledObjectOutputStream |