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 [22/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/testin...
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/Calculator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/Calculator.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/Calculator.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/Calculator.java Tue May 16 06:51:00 2006
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+public interface Calculator extends Remote {
+
+ public static final String SERVICENAME = "RemoteCalculator";
+
+ public void setVectorA(Vector data) throws RemoteException;
+
+ public void setMatrixA(int[][] data) throws RemoteException;
+
+ public void setMatrixB(int[][] data) throws RemoteException;
+
+ public int[][] sumMatrixAB() throws RemoteException;
+
+ public int[][] multiplyMatrixAB() throws RemoteException;
+
+ public double[] getDevProm() throws RemoteException;
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/Calculator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CalculatorBI.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CalculatorBI.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CalculatorBI.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CalculatorBI.java Tue May 16 06:51:00 2006
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.math.BigInteger;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+public interface CalculatorBI extends Remote {
+
+ public static final String SERVICENAME = "RemoteCalculator";
+
+ public void setVectorA(Vector data) throws RemoteException;
+
+ public void setMatrixA(BigInteger[][] data) throws RemoteException;
+
+ public void setMatrixB(BigInteger[][] data) throws RemoteException;
+
+ public BigInteger[][] sumMatrixAB() throws RemoteException;
+
+ public BigInteger[][] multiplyMatrixAB() throws RemoteException;
+
+ public double[] getDevProm() throws RemoteException;
+
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CalculatorBI.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherRMISocketFactory.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherRMISocketFactory.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherRMISocketFactory.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherRMISocketFactory.java Tue May 16 06:51:00 2006
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.rmi.server.RMISocketFactory;
+
+public class CipherRMISocketFactory extends RMISocketFactory {
+
+ public CipherRMISocketFactory() {
+ super();
+ }
+
+ public Socket createSocket(String host, int port) throws IOException {
+ return new CipherSocket(host, port);
+ }
+
+ public ServerSocket createServerSocket(int port) throws IOException {
+ return new CipherServerSocket(port);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherRMISocketFactory.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherServerSocket.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherServerSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherServerSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherServerSocket.java Tue May 16 06:51:00 2006
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+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;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherServerSocket.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherSocket.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherSocket.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherSocket.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherSocket.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+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.*;
+
+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 CipherSocket(String host, int port, boolean stream)
+ throws IOException {
+ super(host, port, stream);
+ }
+
+ public CipherSocket(InetAddress host, int port, boolean stream)
+ throws IOException {
+ super(host, port, stream);
+ }
+
+ 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));
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/CipherSocket.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTest.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTest.java Tue May 16 06:51:00 2006
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface ProtocolTest extends Remote {
+
+ public static final String SERVICENAME = "ProtocolTest";
+
+ public void setByte(byte data) throws RemoteException;
+
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestByte.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestByte.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestByte.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestByte.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+public class ProtocolTestByte extends UnicastRemoteObject implements
+ ProtocolTest {
+
+ public ProtocolTestByte() throws RemoteException {
+ super();
+ }
+
+ public void setByte(byte data) throws RemoteException {
+
+ System.out.println(data);
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestByte.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestClient.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestClient.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestClient.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestClient.java Tue May 16 06:51:00 2006
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+public class ProtocolTestClient {
+
+ public static void main(String[] args) {
+
+ String addr = "127.0.0.1";
+
+ ProtocolTest pt = null;
+ Registry remoteRegistry = null;
+
+
+ byte b = 0x43;
+
+ try {
+ remoteRegistry = LocateRegistry.getRegistry(addr);
+ pt = (ProtocolTest) remoteRegistry.lookup(ProtocolTest.SERVICENAME);
+
+ pt.setByte(b);
+ pt.setByte((byte) 0x12);
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } catch (NotBoundException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestClient.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestServer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestServer.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestServer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestServer.java Tue May 16 06:51:00 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+public class ProtocolTestServer {
+
+ public static void main(String[] args) {
+ Registry localRegistry = null;
+ System.setProperty("sun.rmi.transport.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.readTimeout", "1000");
+
+ try {
+ localRegistry = LocateRegistry
+ .createRegistry(Registry.REGISTRY_PORT);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ ProtocolTestByte rc = new ProtocolTestByte();
+ localRegistry.rebind(ProtocolTest.SERVICENAME, rc);
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/ProtocolTestServer.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculator.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculator.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculator.java Tue May 16 06:51:00 2006
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class RemoteCalculator extends UnicastRemoteObject implements Calculator {
+
+ public RemoteCalculator() throws RemoteException {
+ super();
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ private Vector v1;
+
+ private int[][] m1;
+
+ private int[][] m2;
+
+ public void setVectorA(Vector data) {
+ if (data.size() < 1) {
+ throw new RuntimeException("Vector should not be empty!");
+ }
+ try {
+ System.out.println("Vector A entered from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ this.v1 = data;
+ System.out.println(data.toString());
+ System.out.println();
+ }
+
+ public double[] getDevProm() {
+ try {
+ System.out
+ .println("get Standard Deviation and Average called from "
+ + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ double[] result = new double[2];
+ if ((v1 == null) || (v1.size() <= 1)) {
+ result[0] = 0;
+ result[1] = 0;
+ return result;
+ }
+
+ double sumatoria = 0;
+ Enumeration e = v1.elements();
+ while (e.hasMoreElements()) {
+ Double oneValue = (Double) e.nextElement();
+ double dValue = oneValue.doubleValue();
+ sumatoria += dValue;
+ }
+
+ double promedio = sumatoria / v1.size();
+ double temp = 0;
+
+ e = v1.elements();
+
+ while (e.hasMoreElements()) {
+ Double value = (Double) e.nextElement();
+ double doubleValue = value.doubleValue();
+ temp += Math.pow(doubleValue - promedio, 2.0);
+ }
+
+ double devstandard = Math.sqrt(temp / (v1.size() - 1));
+
+ System.out.println("Standard Deviation: " + devstandard);
+ System.out.println("Average: " + promedio);
+ result[0] = devstandard;
+ result[1] = promedio;
+ return result;
+ }
+
+ public void setMatrixA(int[][] data) {
+ if (data.length != data[0].length) {
+ throw new RuntimeException("Matrix should be square!");
+ }
+ try {
+ System.out.println("Matrix A entered from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ System.out.println(Arrays.toString(data[0]));
+ System.out.println(Arrays.toString(data[1]));
+ System.out.println();
+ this.m1 = data;
+ }
+
+ public void setMatrixB(int[][] data) {
+ if (data.length != data[0].length) {
+ throw new RuntimeException("Matrix should be square!");
+ }
+ try {
+ System.out.println("Matrix B entered from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ System.out.println(Arrays.toString(data[0]));
+ System.out.println(Arrays.toString(data[1]));
+ System.out.println();
+ this.m2 = data;
+ }
+
+ public int[][] sumMatrixAB() {
+ if ((m1 == null) || (m2 == null)) {
+ throw new RuntimeException("Matrix not loaded");
+ }
+ try {
+ System.out.println("add Matrix called from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ int[][] result = new int[m1.length][m2.length];
+ int i, j;
+ for (i = 0; i < m1.length; i++) {
+ for (j = 0; j < m2.length; j++) {
+ result[i][j] = m1[i][j] + m2[i][j];
+ }
+ }
+ System.out.println("Result Matrix (add)");
+ System.out.println(Arrays.toString(result[0]));
+ System.out.println(Arrays.toString(result[1]));
+ System.out.println();
+ return result;
+ }
+
+ public int[][] multiplyMatrixAB() {
+ if ((m1 == null) || (m2 == null)) {
+ throw new RuntimeException("Matrix not loaded");
+ }
+ try {
+ System.out
+ .println("multiply Matrix called from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ int[][] result = new int[m1.length][m2.length];
+ int i, j, k;
+ int sum;
+
+ for (i = 0; i < m1.length; i++) {
+ for (j = 0; j < m2.length; j++) {
+ sum = 0;
+ for (k = 0; k < m1.length; k++) {
+ sum += m1[i][k] * m2[k][j];
+ }
+ result[i][j] = sum;
+ }
+ }
+ System.out.println("Result Matrix (multiply)");
+ System.out.println(Arrays.toString(result[0]));
+ System.out.println(Arrays.toString(result[1]));
+ System.out.println();
+ return result;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculator.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorBI.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorBI.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorBI.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorBI.java Tue May 16 06:51:00 2006
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.math.BigInteger;
+import java.rmi.RemoteException;
+import java.rmi.server.ServerNotActiveException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class RemoteCalculatorBI extends UnicastRemoteObject implements
+ CalculatorBI {
+
+ public RemoteCalculatorBI() throws RemoteException {
+ super();
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ private Vector v1;
+
+ private BigInteger[][] m1;
+
+ private BigInteger[][] m2;
+
+ public void setVectorA(Vector data) {
+ if (data.size() < 1) {
+ throw new RuntimeException("Vector should not be empty!");
+ }
+ try {
+ System.out.println("Vector A entered from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ this.v1 = data;
+ System.out.println(data.toString());
+ System.out.println();
+ }
+
+ public double[] getDevProm() {
+ try {
+ System.out
+ .println("get Standard Deviation and Average called from "
+ + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ double[] result = new double[2];
+ if ((v1 == null) || (v1.size() <= 1)) {
+ result[0] = 0;
+ result[1] = 0;
+ return result;
+ }
+
+ double sumatoria = 0;
+ Enumeration e = v1.elements();
+ while (e.hasMoreElements()) {
+ Double oneValue = (Double) e.nextElement();
+ double dValue = oneValue.doubleValue();
+ sumatoria += dValue;
+ }
+
+ double promedio = sumatoria / v1.size();
+ double temp = 0;
+
+ e = v1.elements();
+
+ while (e.hasMoreElements()) {
+ Double value = (Double) e.nextElement();
+ double doubleValue = value.doubleValue();
+ temp += Math.pow(doubleValue - promedio, 2.0);
+ }
+
+ double devstandard = Math.sqrt(temp / (v1.size() - 1));
+
+ System.out.println("Standard Deviation: " + devstandard);
+ System.out.println("Average: " + promedio);
+ result[0] = devstandard;
+ result[1] = promedio;
+ return result;
+ }
+
+ public void setMatrixA(BigInteger[][] data) {
+ if (data.length != data[0].length) {
+ throw new RuntimeException("Matrix should be square!");
+ }
+ try {
+ System.out.println("Matrix A entered from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ System.out.println(Arrays.toString(data[0]));
+ System.out.println(Arrays.toString(data[1]));
+ System.out.println();
+ this.m1 = data;
+ }
+
+ public void setMatrixB(BigInteger[][] data) {
+ if (data.length != data[0].length) {
+ throw new RuntimeException("Matrix should be square!");
+ }
+ try {
+ System.out.println("Matrix B entered from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ System.out.println(Arrays.toString(data[0]));
+ System.out.println(Arrays.toString(data[1]));
+ System.out.println();
+ this.m2 = data;
+ }
+
+ public BigInteger[][] sumMatrixAB() {
+ if ((m1 == null) || (m2 == null)) {
+ throw new RuntimeException("Matrix not loaded");
+ }
+
+ try {
+ System.out.println("add Matrix called from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ BigInteger[][] result = new BigInteger[m1.length][m2.length];
+
+ int i, j;
+ for (i = 0; i < m1.length; i++) {
+ for (j = 0; j < m2.length; j++) {
+ result[i][j] = m1[i][j].add(m2[i][j]);
+ }
+ }
+ System.out.println("Result Matrix (add)");
+ System.out.println(Arrays.toString(result[0]));
+ System.out.println(Arrays.toString(result[1]));
+ System.out.println();
+ return result;
+ }
+
+ public BigInteger[][] multiplyMatrixAB() {
+ if ((m1 == null) || (m2 == null)) {
+ throw new RuntimeException("Matrix not loaded");
+ }
+
+ try {
+ System.out
+ .println("multiply Matrix called from " + getClientHost());
+ } catch (ServerNotActiveException e) {
+ e.printStackTrace();
+ }
+ BigInteger[][] result = new BigInteger[m1.length][m2.length];
+
+ int i, j, k;
+ BigInteger sum;
+
+ for (i = 0; i < m1.length; i++) {
+ for (j = 0; j < m2.length; j++) {
+ sum = BigInteger.ZERO;
+ for (k = 0; k < m1.length; k++) {
+ sum = m1[i][k].multiply(m2[k][j]).add(sum);
+ }
+ result[i][j] = sum;
+ }
+ }
+ System.out.println("Result Matrix (multiply)");
+ System.out.println(Arrays.toString(result[0]));
+ System.out.println(Arrays.toString(result[1]));
+ System.out.println();
+ return result;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorBI.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClient.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClient.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClient.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClient.java Tue May 16 06:51:00 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.io.IOException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
+import java.util.Arrays;
+import java.util.Vector;
+import java.util.logging.Logger;
+
+import sun.rmi.transport.proxy.RMIHttpToCGISocketFactory;
+
+public class RemoteCalculatorClient {
+
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public static void main(String[] args) {
+
+ System.setProperty("http.proxyHost","10.100.2.1");
+ System.setProperty("http.proxyPort","3128");
+ System.setProperty("sun.rmi.transport.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.readTimeout", "1000");
+
+ try {
+ RMISocketFactory.setSocketFactory(new RMIHttpToCGISocketFactory());
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ String addr = "10.100.2.246";
+
+ Calculator remoteCalc = null;
+ Registry remoteRegistry = null;
+
+ try {
+ logger.info("RemoteCalculatorClient locating RMI registry on remote host \""+ addr + "\".");
+ remoteRegistry = LocateRegistry.getRegistry(addr);
+
+ logger.info("RemoteCalculatorClient looking up service \""+ RemoteCalculator.SERVICENAME + "\".");
+ remoteCalc = (Calculator) remoteRegistry.lookup(RemoteCalculator.SERVICENAME);
+
+ int[][] a = new int[][] {{9,2},{6,4}};
+ int[][] b = new int[][] {{1,4},{1,5}};
+
+ remoteCalc.setMatrixA(a);
+ remoteCalc.setMatrixB(b);
+
+ System.out.println("Matrix A");
+ System.out.println(Arrays.toString(a[0]));
+ System.out.println(Arrays.toString(a[1]));
+ System.out.println();
+
+ System.out.println("Matrix B");
+ System.out.println(Arrays.toString(b[0]));
+ System.out.println(Arrays.toString(b[1]));
+ System.out.println();
+
+ System.out.println("Result Matrix (multiply)");
+ System.out.println(Arrays.toString(remoteCalc.multiplyMatrixAB()[0]));
+ System.out.println(Arrays.toString(remoteCalc.multiplyMatrixAB()[1]));
+ System.out.println();
+
+ System.out.println("Result Matrix (add)");
+ System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[0]));
+ System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[1]));
+ System.out.println();
+
+
+ System.out.println("Vector");
+ Vector v = new Vector(4);
+ v.add(new Double(50.21));
+ v.add(new Double(2000.125));
+ v.add(new Double(196.15));
+ v.add(new Double(36.95));
+
+ remoteCalc.setVectorA(v);
+
+ System.out.println(v.toString());
+ System.out.println();
+
+ System.out.println("Standard Deviation: "+remoteCalc.getDevProm()[0]);
+ System.out.println("Average: "+remoteCalc.getDevProm()[1]);
+
+ } catch (Exception e) {
+ logger.info("RemoteCalculatorClient problem with RemoteCalculator, exception:\n "+ e);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClient.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClientBI.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClientBI.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClientBI.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClientBI.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
+import java.util.Arrays;
+import java.util.Vector;
+import java.util.logging.Logger;
+
+public class RemoteCalculatorClientBI {
+
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public static void main(String[] args) {
+
+
+ System.setProperty("sun.rmi.transport.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE");
+
+ try {
+ RMISocketFactory.setSocketFactory(new CipherRMISocketFactory());
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ System.exit(1);
+ }
+
+ String addr = "localhost"; //"10.100.2.229";
+
+ CalculatorBI remoteCalc = null;
+ Registry remoteRegistry = null;
+
+ try {
+ logger
+ .info("RemoteCalculatorClient locating RMI registry on remote host \""
+ + addr + "\".");
+ remoteRegistry = LocateRegistry.getRegistry(addr);
+
+ logger.info("RemoteCalculatorClient looking up service \""
+ + RemoteCalculatorBI.SERVICENAME + "\".");
+ remoteCalc = (CalculatorBI) remoteRegistry
+ .lookup(RemoteCalculatorBI.SERVICENAME);
+
+ BigInteger[][] a = new BigInteger[2][2];
+ a[0][0] = new BigInteger("9");
+ a[0][1] = new BigInteger("2");
+ a[1][0] = new BigInteger("6");
+ a[1][1] = new BigInteger("4");
+
+ BigInteger[][] b = new BigInteger[2][2];
+ b[0][0] = new BigInteger("1");
+ b[0][1] = new BigInteger("4");
+ b[1][0] = new BigInteger("1");
+ b[1][1] = new BigInteger("5");
+
+ remoteCalc.setMatrixA(a);
+ remoteCalc.setMatrixB(b);
+
+ System.out.println("Matrix A");
+ System.out.println(Arrays.toString(a[0]));
+ System.out.println(Arrays.toString(a[1]));
+ System.out.println();
+
+ System.out.println("Matrix B");
+ System.out.println(Arrays.toString(b[0]));
+ System.out.println(Arrays.toString(b[1]));
+ System.out.println();
+
+ System.out.println("Result Matrix (multiply)");
+ System.out.println(Arrays
+ .toString(remoteCalc.multiplyMatrixAB()[0]));
+ System.out.println(Arrays
+ .toString(remoteCalc.multiplyMatrixAB()[1]));
+ System.out.println();
+
+ System.out.println("Result Matrix (add)");
+ System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[0]));
+ System.out.println(Arrays.toString(remoteCalc.sumMatrixAB()[1]));
+ System.out.println();
+
+ System.out.println("Vector");
+ Vector v = new Vector(4);
+ v.add(new Double(50.21));
+ v.add(new Double(2000.125));
+ v.add(new Double(196.15));
+ v.add(new Double(36.95));
+
+ remoteCalc.setVectorA(v);
+
+ System.out.println(v.toString());
+ System.out.println();
+
+ System.out.println("Standard Deviation: "
+ + remoteCalc.getDevProm()[0]);
+ System.out.println("Average: " + remoteCalc.getDevProm()[1]);
+
+ } catch (Exception e) {
+ logger
+ .info("RemoteCalculatorClient problem with RemoteCalculator, exception:\n "
+ + e);
+ e.printStackTrace();
+
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorClientBI.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServer.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServer.java Tue May 16 06:51:00 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.logging.Logger;
+
+public class RemoteCalculatorServer {
+
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public static void main(String[] args) {
+
+ System.setProperty("sun.rmi.transport.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE");
+
+ Registry localRegistry = null;
+ try {
+
+ localRegistry = LocateRegistry
+ .createRegistry(Registry.REGISTRY_PORT);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ RemoteCalculator rc = new RemoteCalculator();
+ localRegistry.rebind(RemoteCalculator.SERVICENAME, rc);
+ logger.info("RemoteCalculator Server Ready.");
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ Thread.sleep(3*60*6000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServer.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServerBI.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServerBI.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServerBI.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServerBI.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
+import java.util.logging.Logger;
+
+public class RemoteCalculatorServerBI {
+
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public static void main(String[] args) {
+
+ System.setProperty("sun.rmi.transport.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE");
+
+ try {
+ RMISocketFactory.setSocketFactory(new CipherRMISocketFactory());
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ System.exit(1);
+ }
+
+ Registry localRegistry = null;
+ try {
+
+ localRegistry = LocateRegistry
+ .createRegistry(Registry.REGISTRY_PORT);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ RemoteCalculatorBI rc = new RemoteCalculatorBI();
+ localRegistry.rebind(RemoteCalculatorBI.SERVICENAME, rc);
+ logger.info("RemoteCalculator Server Ready.");
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCalculatorServerBI.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipher.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipher.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipher.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipher.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+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;
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipher.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipherImpl.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipherImpl.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipherImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipherImpl.java Tue May 16 06:51:00 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+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;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteCipherImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashClient.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashClient.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashClient.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashClient.java Tue May 16 06:51:00 2006
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.logging.Logger;
+
+public class RemoteHashClient {
+
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ private static boolean checkPopulatedHashMap(String[] data, String[] key,
+ String addr, RemoteMap remoteMap) {
+ for (int i = 0; i < key.length; i++) {
+ if (!getCall(key[i], addr, remoteMap).equals(data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static String getCall(String pattern, String addr,
+ RemoteMap remoteMap) {
+ String value = null;
+ try {
+ value = (String) remoteMap.get(pattern);
+
+ if (value != null)
+ logger.info("RemoteMapClient found at " + addr + ", value="
+ + value);
+ else
+ logger.info("RemoteMapClient could not find key " + addr + ".");
+
+ } catch (RemoteException e) {
+ logger.info("RemoteMapClient problem with " + addr
+ + ", exception:\n " + e);
+ e.printStackTrace();
+ }
+ return value;
+ }
+
+ public static void main(String[] args) {
+
+ String addr = "10.100.2.229";
+
+ RemoteMap remoteMap = null;
+ Registry remoteRegistry = null;
+
+ String[] numbers = { "one", "two", "three", "four", "five", "six",
+ "seven" };
+
+ String[] data = { "pride", "envy", "gluttony", "lust", "anger",
+ "greed", "sloth" };
+
+ try {
+ System.out
+ .println("RemoteMapClient locating RMI registry on remote host \""
+ + addr + "\".");
+ remoteRegistry = LocateRegistry.getRegistry(addr);
+ logger.info("RemoteMapClient looking up service \""
+ + RemoteMap.SERVICENAME + "\".");
+ remoteMap = (RemoteMap) remoteRegistry
+ .lookup(RemoteMap.SERVICENAME);
+ } catch (Exception e) {
+ System.out
+ .println("RemoteMapClient problem with RemoteMap, exception:\n "
+ + e);
+ }
+
+ if (populateHashMap(data, numbers, addr, remoteMap)) {
+ System.out
+ .println("RemoteMapClient HashMap successfully populated...");
+ }
+
+ // getCall("one",addr,remoteMap);
+ if (data.length == sizeCall(remoteMap)) {
+ logger.info("RemoteMapClient HashMap size correct...");
+ }
+
+ if (checkPopulatedHashMap(data, numbers, addr, remoteMap)) {
+ logger.info("RemoteMapClient HashMap check passed...");
+ }
+ }
+
+ private static boolean populateHashMap(String[] data, String[] key,
+ String addr, RemoteMap remoteMap) {
+ boolean retval = false;
+ for (int i = 0; i < data.length; i++) {
+ System.out.println(data[i]);
+ retval = putCall(key[i], data[i], addr, remoteMap);
+ }
+ return retval;
+ }
+
+ private static boolean putCall(String pattern1, String pattern2,
+ String addr, RemoteMap remoteMap) {
+ try {
+ logger.info("RemoteMapClient inserting on " + addr + " key="
+ + pattern1 + ", value=" + pattern2);
+ remoteMap.put(pattern1, pattern2);
+
+ } catch (RemoteException e) {
+ logger.info("RemoteMapClient problem with " + addr
+ + ", exception:\n " + e);
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ private static int sizeCall(RemoteMap remoteMap) {
+ int retval = -1;
+ try {
+ retval = remoteMap.size();
+ logger.info("RemoteMapClient HashMap size: " + retval);
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ return retval;
+ }
+ return retval;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashClient.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashServer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashServer.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashServer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashServer.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+public class RemoteHashServer {
+
+ private static Logger logger = Logger.getAnonymousLogger();
+
+ public static void main(String[] args) {
+
+ try {
+ System.setProperty("sun.rmi.transport.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.logLevel", "VERBOSE");
+ System.setProperty("sun.rmi.transport.tcp.readTimeout", "1000");
+
+ logger.info("RemoteMapServer creating a local RMI registry on the default port.");
+ Registry localRegistry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT );
+
+ logger
+ .info("RemoteMapServer creating local object and remote adapter.");
+ Hashtable hash = new Hashtable();
+ RemoteMapAdapter adapter = new RemoteMapAdapter(hash);
+
+ logger.info("RemoteMapServer publishing service \""
+ + RemoteMap.SERVICENAME + "\" in local registry.");
+ localRegistry.rebind(RemoteMap.SERVICENAME, adapter);
+
+ logger.info("Published RemoteMap as service \""
+ + RemoteMap.SERVICENAME + "\". Ready.");
+ } catch (RemoteException e) {
+ logger
+ .fine("RemoteMapServer problem with remote object, exception:\n "
+ + e);
+ }
+
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteHashServer.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMap.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMap.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMap.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMap.java Tue May 16 06:51:00 2006
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface RemoteMap extends Remote {
+
+ public static final String SERVICENAME = "RemoteHashMap";
+
+ public int size() throws RemoteException;
+
+ public boolean isEmpty() throws RemoteException;
+
+ public boolean containsKey(Object key) throws RemoteException;
+
+ public boolean containsValue(Object value) throws RemoteException;
+
+ public Object get(Object key) throws RemoteException;
+
+ public Object put(Object key, Object value) throws RemoteException;
+
+ public Object remove(Object key) throws RemoteException;
+
+ public void clear() throws RemoteException;
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMap.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMapAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMapAdapter.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMapAdapter.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMapAdapter.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.
+ */
+/**
+ * @author Hugo Beilis
+ * @author Osvaldo Demo
+ * @author Jorge Rafael
+ * @version 1.0
+ */
+package ar.org.fitc.test.rmi.integration;
+
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Hashtable;
+
+public class RemoteMapAdapter extends UnicastRemoteObject implements RemoteMap {
+
+ private static final long serialVersionUID = 1L;
+
+ private int getCalls = 0;
+
+ protected Hashtable hashMap;
+
+ private int putCalls = 0;
+
+ public RemoteMapAdapter(Hashtable table) throws RemoteException {
+ this.hashMap = table;
+ }
+
+ public synchronized void clear() throws RemoteException {
+ hashMap.clear();
+ }
+
+ public boolean containsKey(Object key) throws RemoteException {
+ return hashMap.containsKey(key);
+ }
+
+ public boolean containsValue(Object value) throws RemoteException {
+ return hashMap.contains(value);
+ }
+
+ public synchronized Object get(Object key) throws RemoteException {
+ getCalls++;
+ printStatus();
+ return hashMap.get(key);
+ }
+
+ public boolean isEmpty() throws RemoteException {
+ return hashMap.isEmpty();
+ }
+
+ private void printStatus() {
+ System.out.println("Internal HashMap Status... Timestamp: "
+ + System.currentTimeMillis());
+ System.out.println("get() called " + getCalls + " time(s)..");
+ System.out.println("put() called " + putCalls + " time(s)");
+ }
+
+ public synchronized Object put(Object key, Object value)
+ throws RemoteException {
+ putCalls++;
+ printStatus();
+ return hashMap.put(key, value);
+ }
+
+ public synchronized Object remove(Object key) throws RemoteException {
+ return hashMap.remove(key);
+ }
+
+ public int size() throws RemoteException {
+ return hashMap.size();
+ }
+}
\ No newline at end of file
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/RemoteMapAdapter.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/ITCRemoteUnicast.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/ITCRemoteUnicast.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/ITCRemoteUnicast.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/ITCRemoteUnicast.java Tue May 16 06:51:00 2006
@@ -0,0 +1,135 @@
+/*
+ * 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.clientExecutor;
+
+import java.io.Serializable;
+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.clientExecutor.executor.ReportIPServer;
+import ar.org.fitc.test.rmi.integration.fase2.clientExecutor.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 UnicastRemoteObject.getClientHost().equals(
+ ReportIPServer.localHost());
+ } catch (ServerNotActiveException e) {
+ // server no work, so i'm in the server.
+ return true;
+ }
+ }
+
+ /**
+ * 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();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/ITCRemoteUnicast.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/Net.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/Net.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/Net.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/Net.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.clientExecutor;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * 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;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/ar/org/fitc/test/rmi/integration/fase2/clientExecutor/Net.java
------------------------------------------------------------------------------
svn:executable = *