home *** CD-ROM | disk | FTP | other *** search
- package sun.rmi.transport;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.ObjectInput;
- import java.io.ObjectOutput;
- import java.io.StreamCorruptedException;
- import java.rmi.MarshalException;
- import java.rmi.RemoteException;
- import java.rmi.UnmarshalException;
- import java.rmi.server.LogStream;
- import java.rmi.server.ObjID;
- import java.rmi.server.RemoteCall;
-
- public class StreamRemoteCall implements RemoteCall {
- // $FF: renamed from: in sun.rmi.transport.ConnectionInputStream
- private ConnectionInputStream field_0;
- private ConnectionOutputStream out;
- private Connection conn;
- private boolean resultStarted = false;
-
- public StreamRemoteCall(Connection var1) {
- this.conn = var1;
- }
-
- public StreamRemoteCall(Connection var1, ObjID var2, int var3, long var4) throws RemoteException {
- try {
- this.conn = var1;
- if (Transport.logLevel >= 20) {
- LogStream.log("transport").println("StreamRemoteCall.<init>: write remote call header...");
- }
-
- DataOutputStream var6 = new DataOutputStream(this.conn.getOutputStream());
- var6.writeByte(80);
- this.getOutputStream();
- var2.write(this.out);
- this.out.writeInt(var3);
- this.out.writeLong(var4);
- } catch (IOException var7) {
- throw new MarshalException("Error marshaling call header", var7);
- }
- }
-
- public Connection getConnection() {
- return this.conn;
- }
-
- public ObjectOutput getOutputStream() throws IOException {
- return this.getOutputStream(false);
- }
-
- private ObjectOutput getOutputStream(boolean var1) throws IOException {
- if (this.out == null) {
- if (Transport.logLevel >= 20) {
- LogStream.log("transport").println("StreamRemoteCall.getOutputStream");
- }
-
- this.out = new ConnectionOutputStream(this.conn.getOutputStream(), var1);
- }
-
- return this.out;
- }
-
- public void releaseOutputStream() throws IOException {
- try {
- if (this.out != null) {
- this.out.flush();
- this.out.done(this.conn);
- }
-
- this.conn.releaseOutputStream();
- } finally {
- this.out = null;
- }
-
- }
-
- public ObjectInput getInputStream() throws IOException {
- if (this.field_0 == null) {
- if (Transport.logLevel >= 20) {
- LogStream.log("transport").println("StreamRemoteCall.getInputStream");
- }
-
- this.field_0 = new ConnectionInputStream(this.conn.getInputStream());
- }
-
- return this.field_0;
- }
-
- public void releaseInputStream() throws IOException {
- try {
- if (this.field_0 != null) {
- this.field_0.registerRefs();
- this.field_0.done(this.conn);
- }
-
- this.conn.releaseInputStream();
- } finally {
- this.field_0 = null;
- }
-
- }
-
- public ObjectOutput getResultStream(boolean var1) throws IOException, StreamCorruptedException {
- if (this.resultStarted) {
- throw new StreamCorruptedException("result already in progress");
- } else {
- this.resultStarted = true;
- DataOutputStream var2 = new DataOutputStream(this.conn.getOutputStream());
- var2.writeByte(81);
- this.getOutputStream(true);
- if (var1) {
- this.out.writeByte(1);
- } else {
- this.out.writeByte(2);
- }
-
- this.out.writeID();
- return this.out;
- }
- }
-
- public void executeCall() throws Exception {
- byte var1;
- try {
- this.releaseOutputStream();
- DataInputStream var2 = new DataInputStream(this.conn.getInputStream());
- byte var3 = var2.readByte();
- if (var3 != 81) {
- if (Transport.logLevel >= 10) {
- LogStream.log("transport").println("StreamRemoteCall.executeCall: transport return code invalid: " + var3);
- }
-
- throw new UnmarshalException("Transport return code invalid");
- }
-
- this.getInputStream();
- var1 = this.field_0.readByte();
- this.field_0.readID();
- } catch (UnmarshalException var5) {
- throw var5;
- } catch (IOException var6) {
- throw new UnmarshalException("Error unmarshaling return header");
- }
-
- switch (var1) {
- case 1:
- return;
- case 2:
- Object var7;
- try {
- var7 = this.field_0.readObject();
- } catch (Exception var4) {
- throw new UnmarshalException("Error unmarshaling return", var4);
- }
-
- if (var7 instanceof Exception) {
- throw (Exception)var7;
- }
-
- throw new UnmarshalException("Return type not Exception");
- default:
- if (Transport.logLevel >= 10) {
- LogStream.log("transport").println("StreamRemoteCall.executeCall: return code invalid: " + var1);
- }
-
- throw new UnmarshalException("Return code invalid");
- }
- }
-
- public void done() throws IOException {
- this.releaseInputStream();
- }
- }
-