harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r406944 [7/30] - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi2: ./ build/ doc/ doc/testing/ doc/testing/rmi http tunneling/ doc/testing/rmi http tunneling/Results - ITC/ doc/testing/rmi http tunneling/Results - SUN/ doc/testing...
Date Tue, 16 May 2006 13:52:07 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/transport/jrmp/ServerProtocolHandler.java Tue May 16 06:51:00 2006
@@ -0,0 +1,159 @@
+/* 
+*  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.UnmarshalException;
+
+import ar.org.fitc.rmi.transport.EndpointID;
+import ar.org.fitc.rmi.transport.ProtocolException;
+
+/**
+ * Implements the Server side management of the messages of the JRMP protocol.
+ * 
+ * @author Gustavo Petri
+ */
+public final class ServerProtocolHandler {
+
+	/**
+	 * The client endpoint of the connection.
+	 */
+	private EndpointID clientEP;
+
+	/**
+	 * The local {@link java.io.InputStream} to interact with the client
+	 */
+	private DataInputStream in;
+
+	/**
+	 * The local {@link java.io.OutputStream} to interact with the client.
+	 */
+	private DataOutputStream out;
+
+	/**
+	 * The {@link ProtocolType} which identifies the type of the connection
+	 */
+	private ProtocolType protocolType;
+
+	/**
+	 * Constructs a new {@link ServerProtocolHandler}
+	 * 
+	 * @param in
+	 *            the {@link ar.org.fitc.rmi.transport.RMIObjectInputStream}
+	 * @param out
+	 *            the {@link ar.org.fitc.rmi.transport.RMIObjectInputStream}
+	 * @param clientEP
+	 *            the client {@link EndpointID}
+	 */
+	public ServerProtocolHandler(DataInputStream in, DataOutputStream out,
+			EndpointID clientEP) {
+
+		this.out = out;
+		this.in = in;
+		this.clientEP = (clientEP == null) ? new EndpointID() : clientEP;
+	}
+
+	/**
+	 * Writes the JRMP handshake answer to the client.
+	 * 
+	 * @throws ProtocolException
+	 *             if an exception occurs writing the hanshake data to the
+	 *             client.
+	 */
+	public final void answerHandshake() throws ProtocolException {
+
+		try {
+			if (protocolType == ProtocolType.STREAM) {
+				out.writeByte(HeaderResponse.PROTOCOL_ACK.getValue());
+				clientEP.write(out);
+			} else if (protocolType == ProtocolType.SINGLE_OP) {
+				out.writeByte(HeaderResponse.PROTOCOL_ACK.getValue());
+			} else {
+				out.writeByte(HeaderResponse.PROTOCOL_NOT_SUPPORTED.getValue());
+			}
+		} catch (IOException e) {
+			throw new ProtocolException("Error sending Protocol answer");
+		}
+	}
+
+	/**
+	 * Reads the default client's Endpoint used to accept calls.
+	 * 
+	 * @return an {@link ar.org.fitc.rmi.transport.EndpointID}
+	 */
+	public final EndpointID readEndpointNegotiation() {
+		EndpointID defaultEP = null;
+		try {
+			defaultEP = EndpointID.read(in);
+		} catch (IOException e) {
+			new ProtocolException("Exception reading EndpointID", e);
+		}
+		return defaultEP;
+	}
+
+	/**
+	 * Reads the initial handshake sequence sent by the client.
+	 * 
+	 * @param type
+	 *            a {@link ProtocolType} object indicating the protocol type
+	 * @throws ProtocolException
+	 *             if an exception occurs while reading the handshake data from
+	 *             the imput stream
+	 */
+	public final void readHandShake(ProtocolType type) throws ProtocolException {
+		Header header = new Header(type);
+		try {
+			header.readExternal(in);
+			protocolType = header.getProtocolType();
+		} catch (IOException e) {
+			throw new ProtocolException("I/O Error Reading Transport Header", e);
+		}
+	}
+
+	/**
+	 * Reads a {@link Message} object from the connection's input stream.
+	 * 
+	 * @return the {@link Message} object read.
+	 * @throws UnmarshalException
+	 *             if an exception occurs reading the input stream.
+	 */
+	public final Message readMessage() throws UnmarshalException {
+		Message msg = new Message();
+		try {
+			msg.readExternal(in);
+		} catch (IOException e) {
+			throw new UnmarshalException("IO error unmarshaling a message", e);
+		}
+		return msg;
+	}
+
+	/**
+	 * Writes a {@link MessageResponse#PING_ACK} into the ouput stream.
+	 * 
+	 * @throws ProtocolException
+	 *             if there is an error in the underlying protocol
+	 */
+	public final void writePingAck() throws ProtocolException {
+		try {
+			out.writeByte(MessageResponse.PING_ACK.getValue());
+		} catch (IOException e) {
+			throw new ProtocolException("I/O Error Marshaling a ProtocolAck", e);
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/MethodHashGenerator.java Tue May 16 06:51:00 2006
@@ -0,0 +1,190 @@
+/* 
+*  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.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutput;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+/**
+ * This class provides the methods that compute the hash for a specific method
+ * 
+ * @author Horacio de Oro
+ */
+public final class MethodHashGenerator {
+    private static MessageDigest md;
+    
+    static {
+        try {
+            md = MessageDigest.getInstance("SHA1");
+        } catch (NoSuchAlgorithmException nsae) {
+            throw new InternalError("SHA1 not implemented: " + nsae);
+        }
+    }
+    
+    /**
+     * This method computes the hash of a specific method
+     * 
+     * @param method
+     *            to compute his hash
+     * @return the hash of the method
+     */
+    public final static long getMethodHash(final Method method) {
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        DataOutput dataOutput = new DataOutputStream(baos);
+
+        try {
+            dataOutput.writeUTF(getMethodDescriptor(method));
+        } catch (IOException ioe) {
+            throw new InternalError("IOException while using DataOutput: "
+                    + ioe);
+        }
+
+        byte[] bytes = baos.toByteArray();
+
+        byte[] digest = md.digest(bytes);
+
+        //
+        // 64-bit (long) integer computed from the
+        // first two 32-bit values of the message digest
+        //
+        // The 64-bit hash value is the little-endian composition of an eight
+        // byte sequence
+        // where the first four bytes are the first 32-bit value of the message
+        // digest in
+        // big-endian byte order and the last four bytes are the second 32-bit
+        // value of the
+        // message digest in big-endian byte order. For example, if the first
+        // two 32-bit
+        // values of the message digest are 0xB0B1B2B3 and 0xB4B5B6B7, then the
+        // hash value
+        // would be 0xB7B6B5B4B3B2B1B0.
+        //
+
+        byte[] hash = new byte[8];
+
+        hash[0] = digest[7];
+        hash[1] = digest[6];
+        hash[2] = digest[5];
+        hash[3] = digest[4];
+        hash[4] = digest[3];
+        hash[5] = digest[2];
+        hash[6] = digest[1];
+        hash[7] = digest[0];
+
+        return new BigInteger(hash).longValue();
+    }
+
+    /** Create the description of a method */
+    /**
+     * This method creates the description of a method
+     * 
+     * @param method
+     *            to create the descriptor
+     * @return a descriptor for the method
+     */
+    private final static String getMethodDescriptor(final Method method) {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append(method.getName());
+        sb.append("(");
+
+        for (Class clazz : method.getParameterTypes())
+            sb.append(MethodHashGenerator.getFieldDescriptor(clazz));
+
+        sb.append(")");
+        sb.append(MethodHashGenerator
+                .getFieldDescriptor(method.getReturnType()));
+
+        return sb.toString();
+    }
+
+    /**
+     * This method returns the descriptor for the type represented by the class
+     * clazz
+     * 
+     * @param clazz
+     *            type to compute the descriptor
+     * @return the descriptor for the type represented by the class clazz
+     */
+    private final static String getFieldDescriptor(Class clazz) {
+
+        if (clazz == null) {
+            // TODO: what kind of
+            // exception should be
+            // thrown here?
+            throw new InternalError("clazz == null!"); 
+        }
+        
+        if (clazz.isArray()) {
+            return clazz.getName().replace('.', '/');
+        }
+
+        if (clazz.isPrimitive()) {
+
+            if (clazz.equals(Boolean.TYPE))
+                return "Z";
+
+            else if (clazz.equals(Character.TYPE))
+                return "C";
+
+            else if (clazz.equals(Byte.TYPE))
+                return "B";
+
+            else if (clazz.equals(Short.TYPE))
+                return "S";
+
+            else if (clazz.equals(Integer.TYPE))
+                return "I";
+
+            else if (clazz.equals(Long.TYPE))
+                return "J";
+
+            else if (clazz.equals(Float.TYPE))
+                return "F";
+
+            else if (clazz.equals(Double.TYPE))
+                return "D";
+
+            else if (clazz.equals(Void.TYPE))
+                return "V";
+
+            else
+                throw new InternalError("Unknown primitive type: " + clazz);
+
+        }
+
+        //
+        // clazz.isPrimitive() == false
+        //
+
+        return "L" + clazz.getName().replace('.', '/') + ";";
+
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/Pair.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/Pair.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/Pair.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/Pair.java Tue May 16 06:51:00 2006
@@ -0,0 +1,85 @@
+/* 
+*  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.utils;
+
+/**
+ * This class implements a generic pair.
+ * 
+ * @author Gustavo Petri
+ */
+public final class Pair<E, T> {
+    private E comp1;
+
+    private T comp2;
+
+    /**
+     * @param comp1
+     *            first component
+     * @param comp2
+     *            second component
+     */
+    public Pair(E comp1, T comp2) {
+        this.comp1 = comp1;
+        this.comp2 = comp2;
+    }
+
+    /**
+     * @return the first component of pair
+     */
+    public final E getFirst() {
+        return comp1;
+    }
+
+    /**
+     * @return the second component of pair
+     */
+    public final T getSecond() {
+        return comp2;
+    }
+
+    /**
+     * @param o
+     *            the object that will be compared for equality.
+     * @return <code>true</code> if <code>obj</code> is instance of the
+     *         class <code>Pair</code>, else return <code>false</code>
+     */
+    public final boolean equals(Object o) {
+
+        if (o == null)
+            return false;
+        if (o == this)
+            return true;
+        if (!(o instanceof Pair))
+            return false;
+        Pair oPair = (Pair) o;
+        return (this.comp1.equals(oPair.comp1) && this.comp2
+                .equals(oPair.comp2));
+    }
+
+    /**
+     * @return the hash code for this object.
+     */
+    public final int hashCode() {
+        return this.comp1.hashCode() ^ this.comp2.hashCode();
+    }
+
+    /**
+     * @return a description of the contained of an object of this class
+     */
+    public final String toString() {
+        return "Pair " + this.comp1.toString() + ", " + this.comp2.toString();
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PrintStreamHandler.java Tue May 16 06:51:00 2006
@@ -0,0 +1,87 @@
+/* 
+*  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.utils;
+
+import java.io.PrintStream;
+import java.util.logging.LogRecord;
+import java.util.logging.StreamHandler;
+
+/**
+ * This handler publishes log records into a <code>PrintStream</code>.
+ * 
+ * @author Gonzalo Ortega
+ */
+public final class PrintStreamHandler extends StreamHandler {
+
+    private PrintStream out;
+
+    /**
+     * Creates a new <code>PrintStreamHandler</code>, with
+     * <code>System.err</code> as destiny for the log records.
+     */
+    public PrintStreamHandler() {
+        out = System.err;
+        super.setOutputStream(out);
+    }
+
+    /**
+     * Creates a new <code>PrintStreamHandler<code>, with <code>out</code> 
+     * as destiny for the log records. 
+     *
+     * @param out The <code>PrintStream</code> where the messages will be logged to
+     */
+    public PrintStreamHandler(PrintStream out) {
+        if (out != null) {
+            super.setOutputStream(out);
+        }
+        this.out = out;
+    }
+
+    /**
+     * @param record
+     *            The log record to be published
+     */
+    @Override
+    public final void publish(LogRecord record) {
+        if ((out != null) && isLoggable(record)) {
+            out.println(getFormatter().format(record));
+            out.flush();
+        }
+    }
+
+    /**
+     * @param out
+     *            The <code>PrintStream</code> where the messages will be
+     *            logged, or <code>null</code> if no logging is desired.
+     */
+    public void setOutputPrintStream(PrintStream out) {
+        this.out = out;
+    }
+
+    /**
+     * 
+     */
+    @Override
+    public final void close() {
+        if (out != null) {
+            super.close();
+            if (out != System.err) {
+                out.close();
+            }
+        }
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PropertiesReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PropertiesReader.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PropertiesReader.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/PropertiesReader.java Tue May 16 06:51:00 2006
@@ -0,0 +1,77 @@
+/* 
+*  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.utils;
+
+/*
+ * NOTE: 
+ * This class has been modified in order to support 
+ * Java VM 1.4.2 using the javac's target jsr14 
+ */
+
+public final class PropertiesReader {
+
+    /** To prevent instantiation */
+    private PropertiesReader() {}
+    
+    public final static int readInt(String name, int defaultValue) {
+        int ret;
+        try {
+            ret = Integer.parseInt(System.getProperty(name));
+            if (ret < 0) {
+                // TODO LOG HERE
+                ret = defaultValue;
+            }
+        } catch (NumberFormatException e) {
+            // TODO LOG HERE
+            ret = defaultValue;
+        }
+        return ret;
+    }
+
+    public final static long readLong(String name, long defaultValue) {
+        long ret;
+        try {
+            ret = new Long(System.getProperty(name));
+            if (ret < 0) {
+                // TODO LOG HERE
+                ret = defaultValue;
+            }
+        } catch (NumberFormatException e) {
+            // TODO LOG HERE
+            ret = defaultValue;
+        }
+        return ret;    
+    }
+    
+    public final static boolean readBoolean(String name, boolean defaultValue) {
+        boolean ret;
+        try {
+            ret = Boolean.valueOf(System.getProperty(name));
+        } catch (Exception e) {   // TODO: exception name
+            // TODO LOG HERE
+            ret = defaultValue;
+        }
+        return ret;
+    }
+    
+    public final static String readString (String name) {
+        String ret = System.getProperty(name);
+        if (ret == null) {
+            // TODO LOG HERE
+        }
+        return ret; 
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/RemoteUtils.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/RemoteUtils.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/RemoteUtils.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/RemoteUtils.java Tue May 16 06:51:00 2006
@@ -0,0 +1,122 @@
+/* 
+*  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.utils;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+/**
+ * A Collection of utility methods used to get the Remote interfaces and
+ * methods from a Class.
+ * 
+ * @author Gonzalo Ortega
+ */
+public final class RemoteUtils {
+	
+	/**
+	 * Map used to cache the remote interfaces of a class, saving time when
+	 * exporting multiple instances of the same class. 
+	 */
+	static Map<Class, Set<Class>> remoteInterfacesCache;
+
+	static {
+		remoteInterfacesCache = Collections.synchronizedMap(new WeakHashMap<Class, Set<Class>>());
+	}
+	
+    /**
+     * Returns a set containing all the remote interfaces implemented by a class
+     * 
+     * @param inspect
+     *            the class that implements the remote interfaces
+     * @return A <code>Set</code> containing all the remote interfaces
+     *         implemented by a class
+     */
+    public final static Set<Class> getRemoteInterfaces(Class inspect) {
+    	if (remoteInterfacesCache.containsKey(inspect)) {
+    		return remoteInterfacesCache.get(inspect);
+    	}
+        LinkedHashSet<Class> classSet = new LinkedHashSet<Class>();
+        Class clazz = inspect;
+        do {
+            getRemoteInterfacesAux(clazz, classSet);
+        } while ((clazz = clazz.getSuperclass()) != null);
+        remoteInterfacesCache.put(inspect, classSet);
+        return classSet;
+    }
+
+    /**
+     * Auxiliary method needed for <code>getRemoteInterfaces</code>
+     * 
+     * @param inspect
+     *            The class or intarface that implements or extends the remote
+     *            interface
+     * @param classSet
+     *            A <code>Set</code> where the found remote intrefaces are
+     *            stored
+     * @return <code>true</code> if the received intarface is
+     *         <code>Remote</code>
+     */
+    private final static boolean getRemoteInterfacesAux(Class inspect,
+            Set<Class> classSet) {
+        boolean isRemote = false;
+
+        Class[] allInterfaces = inspect.getInterfaces();
+        for (int x = 0; x < allInterfaces.length; x++) {
+            isRemote = isRemote
+                    | getRemoteInterfacesAux(allInterfaces[x], classSet);
+        }
+        if (inspect.equals(java.rmi.Remote.class)) {
+            isRemote = true;
+        }
+        if (isRemote && inspect.isInterface()) {
+            classSet.add(inspect);
+        }
+        return isRemote;
+    }
+
+    /**
+     * Returns a set containing all the remote methods declared by all the
+     * remote interfaces implemented by a class.
+     * 
+     * @param inspect
+     *            the class that implements the remote interfaces
+     * @return A <code>Set</code> containing all the remote methods of the
+     *         class
+     */
+    public final static Set<Method> getRemoteMethods(Class inspect) {
+        Set<Class> classSet = getRemoteInterfaces(inspect);
+        LinkedHashSet<Method> methods = new LinkedHashSet<Method>();
+
+        for (Class interfaz : classSet) {
+            Method[] methodArray = interfaz.getDeclaredMethods();
+            for (int y = 0; y < methodArray.length; y++) {
+                Class[] exceptions = methodArray[y].getExceptionTypes();
+                for (Class clazz : exceptions) {
+                    if (clazz.equals(java.rmi.RemoteException.class)
+                            || clazz.equals(java.io.IOException.class)
+                            || clazz.equals(java.lang.Exception.class)) {
+                        methods.add(methodArray[y]);
+                    }
+                }
+            }
+        }
+        return methods;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/rmi/utils/ReversibleHashSet.java Tue May 16 06:51:00 2006
@@ -0,0 +1,121 @@
+/* 
+*  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.utils;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * 
+ * This class constructs a generic structure by which is possible to relate one
+ * element "A1" with a list of elements "L11, L12, ..., L1n". This structure
+ * also maintains a list of these relationships "A1, A2, …, Am" with the
+ * corresponding series "L11, L12, ..., L1n, ...", "L21, L22, ..., L2n", ...,
+ * "Lm1, Lm2, ..., Lmn". Thus, if an element "Ai" is known, this class provides
+ * a method that returns a corresponding list of elements "Li". On the other
+ * hand, if an element "Lij" of the list is known, this class provides a method
+ * that return the element "Ai" which contains "Lij".
+ * 
+ * @author Gustavo Petri
+ */
+
+public final class ReversibleHashSet<E, T> {
+
+    private HashMap<E, Set<T>> oneToMany;
+
+    private HashMap<T, E> oneToOne;
+
+    /**
+     * Constructor of the class
+     */
+    public ReversibleHashSet() {
+        this.oneToMany = new HashMap<E, Set<T>>();
+        this.oneToOne = new HashMap<T, E>();
+    }
+
+    /**
+     * This method inserts a value
+     * 
+     * @param key
+     *            the value of the series's identifier
+     * @param value
+     *            of the an element of the series
+     */
+    public final void insert(E key, T value) {
+
+        if (oneToMany.get(key) != null) {
+            oneToMany.get(key).add(value);
+        } else {
+            HashSet<T> newHashSet = new HashSet<T>();
+            newHashSet.add(value);
+            oneToMany.put(key, newHashSet);
+        }
+        oneToOne.put(value, key);
+
+        return;
+    }
+
+    /**
+     * This method returns a list of the elements of the series
+     * 
+     * @param key
+     *            the value of the series's identifier
+     * @return a list of the elements of the series
+     */
+    public final Set<T> getValues(E key) {
+        return oneToMany.get(key);
+    }
+
+    /**
+     * This method returns the value of the series's identifier
+     * 
+     * @param value
+     *            of the an element of the series
+     * @return the key of the series, the value of the series's identifier
+     */
+    public final E getKeyFromValue(T value) {
+        return oneToOne.get(value);
+    }
+
+    /**
+     * This method validate if exists an element in the series
+     * 
+     * @param key
+     *            the value of the series's identifier
+     * @return <code>true</code> if exists an element in the list, else
+     *         <code>false</code>
+     */
+    public final  boolean hasValues(E key) {
+        return !(oneToMany.get(key) == null);
+    }
+
+    /**
+     * This method remove a value of the series
+     * 
+     * @param value
+     *            of the an element of the series
+     */
+    public final void removeValue(T value) {
+        E key = oneToOne.get(value);
+        if (key != null) {
+            oneToMany.get(key).remove(value);
+            oneToOne.remove(value);
+            if (oneToMany.get(key).isEmpty())
+                oneToMany.remove(key);
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AbstractITCRemote.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AbstractITCRemote.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AbstractITCRemote.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AbstractITCRemote.java Tue May 16 06:51:00 2006
@@ -0,0 +1,102 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.io.Serializable;
+import java.net.SocketException;
+import java.rmi.RemoteException;
+import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UnicastRemoteObject;
+
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Implentation of an <code>ITCRemote</code> object.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class AbstractITCRemote implements ITCRemote, Cloneable, Serializable {
+	
+	/**
+	 * Version number unique identificator.
+	 */	
+	private static final long serialVersionUID = 1324L;
+	
+	/**
+	 * Default constructor.
+	 *
+	 */
+	public AbstractITCRemote() {
+		super();
+	}
+	
+	/**
+	 * Removes the remote object from the RMI runtime.
+	 * 
+	 * @param force if <code>true</code>, unexports the object even 
+	 * if there are pending or in-progress calls
+	 * @return true if operation is successful
+	 * @throws RemoteException if failed to unexport object
+	 */
+	public boolean clean(boolean force) throws RemoteException {
+		return UnicastRemoteObject.unexportObject(this, force);
+	}
+	
+	/**
+	 * Returns a clone of the remote object that is distinct 
+	 * from the original.
+	 * 
+	 * @return the new remote object 
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public ITCRemote myClone() throws RemoteException {
+		try {
+			return (ITCRemote) clone();
+		} catch (CloneNotSupportedException e) {
+			throw new RemoteException(e.getMessage());
+		}
+	}
+	
+	/**
+	 * Inidicates if is working in the Server.
+	 * 
+	 * @return <code>true</code> if is working in the Server 
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public boolean imInServer() throws RemoteException {
+		try {
+			return Net.isOwnHost(UnicastRemoteObject.getClientHost());
+		} catch (ServerNotActiveException e) {
+			// server no work, so i'm in the server. 
+			return true;
+		} catch (SocketException e) {
+			throw new RemoteException("fail looking if imInServel", e);
+		}
+	}
+	
+	/**
+	 * Returns a string that represents the value of this remote object.
+	 * 
+	 * @return a string representation of the object
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public String getString() throws RemoteException {
+		return toString();
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AutoBindITCRemoteUnicast.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AutoBindITCRemoteUnicast.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AutoBindITCRemoteUnicast.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/AutoBindITCRemoteUnicast.java Tue May 16 06:51:00 2006
@@ -0,0 +1,129 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.NoSuchObjectException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor;
+
+/**
+ * Construct a <code>AutoBindITCRemoteUnicast</code> and automatically 
+ * bind it.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class AutoBindITCRemoteUnicast extends ITCRemoteUnicast implements ServerExecutor, Serializable {
+
+	/**
+	 * Version number unique identificator.
+	 */	
+	private static final long serialVersionUID = 2L;
+	
+	/**
+	 * A constant string that represents the name of an object to bind.
+	 */
+	public final static String BIND_NAME ="HIHIHIHI";  
+	
+	/**
+	 * The default constructor.
+	 * 
+	 * @throws RemoteException if registry could not be contacted 
+	 */
+	public AutoBindITCRemoteUnicast() throws RemoteException {
+		super();
+		try {
+			Naming.rebind(BIND_NAME, this);
+		} catch (MalformedURLException e) {
+		}
+	}
+	
+	/**
+	 * Removes the remote object from the RMI runtime.
+	 * 
+	 * @param force if <code>true</code>, unexports the object even 
+	 * if there are pending or in-progress calls
+	 * @return true if operation is successful
+	 * @throws RemoteException if failed to unexport object
+	 */
+	public boolean clean(boolean force) throws RemoteException {
+		return unexportObject(this, force);
+	}
+
+	/**
+	 * Returns a reference, a stub, for the remote object associated 
+	 * with the specified name. 
+	 * 
+	 * @param arguments not used here
+	 * @return a reference for a remote object 
+	 * @throws RemoteException if registry could not be contacted 
+	 */
+	public Object execute(Object... arguments) throws RemoteException {
+		try {
+			return Naming.lookup(BIND_NAME);
+		} catch (MalformedURLException e) {
+		} catch (RemoteException e) {
+		} catch (NotBoundException e) {
+		}
+		return null;
+	}
+	
+	/**
+	 * Writes the non-static and non-transient fields of the current 
+	 * class to the stream.
+	 * 
+	 * @param out the <code>ObjectOutputStream</code>
+	 * @throws IOException if an I/O error occurs while writing 
+	 * the stream  
+	 */
+	private void writeObject(ObjectOutputStream out) throws IOException {
+        out.defaultWriteObject();
+    }
+	
+	/**
+	 * Reads the non-static and non-transient fields of the current 
+	 * class from the stream.
+	 * 
+	 * @param in the <code>ObjectInputStream</code>
+	 * @throws IOException IOException if an I/O error occurs while 
+	 * reading the stream  
+	 * @throws ClassNotFoundException if the class of a serialized 
+	 * object could not be found
+	 */
+	private void readObject(ObjectInputStream in) throws IOException,
+    	ClassNotFoundException {
+		in.defaultReadObject();
+		try {
+			toStub(this);
+		} catch(NoSuchObjectException e) {
+			exportObject(this, 10203);
+		}
+		try {
+			Naming.rebind(BIND_NAME, this);
+		} catch (MalformedURLException e) {
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/GCRemote.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/GCRemote.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/GCRemote.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/GCRemote.java Tue May 16 06:51:00 2006
@@ -0,0 +1,138 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.lang.ref.WeakReference;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ClientExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ReportIPException;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ReportIPServer;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Forces the remote execution of garbage collector.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class GCRemote extends AbstractServerExecutor {
+
+	/**
+	 * Version number unique identificator.
+	 */	
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Default constructor.
+	 *	 
+	 * @throws RemoteException if the remote operation fail
+	 */
+	public GCRemote() throws RemoteException {
+		super();	
+	}
+
+	/**
+	 * Creates a <code>WeakReference</code> and forces garbage 
+	 * collection for this <code>WeakReference</code>.
+	 * 
+	 */
+	@SuppressWarnings("unchecked")
+	public static void forceGC() {
+		WeakReference ref = new WeakReference(new Integer(234523));
+		forceGC(ref);
+	}
+	
+	/**
+	 * Forces garbage collection while the <code>WeakReference</code> 
+	 * received will not to be null.
+	 *  
+	 * @param ref the specified <code>WeakReference</code>
+	 */
+	public static void forceGC(WeakReference ref) {
+		while (ref.get() != null) {
+			System.gc();
+		}
+	}
+	
+	/**
+	 * In each host reported executes a <code>GCRemote</code> 
+	 * object. It forces remotely the garbage collection.
+	 * 
+	 */
+	public static void forceRemoteGC() {
+		try {
+			String[] hosts = ReportIPServer.getit();
+			for (final String host: hosts) {	
+				ClientExecutor.getExecutor(host).execute(new GCRemote(), 1);
+			}
+		} catch (ReportIPException e) {
+			e.printStackTrace();
+		} catch (RemoteException e) {
+			e.printStackTrace();
+		} catch (NotBoundException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * In each host reported executes a <code>GCRemote</code> 
+	 * object. It forces remotely the garbage collection for a 
+	 * specified <code>WeakReference</code>.
+	 * 
+	 * @param ref the specified <code>WeakReference</code>.
+	 */
+	public static void forceRemoteGC(WeakReference ref) {
+		try {
+			String[] hosts = ReportIPServer.getit();
+			for (final String host: hosts) {
+					ClientExecutor.getExecutor(host).execute(new GCRemote(), 0, ref.get());
+			}
+		} catch (ReportIPException e) {
+			e.printStackTrace();
+		} catch (RemoteException e) {
+			e.printStackTrace();
+		} catch (NotBoundException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * Forces garbage collection. If an argument is an instance of 
+	 * <code>ITCRemote<code> creates a <code>WeakReference</code> 
+	 * to it. 
+	 * 
+	 * @param arguments it can be a <code>ITCRemote</code> object
+	 * @return a <code>null</code> value
+	 * @throws RemoteException if the remote operation fails 
+	 */
+	@SuppressWarnings("unchecked")
+	@Override
+	public Object execute(Object... arguments) throws RemoteException {
+		if (arguments.length > 0 && arguments[0] instanceof ITCRemote) {
+			WeakReference ref = new WeakReference(arguments[0]);
+			arguments = null;
+			forceGC(ref);
+		} else {
+			forceGC();
+		}
+		return null;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/ITCRemoteUnicast.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/ITCRemoteUnicast.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/ITCRemoteUnicast.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/ITCRemoteUnicast.java Tue May 16 06:51:00 2006
@@ -0,0 +1,136 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.io.Serializable;
+import java.net.SocketException;
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UnicastRemoteObject;
+
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Used for exporting a remote object and obtaining a stub that 
+ * communicates to the remote object. 
+ *  
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class ITCRemoteUnicast extends UnicastRemoteObject implements ITCRemote,
+		Serializable, Cloneable {
+	/**
+	 * Version number unique identificator.
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Creates and exports a new <code>ITCRemoteUnicast</code> object 
+	 * using an anonymous port.
+	 * 
+	 * @throws RemoteException if failed to export object
+	 */
+	public ITCRemoteUnicast() throws RemoteException {
+		super();
+	}
+
+	/**
+	 * Creates and exports a new <code>ITCRemoteUnicast</code> object 
+	 * using the particular supplied port.
+	 * 
+	 * @param port the port number on which the remote object receives 
+	 * calls 
+	 * @throws RemoteException if failed to export object
+	 */
+	public ITCRemoteUnicast(int port) throws RemoteException {
+		super(port);
+	}
+
+	/**
+	 * Creates and exports a new <code>ITCRemoteUnicast</code> object 
+	 * using the particular supplied port and socket factories.
+	 *  
+	 * @param port the port number on which the remote object receives 
+	 * calls 
+	 * @param csf the client-side socket factory for making calls to 
+	 * the remote object
+	 * @param ssf the server-side socket factory for receiving remote 
+	 * calls 
+	 * @throws RemoteException if failed to export object
+	 */
+	public ITCRemoteUnicast(int port, RMIClientSocketFactory csf,
+			RMIServerSocketFactory ssf) throws RemoteException {
+		super(port, csf, ssf);
+	}
+
+	/**
+	 * Removes the remote object from the RMI runtime.
+	 * 
+	 * @param force if <code>true</code>, unexports the object even 
+	 * if there are pending or in-progress calls
+	 * @return <code>true</code> if operation is successful
+	 * @throws RemoteException if failed to unexport object
+	 */
+	public boolean clean(boolean force) throws RemoteException {
+		return unexportObject(this, force);
+	}
+
+	/**
+	 * Returns a clone of the remote object that is distinct 
+	 * from the original.
+	 * 
+	 * @return the new remote object 
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public ITCRemote myClone() throws RemoteException {
+		try {
+			return (ITCRemote) clone();
+		} catch (CloneNotSupportedException e) {
+			throw new RemoteException(e.getMessage());
+		}
+	}
+
+	/**
+	 * Inidicates if is working in the Server.
+	 * 
+	 * @return <code>true</code> if is working in the Server 
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public boolean imInServer() throws RemoteException {
+		try {
+			return Net.isOwnHost(UnicastRemoteObject.getClientHost());
+		} catch (ServerNotActiveException e) {
+			// server no work, so i'm in the server. 
+			return true;
+		} catch (SocketException e) {
+			throw new RemoteException("fail looking if imInServel", e);
+		}
+	}
+
+	/**
+	 * Returns a string that represents the value of this remote object.
+	 * 
+	 * @return a string representation of the object
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public String getString() throws RemoteException {
+		return toString();
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/LogRemoteImpl.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/LogRemoteImpl.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/LogRemoteImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/LogRemoteImpl.java Tue May 16 06:51:00 2006
@@ -0,0 +1,84 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.rmi.RemoteException;
+import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UnicastRemoteObject;
+
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.LogRemote;
+
+/**
+ * Implementation of <code>LogRemote</code> interface.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class LogRemoteImpl extends AbstractITCRemote implements LogRemote {
+
+	/**
+	 * Version number unique identificator.
+	 */	
+	private static final long serialVersionUID = 1L;
+	
+	/**
+	 * Simple cyclic reference.
+	 */
+	public LogRemote out;
+	
+	/**
+	 * Simple int to number the funtion calls.
+	 */
+	int i = 0;
+
+	/**
+	 * Default constructor. 
+	 *
+	 */
+	public LogRemoteImpl() {
+		super();
+	}
+	
+	/**
+	 * Constructs a <code>LogRemoteImpl</code> with a cyclic reference. 
+	 * 
+	 * @param stub a reference for the remote object 
+	 */
+	public LogRemoteImpl(LogRemote stub) {
+		super();
+		out = stub;
+	}
+
+	/**
+	 * Prints a string representation of the client host. Indicates if 
+	 * is a local o remote execution.
+	 * 
+	 * @param arg a string that indicates if is a local or remote
+	 * execution
+	 * @throws RemoteException if the remote operation fails 
+	 */
+	public void println(String arg) throws RemoteException {
+		i++;
+		try {
+			System.out.println("\t\t" + i + " " + UnicastRemoteObject.getClientHost() + ": " + arg);
+			
+		} catch (ServerNotActiveException e) {
+			System.out.println("\t\t" + i + " Localhost: " + arg);
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/MoveRemoteObject.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/MoveRemoteObject.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/MoveRemoteObject.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/MoveRemoteObject.java Tue May 16 06:51:00 2006
@@ -0,0 +1,74 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.LogRemote;
+
+/**
+ * Moves references of remote objects.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class MoveRemoteObject extends AbstractServerExecutor {
+
+	/**
+	 * Version number unique identificator.
+	 */	
+	private static final long serialVersionUID = 3L;
+
+	/**
+	 * Must initialize a <code>LogRemote</code>.
+	 */
+	public LogRemote obj;
+	
+	/**
+	 * Constructs a <code>MoveRemoteObject</code> with a <code>
+	 * LogRemote</code>.
+	 *  
+	 * @param containt a <code>LogRemote</code> object
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public MoveRemoteObject(LogRemote containt) throws RemoteException {
+		super();
+		obj = containt;
+	}
+
+	/**
+	 * Indicates if is a local o remote execution.
+	 * 
+	 * @param arguments not uses here
+	 * @return a <code>null</code> value
+	 * @throws RemoteException if a remote operation fails
+	 */
+	@Override
+	public Object execute(Object... arguments) throws RemoteException {
+		try {
+			Thread.sleep(100);
+		} catch (InterruptedException e) {}
+		if (obj.imInServer()) {
+			obj.println("local run");
+		} else {
+			obj.println("remote run");
+		}
+		return null;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/Net.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/Net.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/Net.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/Net.java Tue May 16 06:51:00 2006
@@ -0,0 +1,99 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+
+/**
+ * Provides network utilities on the <code>Registry</code>. 
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class Net {
+
+	/**
+	 * The port number on which the <code>Registry</code> is exported.
+	 */
+	private static int port;
+	
+	/**
+	 * Sets the port value. 
+	 */
+	static {
+		String sport = System.getProperty("ar.org.fitc.test.port");
+		if (sport != null) {
+			port = Integer.parseInt(sport);
+		} else {
+			port = 1099;
+		}
+	}
+	
+	/**
+	 * Default constructor.
+	 * 
+	 */
+	public Net() {
+		super();
+	}
+	
+	/**
+	 * Returns the port on which the <code>Registry</code> is exported.
+	 * 
+	 * @return the registry port 
+	 */
+
+	public static int getRegistryPort() {
+		return port;
+	}
+
+	/**
+	 * Returns the IP address of the local host.
+	 * 
+	 * @return an IP address
+	 * @throws UnknownHostException if the IP address of a host 
+	 * could not be determined. 
+	 */
+    public static String ip() throws UnknownHostException {
+        InetAddress address = InetAddress.getLocalHost();
+        byte[] ipAddr = address.getAddress();
+        String ip = new String(ipAddr[0] + "." + ipAddr[1] + "." + ipAddr[2]
+                + "." + ipAddr[3]);
+        return ip;
+    }
+
+    public static boolean isOwnHost(String hostname) throws SocketException {
+    	for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements() ;) {
+    		for (Enumeration<InetAddress> e2 = e.nextElement().getInetAddresses(); e2.hasMoreElements(); ) {
+    			InetAddress inet = e2.nextElement();
+    			if (hostname.equals(inet.getHostAddress())) {
+    				return true;
+    			} else if(hostname.equals(inet.getHostName())) {
+    				return true;
+    			} else if(hostname.equals(inet.getCanonicalHostName())) {
+    				return true;
+    			}
+    		}
+    	}
+    	return false;
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/PropagableTestRemote.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/PropagableTestRemote.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/PropagableTestRemote.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/PropagableTestRemote.java Tue May 16 06:51:00 2006
@@ -0,0 +1,115 @@
+/*
+ *  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.test.rmi.integration.fase2;
+
+import java.io.PrintStream;
+import java.rmi.RemoteException;
+import java.rmi.server.ServerNotActiveException;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor;
+
+/**
+ * For tests and reports purpose.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class PropagableTestRemote extends ITCRemoteUnicast implements ServerExecutor {
+	
+	/**
+	 * Version number unique identificator.
+	 */	
+	private static final long serialVersionUID = 1L;
+	
+	/**
+	 * Adds functionality to the <code>System.out</code>.
+	 */	
+	transient PrintStream out = System.out;
+	
+	/**
+	 * Simple counter.
+	 */
+	int i = 0;
+	
+	/**
+	 * Default constructor.
+	 * 
+	 * @throws RemoteException if the remote operation fail
+	 */
+	public PropagableTestRemote() throws RemoteException {
+		super();
+	}
+
+	/**
+	 * Notices the status of the ClientHost. Used in the ok case.
+	 * 
+	 * @return a <code>true</code> value
+	 */
+	public Object ok() {
+		try {
+			out.println("\t\tHost " + getClientHost() + " work well");
+		} catch (ServerNotActiveException e) {
+		}
+		return true;
+	}
+	
+	/**
+	 * Notices the status of the ClientHost. Used in the failed case.
+	 * 
+	 * @param host the specified host name
+	 * @return a <code>false</code> value
+	 */
+	public Object fail(String host) {
+		try {
+			out.println("\t\tHost " + getClientHost() + " don't work, this host wasn't " + host);
+		} catch (ServerNotActiveException e) {
+		}
+		return false;
+	}
+		
+	/**
+	 * Tests the hosts status.
+	 * 
+	 * @param arguments an arbitrary number of hosts
+	 * @return a boolean value
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public Object execute(Object... arguments) throws RemoteException {
+		String host;
+		String client;
+		
+		if ((Integer)arguments[0] > 1) {
+			i++;
+			host = (String) arguments[i];
+		} else {
+			host = (String) arguments[1];
+		}
+		try {
+			client = getClientHost();
+		} catch (ServerNotActiveException e) {
+			client = System.getProperty("java.rmi.server.hostname");
+		}
+		if (host.equals(client)) {
+			out.println("\t\tHost " + client + " work well");
+			return true;
+		} else {
+			out.println("\t\tHost " + client + " don't work, this host wasn't " + host);
+			return false;
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWait.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWait.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWait.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWait.java Tue May 16 06:51:00 2006
@@ -0,0 +1,29 @@
+package ar.org.fitc.test.rmi.integration.fase2;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor;
+
+public class TimeWait extends AbstractServerExecutor {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 2L;
+	
+	public TimeWait() throws RemoteException {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	@Override
+	public Object execute(Object... arguments) throws RemoteException {
+		long startTime = System.currentTimeMillis();
+		try {
+			Thread.sleep(1000);
+		} catch (InterruptedException e) {
+		}
+		return (System.currentTimeMillis() - startTime);
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWaitBigReturn.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWaitBigReturn.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWaitBigReturn.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/TimeWaitBigReturn.java Tue May 16 06:51:00 2006
@@ -0,0 +1,43 @@
+package ar.org.fitc.test.rmi.integration.fase2;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor;
+
+public class TimeWaitBigReturn extends AbstractServerExecutor {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public TimeWaitBigReturn() throws RemoteException {
+		super();
+	}
+
+	@Override
+	public Object execute(Object... arguments) throws RemoteException {
+		long startTime = System.currentTimeMillis();
+		try {
+			Thread.sleep(1000);
+		} catch (InterruptedException e) {
+		}
+		Object[] result = new Object[1000];
+//		for (int i=0; i< 26; i++) {
+//			result[i] = null;
+//		}
+		result[3] = this;
+		result[4] = new TimeWaitBigReturn();
+		result[7] = 5;
+		result[15] = "Overhead result";
+		result[18] = result[4];
+		result[20] = null;
+		result[23] = 32.5d;
+		result[25] = result;
+		result[0] = new Long(System.currentTimeMillis() - startTime);
+		return result;
+		
+		
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/AbstractServerExecutor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/AbstractServerExecutor.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/AbstractServerExecutor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/AbstractServerExecutor.java Tue May 16 06:51:00 2006
@@ -0,0 +1,50 @@
+/*
+ *  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.test.rmi.integration.fase2.executor;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.AbstractITCRemote;
+
+/**
+ * Abstract class that define the execute method.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public abstract class AbstractServerExecutor extends AbstractITCRemote implements ServerExecutor {
+
+	/**
+	 * Default constructor.
+	 * 
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public AbstractServerExecutor() throws RemoteException {
+		super();
+	}
+
+	/**
+	 * Receives an arbitrary number of arguments and returns a generic 
+	 * object. 
+	 * 
+	 * @param arguments an arbitrary number of arguments 
+	 * @return a generic object
+	 * @throws RemoteException if the remote operation fails
+	 */
+	abstract public Object execute(Object... arguments) throws RemoteException;
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ClientExecutor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ClientExecutor.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ClientExecutor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ClientExecutor.java Tue May 16 06:51:00 2006
@@ -0,0 +1,152 @@
+/*
+ *  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.test.rmi.integration.fase2.executor;
+
+import java.net.MalformedURLException;
+import java.net.UnknownHostException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.RMISecurityManager;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.ExportException;
+import java.security.Permission;
+
+import ar.org.fitc.test.rmi.integration.fase2.Net;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Execution in the client side.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class ClientExecutor extends PropagableExecutorImpl implements
+		PropagableExecutor, RemoteExecutor, ITCRemote {
+
+	/**
+	 * Version number unique identificator.
+	 */
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * The sleep time.
+	 */
+	private final static int SLEEP_MINUTES = 2;
+
+	/**
+	 * The remote interface to a simple remote object.
+	 */
+	private static Registry registry;
+
+	/**
+	 * Default constructor.
+	 * 
+	 * @throws RemoteException
+	 *             if failed to export object
+	 */
+	protected ClientExecutor() throws RemoteException {
+		super();
+	}
+
+	/**
+	 * Obtains a <code>PropagableExecutor</code> for a particular host name.
+	 * 
+	 * @param host
+	 *            a specified host name
+	 * @return a <code>PropagableExecutor</code>
+	 * @throws RemoteException
+	 *             if registry could not be contacted
+	 * @throws NotBoundException
+	 *             if name is not currently bound
+	 */
+	public static PropagableExecutor getExecutor(String host)
+			throws RemoteException, NotBoundException {
+		Registry reg = LocateRegistry.getRegistry(host, Net.getRegistryPort());
+		PropagableExecutor client;
+		client = (PropagableExecutor) reg.lookup(CLIENT_SERVICE_NAME);
+		return client;
+	}
+
+	/**
+	 * Exports a <code>ClientExecutor</code>.
+	 * 
+	 * @throws RemoteException
+	 *             if registry could not be contacted
+	 * @throws MalformedURLException
+	 *             if the name is not an appropriately formatted URL
+	 */
+	public static void exportExecutor() throws RemoteException,
+			MalformedURLException {
+		ClientExecutor client = new ClientExecutor();
+ 		Naming.rebind(CLIENT_SERVICE_NAME, client);
+	}
+
+	/**
+	 * Initializes the <code>Registry</code>. If registry is null, creates
+	 * it.
+	 * 
+	 */
+	public synchronized static void initRegistry() {
+		if (registry == null) {
+			try {
+				try {
+					registry = LocateRegistry.createRegistry(Net
+							.getRegistryPort());
+				} catch (ExportException e) {
+					registry = LocateRegistry
+							.getRegistry(Net.getRegistryPort());
+				}
+			} catch (RemoteException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	public static void main(String[] args) throws RemoteException,
+			MalformedURLException {
+		System.setSecurityManager(new RMISecurityManager() {
+			public void checkPermission(Permission perm) {
+			};
+		});
+		System.setProperty("java.rmi.server.codebase",
+		"ftp://proftp:1@10.100.2.230/");
+
+		try {
+			ReportIPServer.setServerHost(System
+					.getProperty("ar.org.fitc.rmi.server.hostname"));
+		} catch (UnknownHostException e2) {
+			e2.printStackTrace();
+			System.exit(1);
+		}
+		
+		initRegistry();
+		exportExecutor();
+		/*
+		 * This is just to avoid the Registry from being Garbage Collected.
+		 */
+		while (true) {
+			try {
+				ReportIPServer.doit();
+				Thread.sleep(SLEEP_MINUTES * 6000);
+			} catch (InterruptedException e) {
+			}
+		}
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutor.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutor.java Tue May 16 06:51:00 2006
@@ -0,0 +1,81 @@
+/*
+ *  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.test.rmi.integration.fase2.executor;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Provides a mechanisms for propagate an executor. 
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public interface PropagableExecutor extends Remote, RemoteExecutor {
+
+	/**
+	 * A constant string that represents the name of an object to bind.
+	 */
+	public final String CLIENT_SERVICE_NAME = "ClientExcecutor";
+
+	/**
+	 * A generic method that receives a host name, a <code>
+	 * ServerExecutor</code>, number of executions and an arbitrary 
+	 * number of arguments and return a generic object.
+	 * 
+	 * @param host a string that contains the host 
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of arguments 
+	 * @return a generic object
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public Object execute(String host, ServerExecutor obj, int times,
+			Object... arguments) throws RemoteException;
+
+	/**
+	 * A generic method that receives an array of host names, a <code>
+	 * ServerExecutor</code>, number of executions and an arbitrary 
+	 * number of arguments and return boolean value.
+	 * 
+	 * @param host a string array that contains the hosts 
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of arguments 
+	 * @return <code>true</code> if the execution was successful
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public boolean execute(String[] host, ServerExecutor obj, int times,
+			Object... arguments) throws RemoteException;
+
+	/**
+ 	 * A generic method that receives an array of host names, an index 
+ 	 * of execution a <code>ServerExecutor</code>, number of executions 
+ 	 * and an arbitrary number of arguments and return boolean value.
+ 	 * 
+ 	 * @param host a string array that contains the hosts 
+	 * @param index of execution
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of arguments
+	 * @return <code>true</code> if the execution was successful
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public boolean execute(String[] host, int index, ServerExecutor obj,
+			int times, Object... arguments) throws RemoteException;
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutorImpl.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutorImpl.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutorImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/PropagableExecutorImpl.java Tue May 16 06:51:00 2006
@@ -0,0 +1,182 @@
+/*
+ *  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.test.rmi.integration.fase2.executor;
+
+import java.rmi.AccessException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.util.logging.Logger;
+
+import ar.org.fitc.test.rmi.integration.fase2.Net;
+
+/**
+ * Implementation of <code>PropagableExecutor</code>.
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public class PropagableExecutorImpl extends RemoteExecutorImpl implements
+		PropagableExecutor {
+
+	/**
+	 * For log purpose.
+	 */
+	transient private final static Logger log = Logger.getAnonymousLogger();
+
+	/**
+	 * Version number unique identificator.
+	 */
+	private static final long serialVersionUID = 7253124857830298656L;
+
+	/**
+	 * Default constructor.
+	 * 
+	 * @throws RemoteException
+	 *             if the remote operation fails
+	 */
+	public PropagableExecutorImpl() throws RemoteException {
+		super();
+	}
+
+	/**
+	 * Constructs a <code>PropagableExecutorImpl</code> using 
+	 * a particular supplied port.
+	 *  
+	 * @param port the port number on which the remote object receives 
+	 * calls  
+	 * @throws RemoteException if failed to export object
+	 */
+	public PropagableExecutorImpl(int port) throws RemoteException {
+		super(port);
+	}
+
+	/**
+	 * Constructs a <code>PropagableExecutorImpl</code> using 
+	 * a particular supplied port and socket factories.
+	 * 
+	 * @param port the port number on which the remote object receives 
+	 * calls 
+	 * @param csf the client-side socket factory for making calls to 
+	 * the remote object
+	 * @param ssf the server-side socket factory for receiving remote 
+	 * calls
+	 * @throws RemoteException if failed to export object
+	 */
+	public PropagableExecutorImpl(int port, RMIClientSocketFactory csf,
+			RMIServerSocketFactory ssf) throws RemoteException {
+		super(port, csf, ssf);
+	}
+
+	/**
+	 * Executes an object.
+	 * 
+	 * @param host a string that contains the host 
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of hosts 
+	 * @return a <code>RemoteExecutor</code>
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public Object execute(String host, ServerExecutor obj, int times,
+			Object... arguments) throws RemoteException {
+		RemoteExecutor client;
+		try {
+			client = (RemoteExecutor) LocateRegistry.getRegistry(host,
+					Net.getRegistryPort()).lookup(CLIENT_SERVICE_NAME);
+			return client.execute(obj, times, arguments);
+		} catch (AccessException e) {
+			throw new RemoteException(e.getMessage());
+		} catch (NotBoundException e) {
+			throw new RemoteException(e.getMessage());
+		}
+	}
+
+	/**
+	 * Executes an object.
+	 * 
+	 * @param host a string array that contains the hosts 
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of hosts
+	 * @return <code>true</code> if the execution was successful
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public boolean execute(String[] host, ServerExecutor obj, int times,
+			Object... arguments) throws RemoteException {
+		if (host != null && host.length > 0) {
+			PropagableExecutor client;
+			try {
+				client = (PropagableExecutor) LocateRegistry.getRegistry(
+						host[0], Net.getRegistryPort()).lookup(
+						CLIENT_SERVICE_NAME);
+				return client.execute(host, 1, obj, times, arguments);
+			} catch (AccessException e) {
+				throw new RemoteException(e.getMessage());
+			} catch (NotBoundException e) {
+				throw new RemoteException(e.getMessage());
+			}
+		} else {
+			return true;
+		}
+
+	}
+
+	/**
+	 * Executes an object.
+	 * 
+	 * @param host a string array that contains the hosts 
+	 * @param index of execution
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of hosts
+	 * @return <code>true</code> if the execution was successful
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public boolean execute(String[] host, int index, ServerExecutor obj,
+			int times, Object... arguments) throws RemoteException {
+
+		if (index < host.length) {
+			Thread t = threadedExecute(obj, times, arguments);
+			PropagableExecutor client;
+			try {
+				client = (PropagableExecutor) LocateRegistry.getRegistry(
+						host[index], Net.getRegistryPort()).lookup(
+						CLIENT_SERVICE_NAME);
+				client.execute(host, index + 1, obj, times, arguments);
+			} catch (AccessException e) {
+				throw new RemoteException(e.getMessage());
+			} catch (NotBoundException e) {
+				throw new RemoteException(e.getMessage());
+			}
+			if (t.isAlive()) {
+				try {
+					t.join();
+				} catch (InterruptedException e) {
+					log
+							.info("Execute finish with a InterruptedException, when wait the excute finish");
+				}
+			}
+		} else {
+			execute(obj, times, arguments);
+		}
+		return true;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/RemoteExecutor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/RemoteExecutor.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/RemoteExecutor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/RemoteExecutor.java Tue May 16 06:51:00 2006
@@ -0,0 +1,59 @@
+/*
+ *  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.test.rmi.integration.fase2.executor;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Provides the methods for implements remote execution. 
+ * 
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ * 
+ * @version 1.0
+ */
+public interface RemoteExecutor extends ITCRemote {
+
+	/**
+	 * A generic method that receives a <code>ServerExecutor</code> 
+	 * a number of executions and an arbitrary number of arguments 
+	 * and return a generic object.
+	 *  
+	 * @param obj a <code>ServerExecutor</code>
+	 * @param times of the executions
+	 * @param arguments an arbitrary number of arguments
+	 * @return a generic object
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public Object execute(ServerExecutor obj, int times, Object... arguments)
+			throws RemoteException;
+
+	/**
+	 * A generic method that receives a <code>ServerExecutor</code> 
+	 * a number of executions and an arbitrary number of arguments 
+	 * and return a thread.
+	 *  
+	 * @param ser a <code>ServerExecutor</code>
+	 * @param times of the executions 
+	 * @param arguments an arbitrary number of arguments
+	 * @return a thread
+	 * @throws RemoteException if the remote operation fails
+	 */
+	public Thread threadedExecute(final ServerExecutor ser, final int times,
+			final Object... arguments) throws RemoteException;
+}



Mime
View raw message