001: /*
002: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License version
007: * 2 only, as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful, but
010: * WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * General Public License version 2 for more details (a copy is
013: * included at /legal/license.txt).
014: *
015: * You should have received a copy of the GNU General Public License
016: * version 2 along with this work; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018: * 02110-1301 USA
019: *
020: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021: * Clara, CA 95054 or visit www.sun.com if you need additional
022: * information or have any questions.
023: */
024:
025: package com.sun.jumpimpl.ixc;
026:
027: import java.io.Serializable;
028: import java.io.ObjectOutputStream;
029: import java.io.ObjectInputStream;
030: import java.io.IOException;
031: import java.rmi.Remote;
032: import java.util.Arrays;
033: import java.util.HashSet;
034: import java.util.Iterator;
035: import java.util.List;
036: import java.lang.reflect.Method;
037:
038: /*
039: * This is the 'marker' class that gets passed around
040: * between VMs for the method invocation.
041: * Each instance contains information for the original Remote object's
042: * ID (only valid within the exporting VM), the port number
043: * which the exporting VM is listening to with it's
044: * ConnectionReceiver, the exporting xlet's ID, and
045: * information about the original remote object's
046: * remote interfaces and remote methods, which are used
047: * by the importer VM to generate a stub.
048: */
049:
050: public class RemoteRef implements Remote, Serializable {
051:
052: private long objectID;
053: private int portID;
054: private int processID;
055:
056: String[] interfaceNames;
057: long[] methodIDs;
058:
059: public RemoteRef(long objectID, int portID, int processID,
060: String[] remoteInterfaces, long[] methodIDAsLongs) {
061: this .objectID = objectID;
062: this .portID = portID;
063: this .processID = processID;
064:
065: interfaceNames = remoteInterfaces;
066: methodIDs = methodIDAsLongs;
067:
068: //Arrays.sort(methodIDs);
069: //dump();
070: }
071:
072: public long getObjectID() {
073: return objectID;
074: }
075:
076: public int getPortID() {
077: return portID;
078: }
079:
080: public int getXletID() {
081: return processID;
082: }
083:
084: public void dump() {
085: System.out.println("ObjectID = " + objectID);
086: System.out.println("portID = " + portID);
087: System.out.println("ProcessID= " + processID);
088: for (int i = 0; i < interfaceNames.length; i++) {
089: System.out.println(" " + i + ":" + interfaceNames[i]);
090: }
091: System.out
092: .println(" " + methodIDs.length + " remote methods");
093: }
094:
095: public String toString() {
096: StringBuffer buf = new StringBuffer("RemoteRef[ObjectID="
097: + objectID + ",portID=" + portID + ",ProcessID="
098: + processID + ",RemoteInterfaces=<");
099: int i = 0;
100: while (i < interfaceNames.length) {
101: buf.append(interfaceNames[i]);
102: i++;
103: if (i < interfaceNames.length)
104: buf.append(",");
105: }
106: buf.append(">]");
107: return buf.toString();
108: }
109:
110: public boolean equals(Object obj) {
111: if (!(obj instanceof RemoteRef))
112: return false;
113: RemoteRef otherRef = (RemoteRef) obj;
114:
115: if ((objectID != otherRef.objectID)
116: || (portID != otherRef.portID)
117: || (processID != (otherRef.processID)))
118: return false;
119:
120: return true;
121:
122: //List thisClasses = Arrays.asList(interfaceNames);
123: //List otherClasses = Arrays.asList(otherRef.interfaceNames);
124:
125: //return (
126: // (thisClasses.containsAll(otherClasses)) &&
127: // (otherClasses.containsAll(thisClasses)) &&
128: // (Arrays.equals(methodIDs, otherRef.methodIDs))
129:
130: //(objectID == otherRef.objectID) &&
131: //(portID == otherRef.portID) &&
132: //(Arrays.equals(interfaceNames, otherRef.interfaceNames)) &&
133: //(Arrays.equals(methodIDs, otherRef.methodIDs))
134: //);
135: }
136: }
|