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 [30/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/java/rmi/server/SocketSecurityException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/SocketSecurityException.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/SocketSecurityException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/SocketSecurityException.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. 
+*/
+package java.rmi.server;
+
+/**
+ * @ar.org.fitc.spec_ref
+ * 
+ */
+public class SocketSecurityException extends ExportException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -7622072999407781979L;
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public SocketSecurityException(String s) {
+        super(s);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public SocketSecurityException(String s, Exception ex) {
+        super(s, ex);
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/SocketSecurityException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UID.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UID.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UID.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UID.java Tue May 16 06:51:00 2006
@@ -0,0 +1,134 @@
+/* 
+*  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 java.rmi.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * @ar.org.fitc.spec_ref
+ * 
+ */
+public final class UID implements Serializable {
+
+    private static final long serialVersionUID = 1086053664494604050L;
+
+    private int unique;
+
+    private long time;
+
+    private short count;
+
+    static private long lastTime;
+
+    static private short counter;
+
+    static private int PID; // Unique identifier inside the host
+
+    /*
+     * REVIEW: Impossible to get a unique identifier inside a host from Java.
+     * This solution seems to be the best until now.
+     */
+    static {
+        PID = new Object().hashCode();
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public UID() {
+        unique = PID;
+        synchronized (UID.class) {
+            time = System.currentTimeMillis();
+            if (lastTime == time) {
+                count = ++counter;
+            } else {
+                count = 0;
+                counter = 0;
+            }
+            lastTime = time;
+        }
+    }
+
+    // Contructor for a well-known UID
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public UID(short num) {
+        unique = 0;
+        time = 0;
+        count = num;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    @Override
+	public int hashCode() {
+        return (int) (unique + time + count);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    @Override
+	public boolean equals(Object obj) {
+        if (obj != null && obj instanceof UID) {
+            return (unique == ((UID) obj).unique 
+                    && time == ((UID) obj).time 
+                    && count == ((UID) obj).count);
+        }
+        return false;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    @Override
+	public String toString() {
+        return "[UID:" + unique + ", " + time + ", " + count + "]";
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public void write(DataOutput out) throws IOException {
+        out.writeInt(unique);
+        out.writeLong(time);
+        out.writeShort(count);
+        return;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static UID read(DataInput in) throws IOException {
+        UID tmp = new UID();
+        tmp.unique = in.readInt();
+        tmp.time = in.readLong();
+        tmp.count = in.readShort();
+        return tmp;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UID.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UnicastRemoteObject.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UnicastRemoteObject.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UnicastRemoteObject.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UnicastRemoteObject.java Tue May 16 06:51:00 2006
@@ -0,0 +1,225 @@
+/* 
+*  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 java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+
+import ar.org.fitc.rmi.runtime.RemoteReferenceManager;
+import ar.org.fitc.rmi.server.UnicastRemoteRef2Impl;
+import ar.org.fitc.rmi.server.UnicastRemoteRefImpl;
+import ar.org.fitc.rmi.server.UnicastServerRef2Impl;
+import ar.org.fitc.rmi.server.UnicastServerRefImpl;
+import ar.org.fitc.rmi.transport.Endpoint;
+import ar.org.fitc.rmi.transport.TransportManager;
+
+/**
+ * @ar.org.fitc.spec_ref
+ * 
+ */
+public class UnicastRemoteObject extends RemoteServer {
+
+    private static final long serialVersionUID = 4974527148936298033L;
+
+    private transient int port;
+
+    private transient RMIClientSocketFactory csf;
+
+    private transient RMIServerSocketFactory ssf;
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    protected UnicastRemoteObject() throws RemoteException {
+        this(0);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    protected UnicastRemoteObject(int port) throws RemoteException {
+        this.port = port;
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(this, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
+        this.ref = sref;
+        rrm.storeExportData(this, objID, sref, stub);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    protected UnicastRemoteObject(int port, RMIClientSocketFactory csf,
+            RMIServerSocketFactory ssf) throws RemoteException {
+        this.port = port;
+        this.csf = csf;
+        this.ssf = ssf;
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, ssf, csf);
+        UnicastServerRef2Impl sref = new UnicastServerRef2Impl(this, objID, ep);
+        Remote stub = rrm
+                .createStub(new UnicastRemoteRef2Impl(objID, ep), this);
+        this.ref = sref;
+        rrm.storeExportData(this, objID, sref, stub);
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    @Override
+	public Object clone() throws CloneNotSupportedException {
+        UnicastRemoteObject clon = (UnicastRemoteObject) super.clone();
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        try {
+            Endpoint ep = tm.export(objID, this.port, this.ssf, this.csf);
+            UnicastServerRef2Impl sref = new UnicastServerRef2Impl(clon, objID,
+                    ep);
+            Remote stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep),
+                    clon);
+            clon.ref = sref;
+            rrm.storeExportData(clon, objID, sref, stub);
+        } catch (RemoteException e) {
+            throw new CloneNotSupportedException(
+                    "Error during clon exportation");
+        }
+        return clon;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static RemoteStub exportObject(Remote obj) throws RemoteException {
+        if (obj == null) {
+            throw new RemoteException("Invalid (null) Remote server object.");
+        }
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        if (rrm.isExported(obj)) {
+            throw new RemoteException("Object already exported.");
+        }
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, 0, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(obj, objID, ep);
+        RemoteStub stub = rrm.createRegularStub(new UnicastRemoteRefImpl(objID,
+                ep), obj);
+        rrm.storeExportData(obj, objID, sref, stub);
+        return stub;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static Remote exportObject(Remote obj, int port)
+            throws RemoteException {
+        if (obj == null) {
+            throw new RemoteException("Invalid (null) Remote server object.");
+        }
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        if (rrm.isExported(obj)) {
+            throw new RemoteException("Object already exported.");
+        }
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(obj, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), obj);
+        rrm.storeExportData(obj, objID, sref, stub);
+        return stub;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static Remote exportObject(Remote obj, int port,
+            RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
+            throws RemoteException {
+        if (obj == null) {
+            throw new RemoteException("Invalid (null) Remote server object.");
+        }
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        if (rrm.isExported(obj)) {
+            throw new RemoteException("Object already exported.");
+        }
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, port, ssf, csf);
+        UnicastServerRef2Impl sref = new UnicastServerRef2Impl(obj, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRef2Impl(objID, ep), obj);
+        rrm.storeExportData(obj, objID, sref, stub);
+        return stub;
+    }
+
+    /**
+     * @ar.org.fitc.spec_ref
+     * 
+     */
+    public static boolean unexportObject(Remote obj, boolean force)
+            throws NoSuchObjectException {
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        return rrm.unexportObject(obj, force);
+    }
+
+    /**
+     * 
+     * 
+     */
+    private void writeObject(ObjectOutputStream out) throws IOException {
+        out.defaultWriteObject();
+    }
+
+    /**
+     * 
+     * 
+     */
+    private void readObject(ObjectInputStream in) throws IOException,
+            ClassNotFoundException {
+        in.defaultReadObject();
+        RemoteReferenceManager rrm = RemoteReferenceManager
+                .getRemoteReferenceManager();
+        TransportManager tm = TransportManager.getTransportManager();
+        ObjID objID = new ObjID();
+        Endpoint ep = tm.export(objID, 0, null, null);
+        UnicastServerRefImpl sref = new UnicastServerRefImpl(this, objID, ep);
+        Remote stub = rrm.createStub(new UnicastRemoteRefImpl(objID, ep), this);
+        this.ref = sref;
+        rrm.storeExportData(this, objID, sref, stub);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/UnicastRemoteObject.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/Unreferenced.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/Unreferenced.java?rev=406944&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/Unreferenced.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/Unreferenced.java Tue May 16 06:51:00 2006
@@ -0,0 +1,26 @@
+/* 
+*  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 java.rmi.server;
+
+/**
+ * @ar.org.fitc.spec_ref
+ * 
+ */
+public interface Unreferenced {
+
+    void unreferenced();
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi2/src/java/rmi/server/Unreferenced.java
------------------------------------------------------------------------------
    svn:executable = *