harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r407724 [10/11] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/rmi/make/ modules/rmi/src/main/java/java/rmi/ modules/rmi/src/main/java/java/rmi/registry/ modules/rmi/src/main/java/java/rmi/server/ modules/rmi/src/main/java/o...
Date Fri, 19 May 2006 06:00:56 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Header.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Header.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Header.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Header.java Thu May 18 23:00:52 2006
@@ -1,114 +1,114 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import ar.org.fitc.rmi.transport.ProtocolException;
-
-/**
- * A class representing the Header of the JRMI protocol.
- * 
- * @author Gustavo Petri
- */
-public class Header {
-
-	/**
-	 * ID for serialization purposes
-	 */
-	private static final long serialVersionUID = 1L;
-
-	/**
-	 * A byte array representing the version of the JRMI protocol
-	 */
-	static final byte[] JRMI_PROTOCOL_VERSION = new byte[] { 0x00, 0x01 };
-
-	/**
-	 * A {@link ar.org.fitc.rmi.transport.jrmp.ProtocolType} object that
-	 * indicates the header type
-	 */
-	private ProtocolType type;
-
-	/**
-	 * Constructor. Does nothing
-	 */
-	public Header() {
-		super();
-	}
-
-	/**
-	 * Constructor. Sets {@link Header#type type} with the parameter
-	 * <code>type</code>
-	 * 
-	 * @param type
-	 */
-	public Header(ProtocolType type) {
-		this.type = type;
-	}
-
-	/**
-	 * Returns the protocol type.
-	 * 
-	 * @return the wrapped {@link Header#type type}
-	 */
-	public ProtocolType getProtocolType() {
-		return type;
-	}
-
-	/**
-	 * Writes the header representation on the stream.
-	 * 
-	 * @param out
-	 *            the output stream to write
-	 * @throws IOException
-	 *             if an exception occurs when writing on the stream
-	 */
-	public final void writeExternal(DataOutputStream out) throws IOException {
-		out.write(ProtocolHeader.JRMI_PROTOCOL_HEADER.getValue());
-		out.write(JRMI_PROTOCOL_VERSION);
-		out.write(type.getValue());
-	}
-
-	/**
-	 * Reads a header from the input stream, and sets the {@link Header#type}
-	 * attribute to the received protocol type.
-	 * 
-	 * @param in
-	 *            the input stream used to read the data
-	 * @throws IOException
-	 *             if an exception occurs reading the header bytes
-	 */
-	public final void readExternal(DataInputStream in) throws IOException {
-
-		if (type.equals(ProtocolType.SINGLE_OP)) {
-			for (byte b : ProtocolHeader.JRMI_PROTOCOL_HEADER.getValue()) {
-				if (in.readByte() != b) {
-					throw new ProtocolException(
-							"Error reading JRMP protocol header");
-				}
-			}
-		}
-		for (byte b : JRMI_PROTOCOL_VERSION) {
-			if (in.readByte() != b) {
-				throw new ProtocolException(
-						"Error reading JRMP protocol header");
-			}
-		}
-		type = ProtocolType.createProtocolType(in.readByte());
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.harmony.rmi.internal.transport.ProtocolException;
+
+/**
+ * A class representing the Header of the JRMI protocol.
+ * 
+ * @author Gustavo Petri
+ */
+public class Header {
+
+	/**
+	 * ID for serialization purposes
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * A byte array representing the version of the JRMI protocol
+	 */
+	static final byte[] JRMI_PROTOCOL_VERSION = new byte[] { 0x00, 0x01 };
+
+	/**
+	 * A {@link org.apache.harmony.rmi.internal.transport.jrmp.ProtocolType} object that
+	 * indicates the header type
+	 */
+	private ProtocolType type;
+
+	/**
+	 * Constructor. Does nothing
+	 */
+	public Header() {
+		super();
+	}
+
+	/**
+	 * Constructor. Sets {@link Header#type type} with the parameter
+	 * <code>type</code>
+	 * 
+	 * @param type
+	 */
+	public Header(ProtocolType type) {
+		this.type = type;
+	}
+
+	/**
+	 * Returns the protocol type.
+	 * 
+	 * @return the wrapped {@link Header#type type}
+	 */
+	public ProtocolType getProtocolType() {
+		return type;
+	}
+
+	/**
+	 * Writes the header representation on the stream.
+	 * 
+	 * @param out
+	 *            the output stream to write
+	 * @throws IOException
+	 *             if an exception occurs when writing on the stream
+	 */
+	public final void writeExternal(DataOutputStream out) throws IOException {
+		out.write(ProtocolHeader.JRMI_PROTOCOL_HEADER.getValue());
+		out.write(JRMI_PROTOCOL_VERSION);
+		out.write(type.getValue());
+	}
+
+	/**
+	 * Reads a header from the input stream, and sets the {@link Header#type}
+	 * attribute to the received protocol type.
+	 * 
+	 * @param in
+	 *            the input stream used to read the data
+	 * @throws IOException
+	 *             if an exception occurs reading the header bytes
+	 */
+	public final void readExternal(DataInputStream in) throws IOException {
+
+		if (type.equals(ProtocolType.SINGLE_OP)) {
+			for (byte b : ProtocolHeader.JRMI_PROTOCOL_HEADER.getValue()) {
+				if (in.readByte() != b) {
+					throw new ProtocolException(
+							"Error reading JRMP protocol header");
+				}
+			}
+		}
+		for (byte b : JRMI_PROTOCOL_VERSION) {
+			if (in.readByte() != b) {
+				throw new ProtocolException(
+						"Error reading JRMP protocol header");
+			}
+		}
+		type = ProtocolType.createProtocolType(in.readByte());
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/HeaderResponse.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/HeaderResponse.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/HeaderResponse.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/HeaderResponse.java Thu May 18 23:00:52 2006
@@ -1,91 +1,91 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import ar.org.fitc.rmi.transport.ProtocolException;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * An enum representing the valid header responses of the JRMP protocol
- * 
- * @author Gustavo Petri
- * 
- */
-class HeaderResponse {
-
-	/**
-	 * A 0x4e byte representing the protocol acknowledge value
-	 */
-	static final HeaderResponse PROTOCOL_ACK = 
-        new HeaderResponse((byte) 0x4e);
-    
-	/**
-	 * A 0x4f byte representing the protocol not supported value
-	 */
-    static final HeaderResponse PROTOCOL_NOT_SUPPORTED = 
-        new HeaderResponse((byte) 0x4f);
-
-	/**
-	 * The current value
-	 */
-	private byte value;
-
-	/**
-	 * Private constructor, sets the internal {@link HeaderResponse#value} 
-	 * 
-	 * @param value
-	 *            the value for this enum
-	 */
-	private HeaderResponse(byte value) {
-		this.value = value;
-	}
-
-	/**
-	 * Getter method which returns the <code>byte</code> value of this enum
-	 * 
-	 * @return the {@link HeaderResponse#value} of this enum
-	 */
-	final byte getValue() {
-		return value;
-	}
-
-	/**
-	 * Creates a new {@link HeaderResponse}
-	 * 
-	 * @param value
-	 *            the <code>byte</code> value of the {@link HeaderResponse}
-	 * @return the new {@link HeaderResponse}
-	 * @throws ProtocolException
-	 *             if the <code>value</code> parameters is not a valid JRMP
-	 *             header response value
-	 */
-	static final HeaderResponse createHeaderResponse(byte value)
-			throws ProtocolException {
-		if (value == PROTOCOL_ACK.getValue()) {
-			return PROTOCOL_ACK;
-		} else if (value == PROTOCOL_NOT_SUPPORTED.getValue()) {
-			return PROTOCOL_NOT_SUPPORTED;
-		} else {
-			throw new ProtocolException("Unrecognized Header Response: "
-					+ Integer.toHexString(value));
-		}
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import org.apache.harmony.rmi.internal.transport.ProtocolException;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * An enum representing the valid header responses of the JRMP protocol
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+class HeaderResponse {
+
+	/**
+	 * A 0x4e byte representing the protocol acknowledge value
+	 */
+	static final HeaderResponse PROTOCOL_ACK = 
+        new HeaderResponse((byte) 0x4e);
+    
+	/**
+	 * A 0x4f byte representing the protocol not supported value
+	 */
+    static final HeaderResponse PROTOCOL_NOT_SUPPORTED = 
+        new HeaderResponse((byte) 0x4f);
+
+	/**
+	 * The current value
+	 */
+	private byte value;
+
+	/**
+	 * Private constructor, sets the internal {@link HeaderResponse#value} 
+	 * 
+	 * @param value
+	 *            the value for this enum
+	 */
+	private HeaderResponse(byte value) {
+		this.value = value;
+	}
+
+	/**
+	 * Getter method which returns the <code>byte</code> value of this enum
+	 * 
+	 * @return the {@link HeaderResponse#value} of this enum
+	 */
+	final byte getValue() {
+		return value;
+	}
+
+	/**
+	 * Creates a new {@link HeaderResponse}
+	 * 
+	 * @param value
+	 *            the <code>byte</code> value of the {@link HeaderResponse}
+	 * @return the new {@link HeaderResponse}
+	 * @throws ProtocolException
+	 *             if the <code>value</code> parameters is not a valid JRMP
+	 *             header response value
+	 */
+	static final HeaderResponse createHeaderResponse(byte value)
+			throws ProtocolException {
+		if (value == PROTOCOL_ACK.getValue()) {
+			return PROTOCOL_ACK;
+		} else if (value == PROTOCOL_NOT_SUPPORTED.getValue()) {
+			return PROTOCOL_NOT_SUPPORTED;
+		} else {
+			throw new ProtocolException("Unrecognized Header Response: "
+					+ Integer.toHexString(value));
+		}
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Message.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Message.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Message.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/Message.java Thu May 18 23:00:52 2006
@@ -1,334 +1,334 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.rmi.MarshalException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.UnmarshalException;
-import java.rmi.server.ObjID;
-import java.rmi.server.UID;
-
-import ar.org.fitc.rmi.runtime.RemoteReferenceManager;
-import ar.org.fitc.rmi.transport.ProtocolException;
-import ar.org.fitc.rmi.transport.RMIObjectInputStream;
-import ar.org.fitc.rmi.transport.RMIObjectOutputStream;
-
-/**
- * Encapsulates all the messages that a RMI Client can send. It is a Tagged 
- * Union Type.
- * 
- * @author Gustavo Petri
- */
-public final class Message {
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * This constant is used as a part of the JRMI protocol
-     */
-    private static final int UNUSED_OPERATION = -1;
-
-    /*
-     * Data Structures used for a Call message.
-     */
-    /**
-     * The hash of the method to be invoked
-     */
-    private long hash;
-
-    /**
-     * The {@link ObjID} of the Object to which a method will be invoked
-     */
-    private ObjID objID;
-
-    /**
-     * The operation number of the operation to be invoked (Actually not used)
-     */
-    private int operation;
-
-    /**
-     * Argumenst to execute the method 
-     */
-    private Object[] values;
-    
-    /**
-     * Type of the message to be sent. Defines the type in the tagged union
-     */
-    private MessageType type;
-
-    /*
-     * UID used to for the DGCAck message.
-     */
-    /**
-     * {@link UID} for DGCAck purposes. 
-     */
-    private UID uid;
-
-    /**
-     * Constructs a Ping Message
-     */
-    public Message() {
-        this.type = MessageType.PING;
-        this.operation = UNUSED_OPERATION;
-    }
-
-    /**
-     * Constructs a Call message
-     * 
-     * @param objID 
-     *          the identifier of the Object which's method will be executed 
-     * @param hash 
-     *          the hash of the method to be executed
-     * @param values 
-     *          the arguments to execute the method
-     */
-    public Message(ObjID objID, long hash, Object... values) {
-        this.type = MessageType.CALL;
-        this.operation = UNUSED_OPERATION;
-        this.objID = objID;
-        this.hash = hash;
-        this.values = values;
-    }
-
-    /**
-     * Constructs a DGCAck message
-     * @param uid
-     *          the {@link UID} to issue the DGCAck
-     */
-    public Message(UID uid) {
-        this.type = MessageType.DGCACK;
-        this.uid = uid;
-    }
-
-    /**
-     * Reads a Call message
-     * @param in 
-     *          the {@link java.io.InputStream} to be read
-     * @throws UnmarshalException 
-     *          if not able to read the Call
-     * @throws NoSuchObjectException
-     *          if the object ID is not exported in this server  
-     */
-    private final void readCall(DataInputStream in) throws UnmarshalException,
-            NoSuchObjectException {
-        RMIObjectInputStream objIn;
-        RemoteReferenceManager refMgr;
-        int argsCount = 0;
-
-        try {
-            objIn = new RMIObjectInputStream(in);
-            this.objID = ObjID.read(objIn);
-            this.operation = objIn.readInt();
-            this.hash = objIn.readLong();
-        } catch (IOException e) {
-            throw new UnmarshalException("I/O Error Unmarshaling Call Header",
-                    e);
-        }
-        refMgr = RemoteReferenceManager.getRemoteReferenceManager();
-        argsCount = refMgr.getArgsCount(objID, hash);
-        values = new Object[argsCount];
-        try {
-            for (int i = 0; i < argsCount; i++) {
-                values[i] = objIn.readObject();
-            }
-        } catch (ClassNotFoundException e) {
-            throw new UnmarshalException(
-                    "I/O Error Unmarshaling the Arguments", e);
-        } catch (IOException e) {
-            throw new UnmarshalException(
-                    "I/O Error Unmarshaling the Arguments", e);
-        }
-    }
-
-    /**
-     * Reads a DGCAck message
-     * @param in 
-     *          the {@link java.io.InputStream} to be read
-     * @throws ProtocolException
-     *          if not able to read the DGCAck
-     */
-    private final void readDGCAck(DataInputStream in) throws ProtocolException {
-        try {
-            uid = UID.read(in);
-        } catch (IOException e) {
-            throw new ProtocolException("I/O Error Reading the DGCAck");
-        }
-    }
-
-    /**
-     * Writes a DGCAck 
-     * @param out
-     *          the {@link java.io.OutputStream} to be written
-     * @throws ProtocolException
-     *          if not able to write the DGCAck
-     */
-    private final void writeDgcAck(DataOutputStream out)
-            throws ProtocolException {
-        try {
-            out.writeByte(MessageType.DGCACK.getValue());
-            uid.write(out);
-        } catch (IOException e) {
-            throw new ProtocolException("I/O Error Sending DGCAck", e);
-        }
-    }
-
-    /**
-     * Writes a Ping message
-     * @param out
-     *          the {@link java.io.OutputStream} to be written
-     * @throws ProtocolException
-     *          if not able to write the Ping
-     */
-    private final void writePing(DataOutputStream out) throws ProtocolException {
-        try {
-            out.writeByte(MessageType.PING.getValue());
-        } catch (IOException e) {
-            throw new ProtocolException("Socket Closed while pinging", e);
-        }
-    }
-
-    /**
-     * Writes a Call message
-     * @param out
-     *          the {@link java.io.OutputStream} to be written
-     * @throws MarshalException
-     *          if not able to write the Call
-     */
-    private final void writeCall(DataOutputStream out) throws MarshalException {
-
-        RMIObjectOutputStream objOut = null;
-        try {
-            out.writeByte(MessageType.CALL.getValue());
-            objOut = new RMIObjectOutputStream(out);
-            objID.write(objOut);
-            objOut.writeInt(operation);
-            objOut.writeLong(hash);
-        } catch (Exception e) {
-            throw new MarshalException("I/O Error Marshaling Call Header", e);
-        }
-        try {
-            if (values != null)
-                for (Object o : values) {
-                    objOut.writeObject(o);
-                }
-        } catch (Exception e) {
-            throw new MarshalException("I/O Error Marshaling Arguments", e);
-        } finally {
-            try {
-                objOut.drain();
-            } catch (IOException e) {
-                throw new MarshalException("I/O Error Marshaling Arguments", e);
-            }
-        }
-    }
-        
-    /**
-     * Gets the arguments of a Call
-     * @return 
-     *          the arguments of a Call
-     */
-    public final Object[] getArguments() {
-        return values;
-    }
-
-    /**
-     * Gets the hash of a mathod Call
-     * @return the hash of a mathod Call
-     */
-    public final long getHash() {
-        return hash;
-    }
-
-    /**
-     * Gets the {@link ObjID} of a mathod Call
-     * @return 
-     *          the {@link ObjID} of a mathod Call
-     */
-    public final ObjID getObjID() {
-        return objID;
-    }
-
-    /**
-     * Gets the Operation number of a mathod to be Called
-     * @return 
-     *          the Operation number of a mathod to be Called
-     */
-    public final int getOperation() {
-        return operation;
-    }
-
-    /**
-     * Gets the message type of this message
-     * @return the message type of this message
-     */
-    public final MessageType getType() {
-        return type;
-    }
-
-    /**
-     * Gets the UID of a DGCAck
-     * @return the UID of a DGCAck
-     */
-    public final UID getUID() {
-        return uid;
-    }
-
-    /**
-     * Reads a message from the specified {@link DataInputStream}
-     * @param in
-     *          the {@link DataInputStream} to be read
-     * @throws IOException
-     *          if unable to read the message
-     */
-    public final void readExternal(DataInputStream in) throws IOException {
-
-        type = MessageType.createMessageType(in.readByte());
-        if (type.equals(MessageType.CALL)) {
-            readCall(in);
-        } else if (type.equals(MessageType.DGCACK)) {
-            readDGCAck(in);
-        } else if (type.equals(MessageType.PING)) {
-        } else {
-            throw new ProtocolException("Message not supported");
-        }
-    }
-
-    /**
-     * Writes the Message to the specified {@link DataOutputStream}
-     * @param out 
-     *          the {@link DataOutputStream} to be written 
-     * @throws IOException
-     *          if unable to write the Message
-     */
-    public final void writeExternal(DataOutputStream out) throws IOException {
-
-        if (type == MessageType.CALL) {
-            writeCall(out);
-        } else if (type == MessageType.PING) {
-            writePing(out);
-        } else if (type == MessageType.DGCACK) {
-            writeDgcAck(out);
-        } else {
-            throw new ProtocolException("Message not supported");
-        }
-    }
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.rmi.MarshalException;
+import java.rmi.NoSuchObjectException;
+import java.rmi.UnmarshalException;
+import java.rmi.server.ObjID;
+import java.rmi.server.UID;
+
+import org.apache.harmony.rmi.internal.runtime.RemoteReferenceManager;
+import org.apache.harmony.rmi.internal.transport.ProtocolException;
+import org.apache.harmony.rmi.internal.transport.RMIObjectInputStream;
+import org.apache.harmony.rmi.internal.transport.RMIObjectOutputStream;
+
+/**
+ * Encapsulates all the messages that a RMI Client can send. It is a Tagged 
+ * Union Type.
+ * 
+ * @author Gustavo Petri
+ */
+public final class Message {
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * This constant is used as a part of the JRMI protocol
+     */
+    private static final int UNUSED_OPERATION = -1;
+
+    /*
+     * Data Structures used for a Call message.
+     */
+    /**
+     * The hash of the method to be invoked
+     */
+    private long hash;
+
+    /**
+     * The {@link ObjID} of the Object to which a method will be invoked
+     */
+    private ObjID objID;
+
+    /**
+     * The operation number of the operation to be invoked (Actually not used)
+     */
+    private int operation;
+
+    /**
+     * Argumenst to execute the method 
+     */
+    private Object[] values;
+    
+    /**
+     * Type of the message to be sent. Defines the type in the tagged union
+     */
+    private MessageType type;
+
+    /*
+     * UID used to for the DGCAck message.
+     */
+    /**
+     * {@link UID} for DGCAck purposes. 
+     */
+    private UID uid;
+
+    /**
+     * Constructs a Ping Message
+     */
+    public Message() {
+        this.type = MessageType.PING;
+        this.operation = UNUSED_OPERATION;
+    }
+
+    /**
+     * Constructs a Call message
+     * 
+     * @param objID 
+     *          the identifier of the Object which's method will be executed 
+     * @param hash 
+     *          the hash of the method to be executed
+     * @param values 
+     *          the arguments to execute the method
+     */
+    public Message(ObjID objID, long hash, Object... values) {
+        this.type = MessageType.CALL;
+        this.operation = UNUSED_OPERATION;
+        this.objID = objID;
+        this.hash = hash;
+        this.values = values;
+    }
+
+    /**
+     * Constructs a DGCAck message
+     * @param uid
+     *          the {@link UID} to issue the DGCAck
+     */
+    public Message(UID uid) {
+        this.type = MessageType.DGCACK;
+        this.uid = uid;
+    }
+
+    /**
+     * Reads a Call message
+     * @param in 
+     *          the {@link java.io.InputStream} to be read
+     * @throws UnmarshalException 
+     *          if not able to read the Call
+     * @throws NoSuchObjectException
+     *          if the object ID is not exported in this server  
+     */
+    private final void readCall(DataInputStream in) throws UnmarshalException,
+            NoSuchObjectException {
+        RMIObjectInputStream objIn;
+        RemoteReferenceManager refMgr;
+        int argsCount = 0;
+
+        try {
+            objIn = new RMIObjectInputStream(in);
+            this.objID = ObjID.read(objIn);
+            this.operation = objIn.readInt();
+            this.hash = objIn.readLong();
+        } catch (IOException e) {
+            throw new UnmarshalException("I/O Error Unmarshaling Call Header",
+                    e);
+        }
+        refMgr = RemoteReferenceManager.getRemoteReferenceManager();
+        argsCount = refMgr.getArgsCount(objID, hash);
+        values = new Object[argsCount];
+        try {
+            for (int i = 0; i < argsCount; i++) {
+                values[i] = objIn.readObject();
+            }
+        } catch (ClassNotFoundException e) {
+            throw new UnmarshalException(
+                    "I/O Error Unmarshaling the Arguments", e);
+        } catch (IOException e) {
+            throw new UnmarshalException(
+                    "I/O Error Unmarshaling the Arguments", e);
+        }
+    }
+
+    /**
+     * Reads a DGCAck message
+     * @param in 
+     *          the {@link java.io.InputStream} to be read
+     * @throws ProtocolException
+     *          if not able to read the DGCAck
+     */
+    private final void readDGCAck(DataInputStream in) throws ProtocolException {
+        try {
+            uid = UID.read(in);
+        } catch (IOException e) {
+            throw new ProtocolException("I/O Error Reading the DGCAck");
+        }
+    }
+
+    /**
+     * Writes a DGCAck 
+     * @param out
+     *          the {@link java.io.OutputStream} to be written
+     * @throws ProtocolException
+     *          if not able to write the DGCAck
+     */
+    private final void writeDgcAck(DataOutputStream out)
+            throws ProtocolException {
+        try {
+            out.writeByte(MessageType.DGCACK.getValue());
+            uid.write(out);
+        } catch (IOException e) {
+            throw new ProtocolException("I/O Error Sending DGCAck", e);
+        }
+    }
+
+    /**
+     * Writes a Ping message
+     * @param out
+     *          the {@link java.io.OutputStream} to be written
+     * @throws ProtocolException
+     *          if not able to write the Ping
+     */
+    private final void writePing(DataOutputStream out) throws ProtocolException {
+        try {
+            out.writeByte(MessageType.PING.getValue());
+        } catch (IOException e) {
+            throw new ProtocolException("Socket Closed while pinging", e);
+        }
+    }
+
+    /**
+     * Writes a Call message
+     * @param out
+     *          the {@link java.io.OutputStream} to be written
+     * @throws MarshalException
+     *          if not able to write the Call
+     */
+    private final void writeCall(DataOutputStream out) throws MarshalException {
+
+        RMIObjectOutputStream objOut = null;
+        try {
+            out.writeByte(MessageType.CALL.getValue());
+            objOut = new RMIObjectOutputStream(out);
+            objID.write(objOut);
+            objOut.writeInt(operation);
+            objOut.writeLong(hash);
+        } catch (Exception e) {
+            throw new MarshalException("I/O Error Marshaling Call Header", e);
+        }
+        try {
+            if (values != null)
+                for (Object o : values) {
+                    objOut.writeObject(o);
+                }
+        } catch (Exception e) {
+            throw new MarshalException("I/O Error Marshaling Arguments", e);
+        } finally {
+            try {
+                objOut.drain();
+            } catch (IOException e) {
+                throw new MarshalException("I/O Error Marshaling Arguments", e);
+            }
+        }
+    }
+        
+    /**
+     * Gets the arguments of a Call
+     * @return 
+     *          the arguments of a Call
+     */
+    public final Object[] getArguments() {
+        return values;
+    }
+
+    /**
+     * Gets the hash of a mathod Call
+     * @return the hash of a mathod Call
+     */
+    public final long getHash() {
+        return hash;
+    }
+
+    /**
+     * Gets the {@link ObjID} of a mathod Call
+     * @return 
+     *          the {@link ObjID} of a mathod Call
+     */
+    public final ObjID getObjID() {
+        return objID;
+    }
+
+    /**
+     * Gets the Operation number of a mathod to be Called
+     * @return 
+     *          the Operation number of a mathod to be Called
+     */
+    public final int getOperation() {
+        return operation;
+    }
+
+    /**
+     * Gets the message type of this message
+     * @return the message type of this message
+     */
+    public final MessageType getType() {
+        return type;
+    }
+
+    /**
+     * Gets the UID of a DGCAck
+     * @return the UID of a DGCAck
+     */
+    public final UID getUID() {
+        return uid;
+    }
+
+    /**
+     * Reads a message from the specified {@link DataInputStream}
+     * @param in
+     *          the {@link DataInputStream} to be read
+     * @throws IOException
+     *          if unable to read the message
+     */
+    public final void readExternal(DataInputStream in) throws IOException {
+
+        type = MessageType.createMessageType(in.readByte());
+        if (type.equals(MessageType.CALL)) {
+            readCall(in);
+        } else if (type.equals(MessageType.DGCACK)) {
+            readDGCAck(in);
+        } else if (type.equals(MessageType.PING)) {
+        } else {
+            throw new ProtocolException("Message not supported");
+        }
+    }
+
+    /**
+     * Writes the Message to the specified {@link DataOutputStream}
+     * @param out 
+     *          the {@link DataOutputStream} to be written 
+     * @throws IOException
+     *          if unable to write the Message
+     */
+    public final void writeExternal(DataOutputStream out) throws IOException {
+
+        if (type == MessageType.CALL) {
+            writeCall(out);
+        } else if (type == MessageType.PING) {
+            writePing(out);
+        } else if (type == MessageType.DGCACK) {
+            writeDgcAck(out);
+        } else {
+            throw new ProtocolException("Message not supported");
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageResponse.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageResponse.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageResponse.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageResponse.java Thu May 18 23:00:52 2006
@@ -1,86 +1,86 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This Enumerated Type describes the possible return types received from a RMI
- * Server.
- * 
- * @author Gustavo Petri
- * 
- */
-class MessageResponse {
-
-	/**
-	 * A 0x51 <code>byte</code> representing a return message
-	 */
-	static final MessageResponse RETURN = new MessageResponse((byte) 0x51);
-
-	/**
-	 * A 0x53 <code>byte</code> representing a PingAck message
-	 */
-    static final MessageResponse PING_ACK = new MessageResponse((byte) 0x53);
-
-	/**
-	 * The internal <code>byte</code> value for this enum
-	 */
-	private byte value;
-
-	/**
-	 * Private constructor, sets the internal {@link MessageResponse#value}
-	 * 
-	 * @param value
-	 */
-	private MessageResponse(byte value) {
-		this.value = value;
-	}
-
-	/**
-	 * Getter method which returns the <code>byte</code> value of this enum
-	 * 
-	 * @return the {@link MessageResponse#value} of this enumeration
-	 */
-	byte getValue() {
-		return value;
-	}
-
-	/**
-	 * Creates a new {@link MessageResponse}
-	 * 
-	 * @param value
-	 *            the <code>byte</code> value of the {@link MessageResponse}
-	 * @return a new {@link MessageResponse}
-	 * @throws IllegalArgumentException
-	 *             if the <code>value</code> parameter is not a valid JRMP
-	 *             return type.
-	 */
-	static MessageResponse createMessageResponse(byte value) {
-		if (value == RETURN.getValue()) {
-			return RETURN;
-		} else if (value == PING_ACK.getValue()) {
-			return PING_ACK;
-		} else {
-			throw new IllegalArgumentException("Unrecognized value: "
-					+ Integer.toHexString(value));
-		}
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This Enumerated Type describes the possible return types received from a RMI
+ * Server.
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+class MessageResponse {
+
+	/**
+	 * A 0x51 <code>byte</code> representing a return message
+	 */
+	static final MessageResponse RETURN = new MessageResponse((byte) 0x51);
+
+	/**
+	 * A 0x53 <code>byte</code> representing a PingAck message
+	 */
+    static final MessageResponse PING_ACK = new MessageResponse((byte) 0x53);
+
+	/**
+	 * The internal <code>byte</code> value for this enum
+	 */
+	private byte value;
+
+	/**
+	 * Private constructor, sets the internal {@link MessageResponse#value}
+	 * 
+	 * @param value
+	 */
+	private MessageResponse(byte value) {
+		this.value = value;
+	}
+
+	/**
+	 * Getter method which returns the <code>byte</code> value of this enum
+	 * 
+	 * @return the {@link MessageResponse#value} of this enumeration
+	 */
+	byte getValue() {
+		return value;
+	}
+
+	/**
+	 * Creates a new {@link MessageResponse}
+	 * 
+	 * @param value
+	 *            the <code>byte</code> value of the {@link MessageResponse}
+	 * @return a new {@link MessageResponse}
+	 * @throws IllegalArgumentException
+	 *             if the <code>value</code> parameter is not a valid JRMP
+	 *             return type.
+	 */
+	static MessageResponse createMessageResponse(byte value) {
+		if (value == RETURN.getValue()) {
+			return RETURN;
+		} else if (value == PING_ACK.getValue()) {
+			return PING_ACK;
+		} else {
+			throw new IllegalArgumentException("Unrecognized value: "
+					+ Integer.toHexString(value));
+		}
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageType.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/MessageType.java Thu May 18 23:00:52 2006
@@ -1,96 +1,96 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import ar.org.fitc.rmi.transport.ProtocolException;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This Enumerated Type describes the possible Messages received by a RMI
- * Server.
- * 
- * @author Gustavo Petri
- * 
- */
-public class MessageType {
-
-	/**
-	 * A 0x50 <code>byte</code> representing a CALL message
-	 */
-	public final static MessageType CALL = new MessageType((byte) 0x50);
-
-	/**
-	 * A 0x52 <code>byte</code> representing a PING message
-	 */
-    public final static MessageType PING = new MessageType((byte) 0x52);
-
-	/**
-	 * A 0x54 <code>byte</code> representing a DGCACK message
-	 */
-    public final static MessageType DGCACK = new MessageType((byte) 0x54);
-
-	/**
-	 * The internal <code>byte</code> value for this enum
-	 */
-	private byte value;
-
-	/**
-	 * Private constructor, sets the internal {@link MessageType#value}
-	 * 
-	 * @param value
-	 */
-	private MessageType(byte value) {
-		this.value = value;
-	}
-
-	/**
-	 * Getter method which returns the <code>byte</code> value of this enum
-	 * 
-	 * @return the {@link MessageType#value} of this enum
-	 */
-	final byte getValue() {
-		return value;
-	}
-
-	/**
-	 * Creates a new {@link MessageType}
-	 * 
-	 * @param value
-	 *            the <code>byte</code> value of the {@link MessageType}
-	 * @return a new {@link MessageType}
-	 * @throws ProtocolException
-	 *             if the <code>value</code> parameter is not a valid JRMP
-	 *             header message type
-	 */
-	static final MessageType createMessageType(byte value)
-			throws ProtocolException {
-		if (value == CALL.getValue()) {
-			return CALL;
-		} else if (value == PING.getValue()) {
-			return PING;
-		} else if (value == DGCACK.getValue()) {
-			return DGCACK;
-		} else {
-			throw new ProtocolException("Unrecognized Message Header "
-					+ Integer.toHexString(value));
-		}
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import org.apache.harmony.rmi.internal.transport.ProtocolException;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This Enumerated Type describes the possible Messages received by a RMI
+ * Server.
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+public class MessageType {
+
+	/**
+	 * A 0x50 <code>byte</code> representing a CALL message
+	 */
+	public final static MessageType CALL = new MessageType((byte) 0x50);
+
+	/**
+	 * A 0x52 <code>byte</code> representing a PING message
+	 */
+    public final static MessageType PING = new MessageType((byte) 0x52);
+
+	/**
+	 * A 0x54 <code>byte</code> representing a DGCACK message
+	 */
+    public final static MessageType DGCACK = new MessageType((byte) 0x54);
+
+	/**
+	 * The internal <code>byte</code> value for this enum
+	 */
+	private byte value;
+
+	/**
+	 * Private constructor, sets the internal {@link MessageType#value}
+	 * 
+	 * @param value
+	 */
+	private MessageType(byte value) {
+		this.value = value;
+	}
+
+	/**
+	 * Getter method which returns the <code>byte</code> value of this enum
+	 * 
+	 * @return the {@link MessageType#value} of this enum
+	 */
+	final byte getValue() {
+		return value;
+	}
+
+	/**
+	 * Creates a new {@link MessageType}
+	 * 
+	 * @param value
+	 *            the <code>byte</code> value of the {@link MessageType}
+	 * @return a new {@link MessageType}
+	 * @throws ProtocolException
+	 *             if the <code>value</code> parameter is not a valid JRMP
+	 *             header message type
+	 */
+	static final MessageType createMessageType(byte value)
+			throws ProtocolException {
+		if (value == CALL.getValue()) {
+			return CALL;
+		} else if (value == PING.getValue()) {
+			return PING;
+		} else if (value == DGCACK.getValue()) {
+			return DGCACK;
+		} else {
+			throw new ProtocolException("Unrecognized Message Header "
+					+ Integer.toHexString(value));
+		}
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolHeader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolHeader.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolHeader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolHeader.java Thu May 18 23:00:52 2006
@@ -1,97 +1,97 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import java.util.Arrays;
-
-import ar.org.fitc.rmi.transport.ProtocolException;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This Enumerated Type describes the possible protocol headers defined by the 
- * JRMP specification.
- * 
- * @author Gustavo Petri
- * 
- */
-public class ProtocolHeader {
-
-	/**
-	 * The <code>byte[]</code> sequence corresponding to the JRMP protocol initial header
-	 */
-	public final static ProtocolHeader JRMI_PROTOCOL_HEADER = 
-        new ProtocolHeader(new byte[] {0x4a, 0x52, 0x4d, 0x49}); 
-
-	/**
-	 * The <code>byte[]</code> sequence corresponding to the HTTP protocol initial header
-	 */
-    public final static ProtocolHeader HTTP_PROTOCOL_HEADER = 
-        new ProtocolHeader(new byte[] {0x50, 0x4f, 0x53, 0x54});
-    
-	/**
-	 * The internal <code>byte[]</code> value for this enumeration
-	 */
-    private byte[] value;
-
-	/**
-	 * Private constructor, sets the internal {@link ProtocolHeader#value}
-	 * 
-	 * @param value
-	 */
-    private ProtocolHeader(byte[] value) {
-        this.value = value.clone();
-    }
-
-	/**
-	 * Getter method which returns the <code>byte[]</code> value of this enumeration
-	 * 
-	 * @return the {@link ProtocolHeader#value} of this enumeration
-	 */
-    final byte[] getValue() {
-        return value;
-    }
-
-	/**
-	 * Creates a new {@link ProtocolHeader}
-	 * 
-	 * @param value
-	 *            the <code>byte[]</code> value of the {@link ProtocolHeader}
-	 * @return a new {@link ProtocolHeader}
-	 * @throws ProtocolException
-	 *             if the <code>value</code> parameter is not a valid JRMP
-	 *             initial protocol header sequence.
-	 */
-    public static final ProtocolHeader createProtocolHeader(byte[] value)
-            throws ProtocolException {
-        if (Arrays.equals(value, JRMI_PROTOCOL_HEADER.getValue())) {
-            return JRMI_PROTOCOL_HEADER;
-        } else if (Arrays.equals(value, HTTP_PROTOCOL_HEADER.getValue())) {
-            return HTTP_PROTOCOL_HEADER;
-        } else {
-            StringBuilder str = new StringBuilder();
-            for (byte b : value) {
-                str.append(Integer.toHexString(b) + ", ");
-            }
-            throw new ProtocolException("Protocol Header not recognized: "
-                    + str.toString());
-        }
-    }
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import java.util.Arrays;
+
+import org.apache.harmony.rmi.internal.transport.ProtocolException;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This Enumerated Type describes the possible protocol headers defined by the 
+ * JRMP specification.
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+public class ProtocolHeader {
+
+	/**
+	 * The <code>byte[]</code> sequence corresponding to the JRMP protocol initial header
+	 */
+	public final static ProtocolHeader JRMI_PROTOCOL_HEADER = 
+        new ProtocolHeader(new byte[] {0x4a, 0x52, 0x4d, 0x49}); 
+
+	/**
+	 * The <code>byte[]</code> sequence corresponding to the HTTP protocol initial header
+	 */
+    public final static ProtocolHeader HTTP_PROTOCOL_HEADER = 
+        new ProtocolHeader(new byte[] {0x50, 0x4f, 0x53, 0x54});
+    
+	/**
+	 * The internal <code>byte[]</code> value for this enumeration
+	 */
+    private byte[] value;
+
+	/**
+	 * Private constructor, sets the internal {@link ProtocolHeader#value}
+	 * 
+	 * @param value
+	 */
+    private ProtocolHeader(byte[] value) {
+        this.value = value.clone();
+    }
+
+	/**
+	 * Getter method which returns the <code>byte[]</code> value of this enumeration
+	 * 
+	 * @return the {@link ProtocolHeader#value} of this enumeration
+	 */
+    final byte[] getValue() {
+        return value;
+    }
+
+	/**
+	 * Creates a new {@link ProtocolHeader}
+	 * 
+	 * @param value
+	 *            the <code>byte[]</code> value of the {@link ProtocolHeader}
+	 * @return a new {@link ProtocolHeader}
+	 * @throws ProtocolException
+	 *             if the <code>value</code> parameter is not a valid JRMP
+	 *             initial protocol header sequence.
+	 */
+    public static final ProtocolHeader createProtocolHeader(byte[] value)
+            throws ProtocolException {
+        if (Arrays.equals(value, JRMI_PROTOCOL_HEADER.getValue())) {
+            return JRMI_PROTOCOL_HEADER;
+        } else if (Arrays.equals(value, HTTP_PROTOCOL_HEADER.getValue())) {
+            return HTTP_PROTOCOL_HEADER;
+        } else {
+            StringBuilder str = new StringBuilder();
+            for (byte b : value) {
+                str.append(Integer.toHexString(b) + ", ");
+            }
+            throw new ProtocolException("Protocol Header not recognized: "
+                    + str.toString());
+        }
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolType.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ProtocolType.java Thu May 18 23:00:52 2006
@@ -1,92 +1,92 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This Enumerated Type describes the possible Protocol types defined by the
- * JRMP specification.
- * 
- * @author Gustavo Petri
- * 
- */
-public class ProtocolType {
-
-	/**
-	 * A 0x4c <code>byte</code> representing the SingleOp protocol
-	 */
-	public static final ProtocolType SINGLE_OP = new ProtocolType((byte) 0x4c);
-
-	/**
-	 * A 0x4b <code>byte</code> representing the Stream protocol
-	 */
-    public static final ProtocolType STREAM = new ProtocolType((byte) 0x4b);
-
-	/**
-	 * A 0x4d <code>byte</code> representing the Multiplex protocol
-	 */
-    public static final ProtocolType MULTIPLEX = new ProtocolType((byte) 0x4d);
-
-	/**
-	 * The internal <code>byte</code> value for this enum
-	 */
-	private byte value;
-
-	/**
-	 * Private constructor, sets the internal {@link ProtocolType#value}
-	 * 
-	 * @param value
-	 */
-	private ProtocolType(byte value) {
-		this.value = value;
-	}
-
-	/**
-	 * Getter method which returns the <code>byte</code> value of this enum
-	 * 
-	 * @return the {@link ProtocolType#value} of this enum
-	 */
-	final byte getValue() {
-		return value;
-	}
-
-	/**
-	 * Creates a new {@link ProtocolType}
-	 * 
-	 * @param value
-	 *            the <code>byte</code> value of the {@link ProtocolType}
-	 * @return a new {@link ProtocolType}
-	 * @throws IllegalArgumentException
-	 *             if the <code>value</code> parameter is not a valid JRMP
-	 *             protocol type
-	 */
-	public static final ProtocolType createProtocolType(byte value) {
-		if (value == SINGLE_OP.getValue()) {
-			return SINGLE_OP;
-		} else if (value == STREAM.getValue()) {
-			return STREAM;
-		} else if (value == MULTIPLEX.getValue()) {
-			return MULTIPLEX;
-		} else {
-			throw new IllegalArgumentException("Unrecognized value");
-		}
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This Enumerated Type describes the possible Protocol types defined by the
+ * JRMP specification.
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+public class ProtocolType {
+
+	/**
+	 * A 0x4c <code>byte</code> representing the SingleOp protocol
+	 */
+	public static final ProtocolType SINGLE_OP = new ProtocolType((byte) 0x4c);
+
+	/**
+	 * A 0x4b <code>byte</code> representing the Stream protocol
+	 */
+    public static final ProtocolType STREAM = new ProtocolType((byte) 0x4b);
+
+	/**
+	 * A 0x4d <code>byte</code> representing the Multiplex protocol
+	 */
+    public static final ProtocolType MULTIPLEX = new ProtocolType((byte) 0x4d);
+
+	/**
+	 * The internal <code>byte</code> value for this enum
+	 */
+	private byte value;
+
+	/**
+	 * Private constructor, sets the internal {@link ProtocolType#value}
+	 * 
+	 * @param value
+	 */
+	private ProtocolType(byte value) {
+		this.value = value;
+	}
+
+	/**
+	 * Getter method which returns the <code>byte</code> value of this enum
+	 * 
+	 * @return the {@link ProtocolType#value} of this enum
+	 */
+	final byte getValue() {
+		return value;
+	}
+
+	/**
+	 * Creates a new {@link ProtocolType}
+	 * 
+	 * @param value
+	 *            the <code>byte</code> value of the {@link ProtocolType}
+	 * @return a new {@link ProtocolType}
+	 * @throws IllegalArgumentException
+	 *             if the <code>value</code> parameter is not a valid JRMP
+	 *             protocol type
+	 */
+	public static final ProtocolType createProtocolType(byte value) {
+		if (value == SINGLE_OP.getValue()) {
+			return SINGLE_OP;
+		} else if (value == STREAM.getValue()) {
+			return STREAM;
+		} else if (value == MULTIPLEX.getValue()) {
+			return MULTIPLEX;
+		} else {
+			throw new IllegalArgumentException("Unrecognized value");
+		}
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnMessage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnMessage.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnMessage.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnMessage.java Thu May 18 23:00:52 2006
@@ -1,260 +1,260 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.rmi.server.UID;
-
-import ar.org.fitc.rmi.transport.RMIObjectInputStream;
-import ar.org.fitc.rmi.transport.RMIObjectOutputStream;
-import ar.org.fitc.rmi.utils.Pair;
-
-/**
- * A tagged union type which represents a message returned from the RMI Server
- * 
- * @author Gustavo Petri
- * 
- */
-public class ReturnMessage {
-
-	/**
-	 * ID used for serialization purposes
-	 */
-	private static final long serialVersionUID = 1L;
-
-	/**
-	 * A {@link MessageResponse} which defines the type of return message.
-	 */
-	private MessageResponse type;
-
-	/**
-	 * A flag that identifies if this {@link ReturnMessage} represents an
-	 * exception.
-	 */
-	private boolean isException;
-
-	/**
-	 * This attribute is used to store the exception returned from the server,
-	 * when {@link ReturnMessage#type} is <code>true</code>
-	 */
-	private Exception exception = null;
-
-	/**
-	 * This attribute is used to store the object returned from the server, when
-	 * {@link ReturnMessage#type} is <code>false</code>
-	 */
-	private Object result = null;
-
-	/**
-	 * This flag is used to determine if this {@link ReturnMessage} should
-	 * read/write a return value from/to the stream
-	 */
-	private boolean returnsValue;
-
-	/**
-	 * This flag is set to <code>true</code> when the read result is a remote
-	 * object, and a DGCAck message should be sent to the server
-	 */
-	private boolean sendDGCAck;
-
-	/**
-	 * The identificator which is sent and received with the return message
-	 */
-	private UID uid;
-
-	/**
-	 * Creates a new {@link ReturnMessage}. By default, a
-	 * {@link MessageResponse#PING_ACK} message response is created.
-	 */
-	public ReturnMessage() {
-		this.type = MessageResponse.PING_ACK;
-	}
-
-	/**
-	 * Creates a new {@link ReturnMessage} of the {@link MessageResponse#RETURN}
-	 * type, which will represent an exception returned from the server.
-	 * 
-	 * @param e
-	 *            the exception that will be encapsulated by this
-	 *            {@link ReturnMessage}
-	 */
-	public ReturnMessage(Exception e) {
-		this.type = MessageResponse.RETURN;
-		this.isException = true;
-		this.exception = e;
-	}
-
-	/**
-	 * Creates a new {@link ReturnMessage} of the {@link MessageResponse#RETURN}
-	 * type, which will represent an object returned from the server.
-	 * 
-	 * @param o
-	 *            the object that will be encapsulated by this
-	 *            {@link ReturnMessage}
-	 * @param returnsValue
-	 *            A flag that indicates if this {@link ReturnMessage} should
-	 *            read/write a return value from/to the stream
-	 */
-	public ReturnMessage(Object o, boolean returnsValue) {
-		this.type = MessageResponse.RETURN;
-		this.isException = false;
-		this.returnsValue = returnsValue;
-		this.result = o;
-	}
-
-	/**
-	 * Returns the {@link ReturnMessage#type} of this {@link ReturnMessage}
-	 * 
-	 * @return the {@link ReturnMessage#type} of this {@link ReturnMessage}
-	 */
-	public final MessageResponse getReturnType() {
-		return type;
-	}
-
-	/**
-	 * Returns the {@link ReturnMessage#isException} of this
-	 * {@link ReturnMessage}
-	 * 
-	 * @return the {@link ReturnMessage#isException} of this
-	 *         {@link ReturnMessage}
-	 */
-	public final boolean isException() {
-		return isException;
-	}
-
-	/**
-	 * Returns the {@link ReturnMessage#exception} of this {@link ReturnMessage}
-	 * 
-	 * @return the {@link ReturnMessage#exception} of this {@link ReturnMessage}
-	 */
-	public final Exception getException() {
-		return exception;
-	}
-
-	/**
-	 * Returns the {@link ReturnMessage#result} of this {@link ReturnMessage}
-	 * 
-	 * @return the {@link ReturnMessage#result} of this {@link ReturnMessage}
-	 */
-	public final Object getResult() {
-		return result;
-	}
-
-	/**
-	 * Returns the {@link ReturnMessage#sendDGCAck} of this
-	 * {@link ReturnMessage}
-	 * 
-	 * @return the {@link ReturnMessage#sendDGCAck} of this
-	 *         {@link ReturnMessage}
-	 */
-	public final boolean sendsDGCAck() {
-		return sendDGCAck;
-	}
-
-	/**
-	 * Returns the {@link ReturnMessage#uid} of this {@link ReturnMessage}
-	 * 
-	 * @return the {@link ReturnMessage#uid} of this {@link ReturnMessage}
-	 */
-	public final UID getUID() {
-		return uid;
-	}
-
-	/**
-	 * Sets the {@link ReturnMessage#returnsValue} of this {@link ReturnMessage}
-	 * 
-	 * @param returnsValue
-	 *            The flag that indicates if this {@link ReturnMessage} should
-	 *            read/write a return value from/to the stream
-	 * 
-	 */
-	public final void setReturnsValue(boolean returnsValue) {
-		this.returnsValue = returnsValue;
-	}
-
-	/**
-	 * Writes this {@link ReturnMessage} to a {@link DataOutputStream}
-	 * 
-	 * @param out
-	 *            the ouput stream in which the {@link ReturnMessage} will be
-	 *            written to
-	 * @return the {@link UID} that identificates the written
-	 *         {@link ReturnMessage}
-	 * @throws IOException
-	 *             if an exception occurs writing the {@link ReturnMessage} to
-	 *             the stream
-	 */
-	public final UID write(DataOutputStream out) throws IOException {
-		RMIObjectOutputStream objOut;
-		boolean writesRemote = false;
-
-		objOut = new RMIObjectOutputStream(out);
-		objOut.writeByte(type.getValue());
-		if (type == MessageResponse.RETURN) {
-			if (!isException) {
-				objOut.writeByte(ReturnType.RETURN_HEADER.getValue());
-				uid = new UID();
-				uid.write(objOut);
-				if (returnsValue) {
-					writesRemote = objOut.writeResultObject(result);
-				}
-			} else {
-				objOut.writeByte(ReturnType.EXCEPTION_HEADER.getValue());
-				uid = new UID();
-				uid.write(objOut);
-				writesRemote = objOut.writeResultObject(exception);
-			}
-		}
-		objOut.drain(); // don't propagate through the socket's output stream
-		return writesRemote ? uid : null;
-	}
-
-	/**
-	 * Reads a {@link ReturnMessage} from a {@link DataInputStream} and sets its
-	 * internal attributes.
-	 * 
-	 * @param in
-	 *            the input stream where the {@link ReturnMessage} will be read
-	 *            from
-	 * @throws IOException
-	 *             if an exception occurs when reading the {@link ReturnMessage}
-	 * @throws ClassNotFoundException
-	 *             if a required class is not found
-	 */
-	public final void read(DataInputStream in) throws IOException,
-			ClassNotFoundException {
-		RMIObjectInputStream objIn = null;
-
-		objIn = new RMIObjectInputStream(in);
-		type = MessageResponse.createMessageResponse(objIn.readByte());
-		if (type == MessageResponse.RETURN) {
-			ReturnType retType = ReturnType.createReturnType(objIn.readByte());
-			uid = UID.read(objIn);
-			if (retType.equals(ReturnType.RETURN_HEADER) && returnsValue) {
-				Pair<Object, Boolean> pair = objIn.readResultObject();
-				result = pair.getFirst();
-				sendDGCAck = pair.getSecond();
-			} else if (retType.equals(ReturnType.EXCEPTION_HEADER)) {
-				Pair<Object, Boolean> pair = objIn.readResultObject();
-				isException = true;
-				exception = (Exception) pair.getFirst();
-				sendDGCAck = pair.getSecond();
-			}
-		}
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.rmi.server.UID;
+
+import org.apache.harmony.rmi.internal.transport.RMIObjectInputStream;
+import org.apache.harmony.rmi.internal.transport.RMIObjectOutputStream;
+import org.apache.harmony.rmi.internal.utils.Pair;
+
+/**
+ * A tagged union type which represents a message returned from the RMI Server
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+public class ReturnMessage {
+
+	/**
+	 * ID used for serialization purposes
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * A {@link MessageResponse} which defines the type of return message.
+	 */
+	private MessageResponse type;
+
+	/**
+	 * A flag that identifies if this {@link ReturnMessage} represents an
+	 * exception.
+	 */
+	private boolean isException;
+
+	/**
+	 * This attribute is used to store the exception returned from the server,
+	 * when {@link ReturnMessage#type} is <code>true</code>
+	 */
+	private Exception exception = null;
+
+	/**
+	 * This attribute is used to store the object returned from the server, when
+	 * {@link ReturnMessage#type} is <code>false</code>
+	 */
+	private Object result = null;
+
+	/**
+	 * This flag is used to determine if this {@link ReturnMessage} should
+	 * read/write a return value from/to the stream
+	 */
+	private boolean returnsValue;
+
+	/**
+	 * This flag is set to <code>true</code> when the read result is a remote
+	 * object, and a DGCAck message should be sent to the server
+	 */
+	private boolean sendDGCAck;
+
+	/**
+	 * The identificator which is sent and received with the return message
+	 */
+	private UID uid;
+
+	/**
+	 * Creates a new {@link ReturnMessage}. By default, a
+	 * {@link MessageResponse#PING_ACK} message response is created.
+	 */
+	public ReturnMessage() {
+		this.type = MessageResponse.PING_ACK;
+	}
+
+	/**
+	 * Creates a new {@link ReturnMessage} of the {@link MessageResponse#RETURN}
+	 * type, which will represent an exception returned from the server.
+	 * 
+	 * @param e
+	 *            the exception that will be encapsulated by this
+	 *            {@link ReturnMessage}
+	 */
+	public ReturnMessage(Exception e) {
+		this.type = MessageResponse.RETURN;
+		this.isException = true;
+		this.exception = e;
+	}
+
+	/**
+	 * Creates a new {@link ReturnMessage} of the {@link MessageResponse#RETURN}
+	 * type, which will represent an object returned from the server.
+	 * 
+	 * @param o
+	 *            the object that will be encapsulated by this
+	 *            {@link ReturnMessage}
+	 * @param returnsValue
+	 *            A flag that indicates if this {@link ReturnMessage} should
+	 *            read/write a return value from/to the stream
+	 */
+	public ReturnMessage(Object o, boolean returnsValue) {
+		this.type = MessageResponse.RETURN;
+		this.isException = false;
+		this.returnsValue = returnsValue;
+		this.result = o;
+	}
+
+	/**
+	 * Returns the {@link ReturnMessage#type} of this {@link ReturnMessage}
+	 * 
+	 * @return the {@link ReturnMessage#type} of this {@link ReturnMessage}
+	 */
+	public final MessageResponse getReturnType() {
+		return type;
+	}
+
+	/**
+	 * Returns the {@link ReturnMessage#isException} of this
+	 * {@link ReturnMessage}
+	 * 
+	 * @return the {@link ReturnMessage#isException} of this
+	 *         {@link ReturnMessage}
+	 */
+	public final boolean isException() {
+		return isException;
+	}
+
+	/**
+	 * Returns the {@link ReturnMessage#exception} of this {@link ReturnMessage}
+	 * 
+	 * @return the {@link ReturnMessage#exception} of this {@link ReturnMessage}
+	 */
+	public final Exception getException() {
+		return exception;
+	}
+
+	/**
+	 * Returns the {@link ReturnMessage#result} of this {@link ReturnMessage}
+	 * 
+	 * @return the {@link ReturnMessage#result} of this {@link ReturnMessage}
+	 */
+	public final Object getResult() {
+		return result;
+	}
+
+	/**
+	 * Returns the {@link ReturnMessage#sendDGCAck} of this
+	 * {@link ReturnMessage}
+	 * 
+	 * @return the {@link ReturnMessage#sendDGCAck} of this
+	 *         {@link ReturnMessage}
+	 */
+	public final boolean sendsDGCAck() {
+		return sendDGCAck;
+	}
+
+	/**
+	 * Returns the {@link ReturnMessage#uid} of this {@link ReturnMessage}
+	 * 
+	 * @return the {@link ReturnMessage#uid} of this {@link ReturnMessage}
+	 */
+	public final UID getUID() {
+		return uid;
+	}
+
+	/**
+	 * Sets the {@link ReturnMessage#returnsValue} of this {@link ReturnMessage}
+	 * 
+	 * @param returnsValue
+	 *            The flag that indicates if this {@link ReturnMessage} should
+	 *            read/write a return value from/to the stream
+	 * 
+	 */
+	public final void setReturnsValue(boolean returnsValue) {
+		this.returnsValue = returnsValue;
+	}
+
+	/**
+	 * Writes this {@link ReturnMessage} to a {@link DataOutputStream}
+	 * 
+	 * @param out
+	 *            the ouput stream in which the {@link ReturnMessage} will be
+	 *            written to
+	 * @return the {@link UID} that identificates the written
+	 *         {@link ReturnMessage}
+	 * @throws IOException
+	 *             if an exception occurs writing the {@link ReturnMessage} to
+	 *             the stream
+	 */
+	public final UID write(DataOutputStream out) throws IOException {
+		RMIObjectOutputStream objOut;
+		boolean writesRemote = false;
+
+		objOut = new RMIObjectOutputStream(out);
+		objOut.writeByte(type.getValue());
+		if (type == MessageResponse.RETURN) {
+			if (!isException) {
+				objOut.writeByte(ReturnType.RETURN_HEADER.getValue());
+				uid = new UID();
+				uid.write(objOut);
+				if (returnsValue) {
+					writesRemote = objOut.writeResultObject(result);
+				}
+			} else {
+				objOut.writeByte(ReturnType.EXCEPTION_HEADER.getValue());
+				uid = new UID();
+				uid.write(objOut);
+				writesRemote = objOut.writeResultObject(exception);
+			}
+		}
+		objOut.drain(); // don't propagate through the socket's output stream
+		return writesRemote ? uid : null;
+	}
+
+	/**
+	 * Reads a {@link ReturnMessage} from a {@link DataInputStream} and sets its
+	 * internal attributes.
+	 * 
+	 * @param in
+	 *            the input stream where the {@link ReturnMessage} will be read
+	 *            from
+	 * @throws IOException
+	 *             if an exception occurs when reading the {@link ReturnMessage}
+	 * @throws ClassNotFoundException
+	 *             if a required class is not found
+	 */
+	public final void read(DataInputStream in) throws IOException,
+			ClassNotFoundException {
+		RMIObjectInputStream objIn = null;
+
+		objIn = new RMIObjectInputStream(in);
+		type = MessageResponse.createMessageResponse(objIn.readByte());
+		if (type == MessageResponse.RETURN) {
+			ReturnType retType = ReturnType.createReturnType(objIn.readByte());
+			uid = UID.read(objIn);
+			if (retType.equals(ReturnType.RETURN_HEADER) && returnsValue) {
+				Pair<Object, Boolean> pair = objIn.readResultObject();
+				result = pair.getFirst();
+				sendDGCAck = pair.getSecond();
+			} else if (retType.equals(ReturnType.EXCEPTION_HEADER)) {
+				Pair<Object, Boolean> pair = objIn.readResultObject();
+				isException = true;
+				exception = (Exception) pair.getFirst();
+				sendDGCAck = pair.getSecond();
+			}
+		}
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnType.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnType.java?rev=407724&r1=407183&r2=407724&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnType.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/internal/transport/jrmp/ReturnType.java Thu May 18 23:00:52 2006
@@ -1,91 +1,91 @@
-/* 
-*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
-* 
-*  Licensed under the Apache License, Version 2.0 (the "License"); 
-*  you may not use this file except in compliance with the License. 
-*  You may obtain a copy of the License at 
-* 
-*    http://www.apache.org/licenses/LICENSE-2.0 
-* 
-*  Unless required by applicable law or agreed to in writing, software 
-*  distributed under the License is distributed on an "AS IS" BASIS, 
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-*  See the License for the specific language governing permissions and 
-*  limitations under the License. 
-*/
-package ar.org.fitc.rmi.transport.jrmp;
-
-import ar.org.fitc.rmi.transport.ProtocolException;
-
-/*
- * NOTE: 
- * This class has been modified in order to support 
- * Java VM 1.4.2 using the javac's target jsr14 
- */
-
-/**
- * This Enumerated Type describes the possible return message types received
- * from a RMI Server.
- * 
- * @author Gustavo Petri
- * 
- */
-class ReturnType {
-
-	/**
-	 * A 0x01 <code>byte</code> representing a return message, when the call
-	 * execution on the remote server was successful
-	 */
-	static final ReturnType RETURN_HEADER = new ReturnType((byte) 0x01);
-
-	/**
-	 * A 0x02 <code>byte</code> representing a return message, when the call
-	 * execution on the remote server threw and exception
-	 */
-    static final ReturnType EXCEPTION_HEADER = new ReturnType((byte) 0x02);
-
-	/**
-	 * The internal <code>byte</code> value for this enum
-	 */
-	private byte value;
-
-	/**
-	 * Private constructor, sets the internal {@link ReturnType#value}
-	 * 
-	 * @param value
-	 */
-	private ReturnType(byte value) {
-		this.value = value;
-	}
-
-	/**
-	 * Getter method which returns the <code>byte</code> value of this enum
-	 * 
-	 * @return the {@link ReturnType#value} of this enumeration
-	 */
-	final byte getValue() {
-		return value;
-	}
-
-	/**
-	 * Creates a new {@link ReturnType}
-	 * 
-	 * @param value
-	 *            the <code>byte</code> value of the {@link ReturnType}
-	 * @return a new {@link ReturnType}
-	 * @throws ProtocolException
-	 *             if the <code>value</code> parameter is not a valid JRMP
-	 *             return message type.
-	 */
-	final static ReturnType createReturnType(byte value)
-			throws ProtocolException {
-		if (value == RETURN_HEADER.getValue()) {
-			return RETURN_HEADER;
-		} else if (value == EXCEPTION_HEADER.getValue()) {
-			return EXCEPTION_HEADER;
-		} else {
-			throw new ProtocolException("Invalid return type byte "
-					+ Integer.toHexString(value));
-		}
-	}
-}
+/* 
+*  Copyright 2005 The Apache Software Foundation or its licensors, as applicable. 
+* 
+*  Licensed under the Apache License, Version 2.0 (the "License"); 
+*  you may not use this file except in compliance with the License. 
+*  You may obtain a copy of the License at 
+* 
+*    http://www.apache.org/licenses/LICENSE-2.0 
+* 
+*  Unless required by applicable law or agreed to in writing, software 
+*  distributed under the License is distributed on an "AS IS" BASIS, 
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+*  See the License for the specific language governing permissions and 
+*  limitations under the License. 
+*/
+package org.apache.harmony.rmi.internal.transport.jrmp;
+
+import org.apache.harmony.rmi.internal.transport.ProtocolException;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This Enumerated Type describes the possible return message types received
+ * from a RMI Server.
+ * 
+ * @author Gustavo Petri
+ * 
+ */
+class ReturnType {
+
+	/**
+	 * A 0x01 <code>byte</code> representing a return message, when the call
+	 * execution on the remote server was successful
+	 */
+	static final ReturnType RETURN_HEADER = new ReturnType((byte) 0x01);
+
+	/**
+	 * A 0x02 <code>byte</code> representing a return message, when the call
+	 * execution on the remote server threw and exception
+	 */
+    static final ReturnType EXCEPTION_HEADER = new ReturnType((byte) 0x02);
+
+	/**
+	 * The internal <code>byte</code> value for this enum
+	 */
+	private byte value;
+
+	/**
+	 * Private constructor, sets the internal {@link ReturnType#value}
+	 * 
+	 * @param value
+	 */
+	private ReturnType(byte value) {
+		this.value = value;
+	}
+
+	/**
+	 * Getter method which returns the <code>byte</code> value of this enum
+	 * 
+	 * @return the {@link ReturnType#value} of this enumeration
+	 */
+	final byte getValue() {
+		return value;
+	}
+
+	/**
+	 * Creates a new {@link ReturnType}
+	 * 
+	 * @param value
+	 *            the <code>byte</code> value of the {@link ReturnType}
+	 * @return a new {@link ReturnType}
+	 * @throws ProtocolException
+	 *             if the <code>value</code> parameter is not a valid JRMP
+	 *             return message type.
+	 */
+	final static ReturnType createReturnType(byte value)
+			throws ProtocolException {
+		if (value == RETURN_HEADER.getValue()) {
+			return RETURN_HEADER;
+		} else if (value == EXCEPTION_HEADER.getValue()) {
+			return EXCEPTION_HEADER;
+		} else {
+			throw new ProtocolException("Invalid return type byte "
+					+ Integer.toHexString(value));
+		}
+	}
+}



Mime
View raw message