You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/05/16 15:52:07 UTC
svn commit: r406944 [8/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...
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/RemoteExecutorImpl.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/RemoteExecutorImpl.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/RemoteExecutorImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/RemoteExecutorImpl.java Tue May 16 06:51:00 2006
@@ -0,0 +1,127 @@
+/*
+ * 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 java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.ServerNotActiveException;
+
+import ar.org.fitc.test.rmi.integration.fase2.ITCRemoteUnicast;
+
+/**
+ * Implementation of the <code>RemoteExecutor<code>.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class RemoteExecutorImpl extends ITCRemoteUnicast implements
+ RemoteExecutor {
+
+ /**
+ * Version number unique identificator.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Default constructor.
+ *
+ * @throws RemoteException if the remote operation fails
+ */
+ public RemoteExecutorImpl() throws RemoteException {
+ super();
+ }
+
+ /**
+ * Constructs a <code>RemoteExecutorImpl</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 RemoteExecutorImpl(int port) throws RemoteException {
+ super(port);
+ }
+
+ /**
+ * Constructs a <code>RemoteExecutorImpl</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 RemoteExecutorImpl(int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws RemoteException {
+ super(port, csf, ssf);
+ }
+
+ /**
+ * Executes an object a specified number of times.
+ *
+ * @param obj a <code>ServerExecutor</code>
+ * @param times of the executions
+ * @param arguments an arbitrary number of hosts
+ * @return a result of the execution
+ * @throws RemoteException if the remote operation fails
+ */
+ public Object execute(ServerExecutor obj, int times, Object... arguments)
+ throws RemoteException {
+ if (!imInServer()) {
+ try {
+ System.out.println("\t\tExcecuting execute client: " + getClientHost() + " my: " + ReportIPServer.localHost());
+ } catch (ServerNotActiveException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ for (int i = 0; i < times - 1; i++) {
+ obj.execute(arguments);
+ }
+ return obj.execute(arguments);
+ }
+
+ /**
+ * Executes an object in a thread.
+ *
+ * @param ser a <code>ServerExecutor</code>
+ * @param times of the executions
+ * @param arguments an arbitrary number of hosts
+ * @return a thread
+ * @throws RemoteException if the remote operation fails
+ */
+ public Thread threadedExecute(final ServerExecutor ser, final int times,
+ final Object... arguments) throws RemoteException {
+ Thread t = new Thread() {
+ public void run() {
+ try {
+ execute(ser, times, arguments);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ t.start();
+ return t;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ReportIP.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/ReportIP.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/ReportIP.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ReportIP.java Tue May 16 06:51:00 2006
@@ -0,0 +1,58 @@
+/*
+ * 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 several methods for managing a client-host collection.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public interface ReportIP extends Remote {
+
+ /**
+ * A constant string that represents the name of an object to bind.
+ */
+ public String BIND_NAME = "REPORT_IP_SERVER";
+
+ /**
+ * Constructs a collection with client-hosts IP´s.
+ *
+ * @throws RemoteException if the remote operation fails
+ */
+ public void report() throws RemoteException;
+
+ /**
+ * Returns a client-host IP of the collection.
+ *
+ * @return a client-host IP
+ * @throws RemoteException if the remote operation fails
+ */
+ public String[] getIP() throws RemoteException;
+
+ /**
+ * Returns the host name if the service is activated.
+ *
+ * @return the host name
+ * @throws RemoteException if the remote operation fails
+ */
+ public String myHostName() throws RemoteException;
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ReportIPException.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/ReportIPException.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/ReportIPException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ReportIPException.java Tue May 16 06:51:00 2006
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+/**
+ * Defines the constructors for the <code>ReportIPException</code>
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class ReportIPException extends RemoteException {
+
+ /**
+ * Version number unique identificator.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Default constructor.
+ */
+ public ReportIPException() {
+ super();
+ }
+
+ /**
+ * Sets the message of the exception.
+ *
+ * @param s the exception message
+ */
+ public ReportIPException(String s) {
+ super(s);
+ }
+
+ /**
+ * Sets the message and the cause of the exception.
+ *
+ * @param s the exception message
+ * @param cause the exception cause
+ */
+ public ReportIPException(String s, Throwable cause) {
+ super(s, cause);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ReportIPServer.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/ReportIPServer.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/ReportIPServer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ReportIPServer.java Tue May 16 06:51:00 2006
@@ -0,0 +1,344 @@
+/*
+ * 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.InetAddress;
+import java.net.UnknownHostException;
+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.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.ServerNotActiveException;
+import java.security.Permission;
+import java.util.AbstractCollection;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Random;
+import java.util.TreeSet;
+import java.util.logging.Logger;
+
+import ar.org.fitc.test.rmi.integration.fase2.ITCRemoteUnicast;
+import ar.org.fitc.test.rmi.integration.fase2.Net;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+class Aleatoriator implements Comparator<String> {
+
+ Random rnd = new Random();
+
+ public int compare(String o1, String o2) {
+ if (rnd.nextBoolean()) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+
+}
+/**
+ * Manage the reporting of IP´s and host name of the servers.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+
+public class ReportIPServer extends ITCRemoteUnicast implements ReportIP {
+
+ public static String arrayToString(Object[] arg) {
+ if (arg.length == 0) {
+ return "[]";
+ } else {
+ String result = "[" + arg[0].toString();
+ int i = 1;
+ while(i < arg.length) {
+ result += ", " + arg[i].toString();
+ }
+ result += "]";
+ return result;
+ }
+ }
+
+ private static Comparator<String> compar = new Aleatoriator();
+ /**
+ * For log purpose.
+ */
+ transient private final static Logger log = Logger
+ .getLogger("ar.org.fitc.test.rmi.integration.fase2.executor");
+
+ /**
+ * Version number unique identificator.
+ */
+ private static final long serialVersionUID = 8197377575540620278L;
+
+ /**
+ * The server-host IP.
+ */
+ protected static String SERVER_HOST = "10.100.2.230";
+
+ /**
+ * A <code>TreeSet</code> of client-host IP´s.
+ */
+ protected AbstractCollection<String> listIP = new TreeSet<String>();
+
+ /**
+ * Default constructor.
+ *
+ * @throws RemoteException if the exportation fails
+ */
+ public ReportIPServer() throws RemoteException {
+ super();
+ }
+
+ /**
+ * Constructs a <code>ReportIPServer</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 ReportIPServer(int port) throws RemoteException {
+ super(port);
+ }
+
+ /**
+ * Constructs a <code>ReportIPServer</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 ReportIPServer(int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws RemoteException {
+ super(port, csf, ssf);
+ }
+
+ /**
+ * Constructs a collection with client-hosts IP´s.
+ *
+ * @throws RemoteException if the remote operation fails
+ */
+ public void report() throws RemoteException {
+ try {
+ synchronized (listIP) {
+ if (listIP.add(getClientHost())) {
+ System.out.println("add client:" + getClientHost());
+ }
+ }
+ } catch (ServerNotActiveException e) {
+ log.info("Report IP isn't working");
+ }
+ }
+
+ /**
+ * Returns the host name if the service is activated.
+ *
+ * @return the host name
+ * @throws RemoteException if the remote operation fails
+ */
+ public String myHostName() throws RemoteException {
+ try {
+ return getClientHost();
+ } catch (ServerNotActiveException e) {
+ return SERVER_HOST;
+ }
+ }
+
+ /**
+ * Returns a client-host IP of the collection.
+ *
+ * @return a client-host IP
+ * @throws RemoteException if the remote operation fails
+ */
+ public String[] getIP() throws RemoteException {
+ String[] result;
+
+ synchronized (listIP) {
+ result = listIP.toArray(new String[0]);
+ }
+ Arrays.sort(result, compar);
+ log.info("list of hosts: " + arrayToString(result));
+ return result;
+ }
+ /**
+ * Sets the server-host with the specified name.
+ *
+ * @param host the specified name
+ * @throws UnknownHostException if the host cannot to be determined
+ */
+ public static void setServerHost(String host) throws UnknownHostException {
+ InetAddress.getByName(host);
+ SERVER_HOST = host;
+ }
+
+ /**
+ * For each client-host in the collection obtains a remote
+ * reference if fails removes the IP from the collection.
+ *
+ * @throws InterruptedException if another thread interrupts the
+ * wait
+ */
+ public void checkIP() throws InterruptedException {
+ synchronized (listIP) {
+ AbstractCollection<String> removeIP = new TreeSet<String>();
+
+ for (String ip : listIP) {
+ try {
+ ((ITCRemote) ClientExecutor.getExecutor(ip)).getString();
+ } catch (Exception e) {
+ removeIP.add(ip);
+ }
+ }
+ for (String ip : removeIP) {
+ listIP.remove(ip);
+ }
+ }
+ }
+
+ /**
+ * Obtains the <code>Registry</code> and a stub of the remote
+ * object bounded in the <code>Registry</code>. Puts the host name
+ * of the remote object in the collection.
+ *
+ */
+ public static void doit() {
+ try {
+ Registry r = LocateRegistry.getRegistry(SERVER_HOST, Net
+ .getRegistryPort());
+
+ ((ReportIP) r.lookup(BIND_NAME)).report();
+ } catch (RemoteException e) {
+ log.info("report has same problem: " + e.getMessage());
+ } catch (NotBoundException e) {
+ log.warning("report is not bound.");
+ }
+ }
+
+ /**
+ * Obtains the <code>Registry</code> and a stub of the remote
+ * object bounded in the <code>Registry</code>. Returns the IP
+ * address.
+ *
+ * @return the IP address
+ * @throws ReportIPException if a non-catched exception occurs
+ */
+ public static String[] getit() throws ReportIPException {
+ try {
+ Registry r = LocateRegistry.getRegistry(SERVER_HOST, Net
+ .getRegistryPort());
+ return ((ReportIP) r.lookup(BIND_NAME)).getIP();
+ } catch (RemoteException e) {
+ log.info("report has same problem: " + e.getMessage());
+ throw new ReportIPException("Can't found report server", e);
+ } catch (NotBoundException e) {
+ log.warning("report is not bound.");
+ throw new ReportIPException("Can't found report server", e);
+ }
+
+ }
+
+ /**
+ * Obtains the <code>Registry</code> and a stub of the remote
+ * object bounded in the <code>Registry</code>. Returns the host
+ * name.
+ *
+ * @return the host name
+ * @throws ReportIPException if a non-catched exception occurs
+ */
+ public static String localHost() throws ReportIPException {
+ try {
+ Registry r = LocateRegistry.getRegistry(SERVER_HOST, Net
+ .getRegistryPort());
+ return ((ReportIP) r.lookup(BIND_NAME)).myHostName();
+ } catch (RemoteException e) {
+ log.info("report has same problem: " + e.getMessage());
+ throw new ReportIPException("Can't found report server", e);
+ } catch (NotBoundException e) {
+ log.warning("report is not bound.");
+ throw new ReportIPException("Can't found report server", e);
+ }
+
+ }
+
+ public static Registry getServerRegistry() throws RemoteException {
+ return LocateRegistry.getRegistry(SERVER_HOST, Net.getRegistryPort());
+ }
+
+ static Registry reg;
+ public static void main(String[] argv) {
+
+ System.setSecurityManager(new RMISecurityManager() {
+ public void checkPermission(Permission perm) {
+ };
+ });
+ System.setProperty("ar.org.fitc.rmi.server.threadPoolKeepAliveTime", "1000");
+ System.setProperty("ar.org.fitc.rmi.server.threadPoolCoreSize", "1");
+// System.setProperty("java.rmi.server.codebase",
+// "ftp://proftp:1@10.100.2.230/");
+ System.setProperty("java.rmi.server.hostname", "10.100.2.230");
+ final ReportIPServer rep;
+ try {
+ setServerHost(System.getProperty("java.rmi.server.hostname"));
+ if (!Net.isOwnHost(SERVER_HOST)) {
+ System.out.println("Report IP can't start in hostname "
+ + SERVER_HOST + " because this host is not localhost");
+ } else {
+
+ try {
+ LocateRegistry.createRegistry(Net.getRegistryPort());
+ } catch (RemoteException e1) {
+ }
+
+ reg = LocateRegistry.getRegistry(SERVER_HOST, Net.getRegistryPort());
+
+ for (String service : reg.list()) {
+ if (service.equals(BIND_NAME)) {
+ throw new Exception(
+ "ReportIP is running in other place");
+ }
+ }
+ rep = new ReportIPServer();
+ reg.bind(BIND_NAME, rep);
+
+ System.out.print("ReportIPServer Start...");
+ new Thread() {
+ public void run() {
+ while (true) {
+ try {
+ Thread.sleep(10 * 6000);
+ rep.checkIP();
+ } catch (InterruptedException e) {
+ log.info("cheaking ip fail");
+ }
+
+ }
+ }
+ }.start();
+ }
+ } catch (Exception e) {
+ System.out.print("ReportIPServer no work: " + e.getMessage());
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ServerExecutor.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/ServerExecutor.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/ServerExecutor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/ServerExecutor.java Tue May 16 06:51:00 2006
@@ -0,0 +1,41 @@
+/*
+ * 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 a generic method to execute an object
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public interface ServerExecutor extends ITCRemote {
+
+ /**
+ * Receives an arbitrary number of arguments and return a generic
+ * object.
+ *
+ * @param arguments an arbitrary number of arguments
+ * @return a generic object
+ * @throws RemoteException if the remote operation fails
+ */
+ 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/tests.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/tests.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/tests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/executor/tests.java Tue May 16 06:51:00 2006
@@ -0,0 +1,39 @@
+package ar.org.fitc.test.rmi.integration.fase2.executor;
+
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.NoSuchObjectException;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+
+
+public class tests {
+
+ public tests() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+ public static void main(String[] arg) throws RemoteException {
+
+
+ try {
+ ServerExecutor o = ((ServerExecutor)Naming.lookup("hh"));
+ System.out.println(o.toString());
+ System.out.println(o.getString());
+ Object t= o.execute();;
+ System.out.println(t.getClass());
+ } catch (NoSuchObjectException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (RemoteException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (NotBoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/interfaces/ITCRemote.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/interfaces/ITCRemote.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/interfaces/ITCRemote.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/interfaces/ITCRemote.java Tue May 16 06:51:00 2006
@@ -0,0 +1,66 @@
+/*
+ * 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.interfaces;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Provides several methods for the implementation of objects used
+ * in the series of tests.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public interface ITCRemote extends Remote {
+
+ /**
+ * 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>truez/code> if operation is successful
+ * @throws RemoteException if failed to unexport object
+ */
+ public boolean clean(boolean force) throws RemoteException;
+
+ /**
+ * 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;
+
+ /**
+ * 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;
+
+ /**
+ * 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;
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/interfaces/LogRemote.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/interfaces/LogRemote.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/interfaces/LogRemote.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/interfaces/LogRemote.java Tue May 16 06:51:00 2006
@@ -0,0 +1,39 @@
+/*
+ * 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.interfaces;
+
+import java.rmi.RemoteException;
+
+/**
+ * Provides a method for the implementation of objects used
+ * in the series of tests.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public interface LogRemote extends ITCRemote {
+
+ /**
+ * Prints a string representation of the client host.
+ *
+ * @param arg a string that indicate if is a local or remote
+ * execution
+ * @throws RemoteException if the remote operation fails
+ */
+ public void println(String arg) throws RemoteException;
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/main/StartUp.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/main/StartUp.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/main/StartUp.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/main/StartUp.java Tue May 16 06:51:00 2006
@@ -0,0 +1,120 @@
+/*
+ * 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.main;
+
+import java.net.UnknownHostException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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.test.BigReturnComunicationPerformanceTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.ComunicationPerformanceTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.DGCTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.ExportationPerformanceTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.ITCTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.OverheadComunicationPerformanceTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.PortableTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.PropagableTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.RemoteRegistryTestCase;
+import ar.org.fitc.test.rmi.integration.fase2.test.ReportIPTestCase;
+
+/**
+ * Sets the properties for the start up.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class StartUp extends ITCTestCase {
+
+ /**
+ * Indicates the number of <code>ClientExecutor</code>'s.
+ */
+ public static int numberOfClientExecutor = 1;
+
+ /**
+ * @param arg
+ * @throws Exception
+ */
+ public static void main(String[] arg) throws Exception {
+
+
+
+ Logger.getLogger("ar.org.fitc.test.rmi.integration.fase2.executor")
+ .setLevel(Level.OFF);
+ System.setProperty("ar.org.fitc.rmi.server.threadPoolKeepAliveTime", "1000");
+ System.setProperty("ar.org.fitc.rmi.server.threadPoolMaxSize", "10");
+ System.setProperty("ar.org.fitc.rmi.server.threadPoolCoreSize", "1");
+
+
+ try {
+ {
+ String n = System.getProperty("ar.org.fitc.test.numbreofclientexecutor");
+ if (n != null) {
+ numberOfClientExecutor = Integer.parseInt(n);
+ }
+ }
+
+
+
+ initRegistry();
+ try {
+ ReportIPServer.setServerHost(System.getProperty("java.rmi.server.hostname"));
+ } catch (UnknownHostException e) {
+ fail("The java.rmi.server.hostname property is bad set");
+ }
+
+ ReportIPServer.main(null);
+
+ try {
+ do {
+ System.out.print(".");
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+
+ }
+ System.out.println(arrayToString(ReportIPServer.getit()));
+ } while (ReportIPServer.getit().length < numberOfClientExecutor);
+ } catch (ReportIPException e) {
+ fail("The ReportIP fail with: " + e);
+ }
+ System.out.println();
+
+
+
+ new ReportIPTestCase().run();
+ new RemoteRegistryTestCase().run();
+ new PropagableTestCase().run();
+ new PortableTestCase().run();
+// new RMISocketFactoryTestCase().run();
+ new ComunicationPerformanceTestCase().run();
+ new OverheadComunicationPerformanceTestCase().run();
+ new ExportationPerformanceTestCase().run();
+ new BigReturnComunicationPerformanceTestCase().run();
+ new DGCTestCase().run();
+
+ registry = null;
+
+
+ } finally {
+ // Forcing finish
+ System.exit(0);
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/ExecutorGetClientHost.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/remoteexport/ExecutorGetClientHost.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/ExecutorGetClientHost.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/ExecutorGetClientHost.java Tue May 16 06:51:00 2006
@@ -0,0 +1,63 @@
+/*
+ * 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.remoteexport;
+
+import java.rmi.RemoteException;
+import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UnicastRemoteObject;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor;
+
+/**
+ * Particular implementation of <code>AbstractServerExecutor</code>.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class ExecutorGetClientHost extends AbstractServerExecutor {
+
+ /**
+ * Version number unique identificator.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Default cosntructor.
+ *
+ * @throws RemoteException if the remote operation fails
+ */
+ public ExecutorGetClientHost() throws RemoteException {
+ super();
+ }
+
+ /**
+ * Returns a host address.
+ *
+ * @param arguments not used here
+ * @return an host address
+ * @throws RemoteException if the remote operation fails
+ */
+ @Override
+ public Object execute(Object... arguments) throws RemoteException {
+ try {
+ return UnicastRemoteObject.getClientHost();
+ } catch (ServerNotActiveException e) {
+ return "127.0.0.1";
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/ExportServiceExecutor.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/remoteexport/ExportServiceExecutor.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/ExportServiceExecutor.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/ExportServiceExecutor.java Tue May 16 06:51:00 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.remoteexport;
+
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.UnicastRemoteObject;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.AbstractServerExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Particular implementation of <code>AbstractServerExecutor</code>.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class ExportServiceExecutor extends AbstractServerExecutor {
+
+ /**
+ * Version number unique identificator.
+ */
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Default cosntructor.
+ *
+ * @throws RemoteException if the remote operation fails
+ */
+ public ExportServiceExecutor() throws RemoteException {
+ super();
+ }
+
+ /**
+ * Exports an <code>ITCRemote</code> object.
+ *
+ * @param arguments can be a <code>ITCRemote</code> object, a port
+ * and socket factories as well in this order
+ * @return return a remote object stub or <code>null</code> value
+ * @throws RemoteException if the exporation fails
+ */
+ @Override
+ public Object execute(Object... arguments) throws RemoteException {
+ int argumentCount = ((Integer) arguments[0]).intValue();
+ switch(argumentCount) {
+ case (1) :
+ return UnicastRemoteObject.exportObject((ITCRemote)arguments[1]);
+ case (2) :
+ return UnicastRemoteObject.exportObject((ITCRemote)arguments[1], ((Integer) arguments[2]).intValue());
+ case (4) :
+ return UnicastRemoteObject.exportObject((ITCRemote)arguments[1], ((Integer) arguments[2]).intValue(), (RMIClientSocketFactory)arguments[3], (RMIServerSocketFactory)arguments[4]);
+ default:
+ return null;
+ }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/PortableUnicastRemoteObject.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/remoteexport/PortableUnicastRemoteObject.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/PortableUnicastRemoteObject.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/remoteexport/PortableUnicastRemoteObject.java Tue May 16 06:51:00 2006
@@ -0,0 +1,116 @@
+/*
+ * 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.remoteexport;
+
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RemoteStub;
+
+import ar.org.fitc.test.rmi.integration.fase2.executor.ClientExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.executor.PropagableExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+/**
+ * Implements static methods for export an unexport objects.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class PortableUnicastRemoteObject {
+
+ /**
+ * Default constructor.
+ */
+ public PortableUnicastRemoteObject() {
+ super();
+ }
+
+ /**
+ * Defines a <code>PropagableExecutor</code> object and assigns it
+ * a <code>ClentExecutor</code>.
+ *
+ * @param serverHost the host of the Server
+ * @param obj an <code>ITCRemote</code> object
+ * @return a <code>RemoteStub</code>
+ * @throws RemoteException if the remote operation fails
+ * @throws NotBoundException if name is not currently bound
+ */
+ static public RemoteStub exportObject(String serverHost, ITCRemote obj) throws RemoteException, NotBoundException {
+ PropagableExecutor client;
+ client = ClientExecutor.getExecutor(serverHost);
+ ServerExecutor serv = new ExportServiceExecutor();
+ return (RemoteStub) client.execute(serv, 0, (Integer) 1, obj);
+ }
+
+ /**
+ * Defines a <code>PropagableExecutor</code> object and assigns it
+ * a <code>ClentExecutor</code>.
+ *
+ * @param serverHost the host of the Server
+ * @param obj an <code>ITCRemote</code> object
+ * @param port the specified port
+ * @return an <code>ITCRemote</code> object
+ * @throws RemoteException if the remote operation fails
+ * @throws NotBoundException if name is not currently bound
+ */
+ static public ITCRemote exportObject(String serverHost, ITCRemote obj, int port) throws RemoteException, NotBoundException {
+ PropagableExecutor client;
+ client = ClientExecutor.getExecutor(serverHost);
+ ServerExecutor serv = new ExportServiceExecutor();
+ return (ITCRemote) client.execute(serv, 0, (Integer) 2, obj, port);
+ }
+
+ /**
+ * Defines a <code>PropagableExecutor</code> object and assigns it
+ * a <code>ClentExecutor</code>.
+ *
+ * @param serverHost the host of the Server
+ * @param obj an <code>ITCRemote</code> object
+ * @param port the specified port
+ * @param csf the specified <code>ClientSocketFactory</code>
+ * @param ssf the specified <code>ServerSocketFactory</code>
+ * @return an <code>ITCRemote</code> object
+ * @throws RemoteException if the remote operation fails
+ * @throws NotBoundException if name is not currently bound
+ */
+ static public ITCRemote exportObject(String serverHost, ITCRemote obj, int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws RemoteException, NotBoundException {
+ PropagableExecutor client;
+ client = ClientExecutor.getExecutor(serverHost);
+ ServerExecutor serv = new ExportServiceExecutor();
+ return (ITCRemote) client.execute(serv, 0, (Integer) 4, obj, port, csf, ssf);
+ }
+
+ /**
+ * Unexport a specified <code>ITCRemote</code> object.
+ *
+ * @param obj the specified <code>ITCRemote</code> object
+ * @param force if <code>true</code>, unexports the object even
+ * if there are pending or in-progress calls; if <code>false</code>,
+ * only unexports the object if there are no pending or in-progress
+ * calls
+ * @return true if operation is successful, false otherwise
+ * @throws RemoteException if the remote operation fails
+ */
+ static public boolean unexportObject(ITCRemote obj, boolean force) throws RemoteException {
+ return obj.clean(force);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherRMISocketFactory.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/socketfactory/CipherRMISocketFactory.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherRMISocketFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherRMISocketFactory.java Tue May 16 06:51:00 2006
@@ -0,0 +1,29 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+
+
+public class CipherRMISocketFactory extends RMISocketFactory implements Serializable {
+
+ private static final long serialVersionUID = -7178597099667129705L;
+
+ public CipherRMISocketFactory() {
+ super();
+ }
+
+ @Override
+ public Socket createSocket(String host, int port) throws IOException {
+ return new CipherSocket(host, port);
+ }
+
+ @Override
+ public ServerSocket createServerSocket(int port) throws IOException {
+ return new CipherServerSocket(port);
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherServerSocket.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/socketfactory/CipherServerSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherServerSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherServerSocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,32 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class CipherServerSocket extends ServerSocket {
+
+ public CipherServerSocket() throws IOException {
+ super();
+ }
+
+ public CipherServerSocket(int port) throws IOException {
+ super(port);
+ }
+
+ public CipherServerSocket(int port, int backlog) throws IOException {
+ super(port, backlog);
+ }
+
+ public CipherServerSocket(int port, int backlog, InetAddress bindAddr)
+ throws IOException {
+ super(port, backlog, bindAddr);
+ }
+
+ public Socket accept() throws IOException{
+ Socket s = new CipherSocket();
+ implAccept(s);
+ return s;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherSocket.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/socketfactory/CipherSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/CipherSocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,56 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Proxy;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketImpl;
+import java.net.UnknownHostException;
+
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+
+public class CipherSocket extends Socket {
+
+ public CipherSocket() {
+ super();
+ }
+
+ public CipherSocket(Proxy proxy) {
+ super(proxy);
+ }
+
+ public CipherSocket(SocketImpl impl) throws SocketException {
+ super(impl);
+ }
+
+ public CipherSocket(String host, int port) throws UnknownHostException,
+ IOException {
+ super(host, port);
+ }
+
+ public CipherSocket(InetAddress address, int port) throws IOException {
+ super(address, port);
+ }
+
+ public CipherSocket(String host, int port, InetAddress localAddr,
+ int localPort) throws IOException {
+ super(host, port, localAddr, localPort);
+ }
+
+ public CipherSocket(InetAddress address, int port, InetAddress localAddr,
+ int localPort) throws IOException {
+ super(address, port, localAddr, localPort);
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return new CipherOutputStream(super.getOutputStream(), RemoteCipherImpl.getCipher(Cipher.ENCRYPT_MODE));
+ }
+ public InputStream getInputStream() throws IOException {
+ return new CipherInputStream(super.getInputStream(), RemoteCipherImpl.getCipher(Cipher.DECRYPT_MODE));
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelayRMISocketFactory.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/socketfactory/DelayRMISocketFactory.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelayRMISocketFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelayRMISocketFactory.java Tue May 16 06:51:00 2006
@@ -0,0 +1,33 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+
+/**
+ * A Client Socket Factory that delays the data channel
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+public class DelayRMISocketFactory extends RMISocketFactory {
+
+ public DelayRMISocketFactory() {
+ super();
+ }
+
+ @Override
+ public Socket createSocket(String arg0, int arg1) throws IOException {
+ return new DelaySocket(arg0,arg1);
+ }
+
+ @Override
+ public ServerSocket createServerSocket(int arg0) throws IOException {
+ return new DelayServerSocket(arg0);
+ }
+
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelayServerSocket.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/socketfactory/DelayServerSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelayServerSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelayServerSocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,23 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+
+/**
+ * A Server Socket that delays the data channel
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+public class DelayServerSocket extends ServerSocket {
+
+ public DelayServerSocket(int arg0) throws IOException {
+ super(arg0);
+ }
+
+ public DelayServerSocket() throws IOException {
+ super();
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelaySocket.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/socketfactory/DelaySocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelaySocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/DelaySocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,58 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Proxy;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketImpl;
+import java.net.UnknownHostException;
+
+/**
+ * A Socket that delays the data channel
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+public class DelaySocket extends Socket {
+ public DelaySocket() {
+ super();
+ }
+
+ public DelaySocket(Proxy proxy) {
+ super(proxy);
+ }
+
+ public DelaySocket(SocketImpl impl) throws SocketException {
+ super(impl);
+ }
+
+ public DelaySocket(String host, int port) throws UnknownHostException,
+ IOException {
+ super(host, port);
+ }
+
+ public DelaySocket(InetAddress address, int port) throws IOException {
+ super(address, port);
+ }
+
+ public DelaySocket(String host, int port, InetAddress localAddr,
+ int localPort) throws IOException {
+ super(host, port, localAddr, localPort);
+ }
+
+ public DelaySocket(InetAddress address, int port, InetAddress localAddr,
+ int localPort) throws IOException {
+ super(address, port, localAddr, localPort);
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return super.getOutputStream();
+ }
+ public InputStream getInputStream() throws IOException {
+ return super.getInputStream();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipClientSocketFactory.jav
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/socketfactory/GZipClientSocketFactory.jav?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipClientSocketFactory.jav (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipClientSocketFactory.jav Tue May 16 06:51:00 2006
@@ -0,0 +1,24 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.Socket;
+import java.rmi.server.RMIClientSocketFactory;
+
+/**
+ * A Client Socket Factory that compress data
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+public class GZipClientSocketFactory implements RMIClientSocketFactory, Serializable {
+
+ private static final long serialVersionUID = -5171232459222429076L;
+
+ public Socket createSocket(String host, int port)
+ throws IOException {
+ GZipSocket socket = new GZipSocket(host, port);
+ return socket;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipRMISocketFactory.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/socketfactory/GZipRMISocketFactory.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipRMISocketFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipRMISocketFactory.java Tue May 16 06:51:00 2006
@@ -0,0 +1,35 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+
+/**
+ * A RMI Socket Factory that compress data
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+
+public class GZipRMISocketFactory extends RMISocketFactory implements Serializable {
+
+ private static final long serialVersionUID = 1372758287532040991L;
+
+ public GZipRMISocketFactory() {
+ super();
+ }
+ @Override
+ public Socket createSocket(String arg0, int arg1) throws IOException {
+ return new GZipSocket(arg0,arg1);
+ }
+
+ @Override
+ public ServerSocket createServerSocket(int arg0) throws IOException {
+ return new GZipServerSocket(arg0);
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipServerSocket.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/socketfactory/GZipServerSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipServerSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipServerSocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,43 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+
+/**
+ * A Server Socket that compress data
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+
+public class GZipServerSocket extends ServerSocket {
+
+ public GZipServerSocket() throws IOException {
+ super();
+ }
+
+ public GZipServerSocket(int port, int backlog) throws IOException {
+ super(port, backlog);
+ }
+
+ public GZipServerSocket(int port, int backlog, InetAddress bindAddr)
+ throws IOException {
+ super(port, backlog, bindAddr);
+ }
+
+ public GZipServerSocket(int port) throws IOException {
+ super(port);
+ }
+
+ public Socket accept() throws IOException {
+ Socket socket = new GZipSocket();
+ implAccept(socket);
+ return socket;
+ }
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipServerSocketFactory.jav
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/socketfactory/GZipServerSocketFactory.jav?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipServerSocketFactory.jav (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipServerSocketFactory.jav Tue May 16 06:51:00 2006
@@ -0,0 +1,27 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.ServerSocket;
+import java.rmi.server.RMIServerSocketFactory;
+
+
+/**
+ * A Server Socket Factory that compress data
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+public class GZipServerSocketFactory implements RMIServerSocketFactory, Serializable {
+
+ private static final long serialVersionUID = 3546154586009446002L;
+
+ public ServerSocket createServerSocket(int port)
+ throws IOException {
+ GZipServerSocket server = new GZipServerSocket(port);
+ return server;
+ }
+}
+
+
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipSocket.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/socketfactory/GZipSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/GZipSocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,79 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Proxy;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketImpl;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+
+/**
+ * A Socket that compress data
+ *
+ * @author Osvaldo Demo
+ *
+ * @version 1.0
+ */
+
+public class GZipSocket extends Socket {
+
+ private InputStream in;
+
+ private OutputStream out;
+
+
+ public GZipSocket(Proxy proxy) {
+ super(proxy);
+ }
+
+ public GZipSocket(SocketImpl impl) throws SocketException {
+ super(impl);
+ }
+
+ public GZipSocket(InetAddress address, int port) throws IOException {
+ super(address, port);
+ }
+
+ public GZipSocket(String host, int port, InetAddress localAddr,
+ int localPort) throws IOException {
+ super(host, port, localAddr, localPort);
+ }
+
+ public GZipSocket(InetAddress address, int port, InetAddress localAddr,
+ int localPort) throws IOException {
+ super(address, port, localAddr, localPort);
+ }
+
+ public GZipSocket() {
+ super();
+ }
+
+ public GZipSocket(String host, int port) throws IOException {
+ super(host, port);
+ }
+
+ public InputStream getInputStream() throws IOException {
+ if (in == null) {
+ in = new ZipInputStream(super.getInputStream());
+ }
+ return in;
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ if (out == null) {
+ out = new ZipOutputStream(super.getOutputStream());
+ }
+ return out;
+ }
+
+ public synchronized void close() throws IOException {
+ OutputStream o = getOutputStream();
+ o.flush();
+ super.close();
+ }
+}
\ 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/socketfactory/RemoteCipher.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/socketfactory/RemoteCipher.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/RemoteCipher.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/RemoteCipher.java Tue May 16 06:51:00 2006
@@ -0,0 +1,15 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface RemoteCipher<T extends Serializable> extends Remote {
+
+ public byte[] encipher(T s) throws RemoteException;
+ public T decipher(byte[] b) throws RemoteException;
+ public byte[][] encipher(T[] s) throws RemoteException;
+ public T[] decipher(byte[][] b) throws RemoteException;
+
+ public Class getTClass() throws RemoteException;
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/RemoteCipherImpl.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/socketfactory/RemoteCipherImpl.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/RemoteCipherImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/socketfactory/RemoteCipherImpl.java Tue May 16 06:51:00 2006
@@ -0,0 +1,103 @@
+package ar.org.fitc.test.rmi.integration.fase2.socketfactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.math.BigInteger;
+import java.rmi.RemoteException;
+import java.security.GeneralSecurityException;
+import java.security.Key;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+
+
+public class RemoteCipherImpl implements RemoteCipher<BigInteger> {
+
+ private Cipher encipher;
+ private Cipher decipher;
+
+ private final BigInteger deserialization(byte[] b) throws IOException,
+ ClassNotFoundException {
+ ByteArrayInputStream bais = new ByteArrayInputStream(b);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ BigInteger result = (BigInteger) ois.readObject();
+ ois.close();
+ return result;
+ }
+
+ private final byte[] serialization(BigInteger object) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(object);
+ oos.close();
+ return baos.toByteArray();
+ }
+ static public Cipher getCipher(int mode) {
+ Cipher cipher;
+ try {
+ cipher = Cipher.getInstance("DES/CFB8/NoPadding", "SunJCE");
+ byte[] password = new byte[] {(byte)1, (byte)24, (byte)234, (byte)345, (byte)23, (byte)432, (byte)3, (byte)43};
+ Key key = SecretKeyFactory.getInstance("DES").translateKey(
+ new SecretKeySpec(password, "DES"));
+ cipher.init(mode, key, new IvParameterSpec(password));
+ } catch (GeneralSecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ return cipher;
+ }
+
+ public RemoteCipherImpl() {
+ super();
+ encipher = getCipher(Cipher.ENCRYPT_MODE);
+ decipher = getCipher(Cipher.DECRYPT_MODE);
+ }
+
+ public byte[] encipher(BigInteger s) throws RemoteException {
+ try {
+ return encipher.update(serialization(s));
+ } catch (IOException e) {
+ throw new RemoteException(e.getMessage());
+ }
+ }
+
+ public byte[][] encipher(BigInteger[] s) throws RemoteException {
+ byte[][] result;
+ result = new byte[s.length][];
+ for (int i=s.length; i-- > 0;) {
+ result[i] = encipher(s[i]);
+ }
+ return result;
+ }
+
+ public BigInteger decipher(byte[] b) throws RemoteException {
+ try {
+ return deserialization(decipher.update(b));
+ } catch (IOException e) {
+ throw new RemoteException(e.getMessage());
+ } catch (ClassNotFoundException e) {
+ throw new RemoteException(e.getMessage());
+ }
+ }
+
+ public BigInteger[] decipher(byte[][] b) throws RemoteException {
+ BigInteger[] result;
+ result = new BigInteger[b.length];
+ for (int i=b.length; i-- > 0;) {
+ result[i] = decipher(b[i]);
+ }
+ return result;
+ }
+
+ public Class getTClass() throws RemoteException {
+ return BigInteger.class;
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/BigReturnComunicationPerformanceTestCase.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/test/BigReturnComunicationPerformanceTestCase.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/BigReturnComunicationPerformanceTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/BigReturnComunicationPerformanceTestCase.java Tue May 16 06:51:00 2006
@@ -0,0 +1,35 @@
+package ar.org.fitc.test.rmi.integration.fase2.test;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.TimeWaitBigReturn;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor;
+
+public class BigReturnComunicationPerformanceTestCase extends
+ PerformanceTestCase {
+
+ public BigReturnComunicationPerformanceTestCase() {
+ super();
+ }
+
+ public BigReturnComunicationPerformanceTestCase(String arg0) {
+ super(arg0);
+ }
+
+ protected ServerExecutor object;
+ protected void setUp() throws Exception {
+ object = new TimeWaitBigReturn();
+ super.setUp();
+ }
+
+ @Override
+ protected long oneTest() throws RemoteException {
+ long startTime = System.currentTimeMillis();
+ Object result = executor.execute(object, 1);
+ long stopTime = System.currentTimeMillis();
+ Object[] arr = (Object[]) result;
+ long clientTime= ((Long)arr[0]).longValue();
+ return stopTime - startTime - clientTime;
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ComunicationPerformanceTestCase.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/test/ComunicationPerformanceTestCase.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ComunicationPerformanceTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ComunicationPerformanceTestCase.java Tue May 16 06:51:00 2006
@@ -0,0 +1,33 @@
+package ar.org.fitc.test.rmi.integration.fase2.test;
+
+import java.rmi.RemoteException;
+
+import ar.org.fitc.test.rmi.integration.fase2.TimeWait;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor;
+
+public class ComunicationPerformanceTestCase extends PerformanceTestCase {
+
+ public ComunicationPerformanceTestCase() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public ComunicationPerformanceTestCase(String arg0) {
+ super(arg0);
+ // TODO Auto-generated constructor stub
+ }
+ protected ServerExecutor object;
+ protected void setUp() throws Exception {
+ object = new TimeWait();
+ super.setUp();
+ }
+
+ @Override
+ protected long oneTest() throws RemoteException {
+ long startTime = System.currentTimeMillis();
+ long clientTime= (Long)executor.execute(object, 1);
+ long stopTime = System.currentTimeMillis();
+ return stopTime - startTime - clientTime;
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/DGCTestCase.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/test/DGCTestCase.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/DGCTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/DGCTestCase.java Tue May 16 06:51:00 2006
@@ -0,0 +1,232 @@
+/*
+ * 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.test;
+
+import java.lang.ref.WeakReference;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import junit.framework.AssertionFailedError;
+import ar.org.fitc.test.rmi.integration.fase2.LogRemoteImpl;
+import ar.org.fitc.test.rmi.integration.fase2.MoveRemoteObject;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ServerExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.LogRemote;
+import ar.org.fitc.test.rmi.integration.fase2.remoteexport.PortableUnicastRemoteObject;
+
+/**
+ * Testing class for Distributed Garbage Collector.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class DGCTestCase extends ExecutorTestCase {
+
+ /**
+ * A <code>LogRemoteImpl</code>.
+ */
+ public LogRemoteImpl remote;
+
+ /**
+ * A <code>ServerExecutor</code>.
+ */
+ public ServerExecutor serv;
+
+ /**
+ * A <code>WeakReference</code>.
+ */
+ public WeakReference wref;
+
+ /**
+ * A <code>LogReRemote</code>.
+ */
+ public LogRemote stub;
+
+
+ /**
+ * Default constructor.
+ *
+ */
+ public DGCTestCase() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>DGCTestCase</code> with a name.
+ *
+ * @param arg0 a name.
+ */
+ public DGCTestCase(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Wait for a reference.
+ *
+ * @param ref a specified <code>WeakReference</code>
+ */
+ @SuppressWarnings("unused")
+ private void waitRef(WeakReference ref) {
+ System.out.print("waiting");
+ try {
+ for (int i = 0; i < 40; i++) {
+ System.out.print(".");
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) { }
+ assertNotNull(wref);
+ }
+ } catch (AssertionFailedError e) {
+ }
+ System.out.println();
+ }
+
+ /**
+ * Exports a remote object.
+ *
+ * @throws Exception if any exception occurs
+ */
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ remote = new LogRemoteImpl();
+ stub = (LogRemote) UnicastRemoteObject.exportObject(remote, 0);
+ // Container and remote execution
+ serv = new MoveRemoteObject(remote);
+ wref = new WeakReference(remote);
+ super.setUp();
+ }
+
+ /**
+ * Unexport a remote object.
+ *
+ * @throws Exception if any exception occurs
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (wref.get() != null) {
+ UnicastRemoteObject.unexportObject((ITCRemote) wref.get(), true);
+ }
+ }
+
+ /**
+ * This test copies -through all servers- the reference (stub)
+ * of an exported remote object. The life time of these objects
+ * is limited, they work and then they are deleted. All local
+ * strong references to the object are deleted and we expect
+ * that the DGC collect the remote object.
+ *
+ * @throws RemoteException if any remote operation fails
+ * @throws NotBoundException if the name is not currently bound
+ */
+ @SuppressWarnings("unchecked")
+ public void testMovingReference001() throws RemoteException,
+ NotBoundException {
+
+ executor.execute(hosts, serv, 10);
+
+ // Obtains s WeakreRerence and clean all local reference
+ remote = null;
+ serv = null;
+ // a local stub not change the DGC behavior.
+ // stub = null;
+
+ // Force GC in all clean
+ // GCRemote.forceRemoteGC();
+ waitRef(wref);
+ assertNull("the reference is not null",wref);
+ }
+
+ /**
+ * Exports a non exported object that has a reference to an
+ * exported object in an external host. If all local strong
+ * references are deleted and only the exported object in the
+ * external host has a reference to the local object, then the
+ * local object is not collected.
+ *
+ * @throws RemoteException if any remote operation fails
+ * @throws NotBoundException if the name is not currently bound
+ */
+ public void testMovingReference002() throws RemoteException, NotBoundException {
+
+ LogRemoteImpl remote2 = new LogRemoteImpl();
+ remote2.out = remote;
+ stub = (LogRemote) PortableUnicastRemoteObject.exportObject(
+ hosts[0], remote2, 0);
+ remote2 = null;
+ remote = null; serv = null;
+ //assertNotNull("The reference is gone here",wref);
+ stub = null;
+ waitRef(wref);
+ assertNull("The reference is gone here",wref);
+ }
+
+ /**
+ * Makes a cyclic reference using the stub of the remote object.
+ * The specified objects are in the same host. The DGC will detect
+ * the cyclic reference and collect them.
+ *
+ * @throws RemoteException if any remote operation fails
+ * @throws NotBoundException if the name is not currently bound
+ */
+ public void testCyclicReference001() throws RemoteException,
+ NotBoundException {
+ LogRemoteImpl remote2 = new LogRemoteImpl();
+ LogRemoteImpl remote3 = new LogRemoteImpl();
+ remote3.out = stub;
+ remote2.out = (LogRemote) UnicastRemoteObject.exportObject(remote3, 0);
+ remote.out = (LogRemote) UnicastRemoteObject.exportObject(remote2, 0);
+ remote3 = null; remote2 = null;
+
+ testMovingReference001();
+ }
+
+ /**
+ * Makes a cyclic reference to the remote objects that they are
+ * in different hosts. The DGC not will detect the cyclic reference
+ * and not collect them.
+ *
+ * @throws RemoteException if any remote operation fails
+ * @throws NotBoundException if the name is not currently bound
+ */
+ public void testCyclicReference002() throws RemoteException,
+ NotBoundException {
+ LogRemoteImpl remote2 = new LogRemoteImpl();
+ LogRemoteImpl remote3 = new LogRemoteImpl();
+ remote3.out = remote;
+ remote2.out = (LogRemote) PortableUnicastRemoteObject.exportObject(
+ hosts[1], remote3, 0);
+ remote.out = (LogRemote) PortableUnicastRemoteObject.exportObject(
+ hosts[0], remote2, 0);
+
+ remote2 = null; remote3 = null;
+ executor.execute(hosts, serv, 10);
+
+ // Obtains s WeakreRerence and clean all local reference
+ remote = null;
+ serv = null;
+ // a local stub not change the DGC behavior.
+ // stub = null;
+
+ // Force GC in all clean
+ // GCRemote.forceRemoteGC();
+ waitRef(wref);
+ assertNotNull("the reference mustn't clean",wref);
+
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ExecutorTestCase.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/test/ExecutorTestCase.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ExecutorTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ExecutorTestCase.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.test.rmi.integration.fase2.test;
+
+import ar.org.fitc.test.rmi.integration.fase2.Net;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ClientExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.executor.PropagableExecutor;
+import ar.org.fitc.test.rmi.integration.fase2.executor.ReportIPServer;
+
+/**
+ * Testing class for a <code>PropagableExecutor</code>.
+ *
+ * @author Jorge Rafael
+ * @author Marcelo Arcidiacono
+ *
+ * @version 1.0
+ */
+public class ExecutorTestCase extends ITCTestCase {
+
+ /**
+ * An arrays of hosts.
+ */
+ public String[] hosts;
+
+ /**
+ * A <code>PropagableExecutor</code>.
+ */
+ public PropagableExecutor executor;
+
+ /**
+ * Default constructor.
+ *
+ */
+ public ExecutorTestCase() {
+ super();
+ }
+
+ /**
+ * Constructs a <code>ExecutorTestCase</code> with a name.
+ *
+ * @param arg0 a name.
+ */
+ public ExecutorTestCase(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * Obtains a <code>PropagableExecutor</code> for a reported host.
+ *
+ * @throws Exception if any exception occurs
+ */
+ protected void setUp() throws Exception {
+ hosts = ReportIPServer.getit();
+ for (String host: hosts) {
+ if (!Net.isOwnHost(host)) {
+ executor = ClientExecutor.getExecutor(host);
+ break;
+ }
+ }
+
+ super.setUp();
+ }
+
+ /**
+ * Simple implementation.
+ *
+ * @throws Exception if any exception occurs
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ hosts = null;
+ executor = null;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ExportationPerformanceTestCase.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/test/ExportationPerformanceTestCase.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ExportationPerformanceTestCase.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/rmi-1.4.2/src/ar/org/fitc/test/rmi/integration/fase2/test/ExportationPerformanceTestCase.java Tue May 16 06:51:00 2006
@@ -0,0 +1,32 @@
+package ar.org.fitc.test.rmi.integration.fase2.test;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+import ar.org.fitc.test.rmi.integration.fase2.AbstractITCRemote;
+import ar.org.fitc.test.rmi.integration.fase2.interfaces.ITCRemote;
+
+public class ExportationPerformanceTestCase extends PerformanceTestCase {
+
+ public ExportationPerformanceTestCase() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public ExportationPerformanceTestCase(String arg0) {
+ super(arg0);
+
+ }
+
+ @Override
+ protected long oneTest() throws RemoteException {
+ ITCRemote o = new AbstractITCRemote();
+ long startTime = System.currentTimeMillis();
+ UnicastRemoteObject.exportObject(o, 0);
+ long stopTime = System.currentTimeMillis();
+ UnicastRemoteObject.unexportObject(o, false);
+ return stopTime - startTime;
+
+ }
+
+}