home *** CD-ROM | disk | FTP | other *** search
- package sun.rmi.server;
-
- import java.rmi.Remote;
- import java.rmi.RemoteException;
- import java.rmi.StubNotFoundException;
- import java.rmi.server.LogStream;
- import java.rmi.server.RemoteRef;
- import java.rmi.server.RemoteStub;
- import java.rmi.server.Skeleton;
- import java.rmi.server.SkeletonNotFoundException;
- import sun.rmi.transport.ObjectTable;
- import sun.rmi.transport.Target;
- import sun.rmi.transport.Utils;
-
- public final class RemoteProxy extends RemoteStub {
- static int logLevel = LogStream.parseLevel(Utils.getProperty("sun.rmi.server.logLevel"));
- private static Class classRemote = null;
-
- private RemoteProxy() {
- }
-
- public static RemoteStub getStub(Remote var0, RemoteRef var1) throws StubNotFoundException {
- Object var2 = null;
-
- try {
- Class var4 = getRemoteClass(var0);
- return getStub(var4.getName(), var4, var1);
- } catch (ClassNotFoundException var3) {
- throw new StubNotFoundException("Object does not implement an interface that extends java.rmi.Remote: " + var0.getClass().getName());
- }
- }
-
- public static RemoteStub getStub(String var0, RemoteRef var1) throws StubNotFoundException {
- return getStub(var0, (Class)null, var1);
- }
-
- public static RemoteStub getStub(String var0, Class var1, RemoteRef var2) throws StubNotFoundException {
- String var3 = var0 + "_Stub";
- Object var4 = null;
-
- try {
- Class var5 = loadClassFromClass(var3, var1);
- var10 = (RemoteStub)var5.newInstance();
- } catch (ClassNotFoundException var6) {
- throw new StubNotFoundException("Class not found: " + var3, var6);
- } catch (InstantiationException var7) {
- throw new StubNotFoundException("Can't create stub: " + var3, var7);
- } catch (IllegalAccessException var8) {
- throw new StubNotFoundException("No public constructor: " + var3, var8);
- } catch (ClassCastException var9) {
- throw new StubNotFoundException("Stub not of correct class: " + var3, var9);
- }
-
- RemoteStub.setRef(var10, var2);
- return var10;
- }
-
- public static RemoteStub getProxy(Remote var0) throws RemoteException {
- RemoteStub var2;
- if (var0 instanceof RemoteStub) {
- var2 = (RemoteStub)var0;
- } else {
- Target var1;
- if ((var1 = ObjectTable.getTarget(var0)) == null) {
- throw new StubNotFoundException("Remote object not exported: " + var0.getClass().getName());
- }
-
- var2 = var1.getStub();
- }
-
- return var2;
- }
-
- public static Skeleton getSkeleton(Remote var0) throws SkeletonNotFoundException {
- Class var1;
- try {
- var1 = getRemoteClass(var0);
- } catch (ClassNotFoundException var8) {
- throw new SkeletonNotFoundException("Object does not implement an interface that extends java.rmi.Remote: " + var0.getClass().getName());
- }
-
- String var2 = var1.getName() + "_Skel";
-
- try {
- Class var3 = loadClassFromClass(var2, var1);
- return (Skeleton)var3.newInstance();
- } catch (ClassNotFoundException var4) {
- throw new SkeletonNotFoundException("Skeleton class not found: " + var2, var4);
- } catch (InstantiationException var5) {
- throw new SkeletonNotFoundException("Can't create skeleton: " + var2, var5);
- } catch (IllegalAccessException var6) {
- throw new SkeletonNotFoundException("No public constructor: " + var2, var6);
- } catch (ClassCastException var7) {
- throw new SkeletonNotFoundException("Skeleton not of correct class: " + var2, var7);
- }
- }
-
- private static Class loadClassFromClass(String var0, Class var1) throws ClassNotFoundException {
- ClassLoader var2 = null;
- if (var1 != null) {
- var2 = var1.getClassLoader();
- }
-
- return var2 != null ? var2.loadClass(var0) : Class.forName(var0);
- }
-
- private static Class getRemoteClass(Remote var0) throws ClassNotFoundException {
- for(Class var1 = var0.getClass(); var1 != null; var1 = var1.getSuperclass()) {
- if (extendsRemote(var1.getInterfaces())) {
- return var1;
- }
- }
-
- throw new ClassNotFoundException("java.rmi.Remote");
- }
-
- private static boolean extendsRemote(Class[] var0) throws ClassNotFoundException {
- if (classRemote == null) {
- classRemote = Class.forName("java.rmi.Remote");
- }
-
- for(int var1 = var0.length - 1; var1 >= 0; --var1) {
- if (var0[var1].equals(classRemote)) {
- return true;
- }
-
- if (extendsRemote(var0[var1].getInterfaces())) {
- return true;
- }
- }
-
- return false;
- }
- }
-