package com.jiuqi.mobile.core.service.base;
import java.io.ObjectStreamException;
import java.lang.reflect.Proxy;
import java.rmi.server.RemoteRef;
import java.rmi.server.RemoteStub;
import sun.rmi.server.UnicastRef;
public class DynamicRemoteStub extends RemoteStub
{
// Constructors --------------------------------------------------
/**
*
*/
private static final long serialVersionUID = -2074472290188097386L;
Class cl;
public DynamicRemoteStub(RemoteRef ref)
{
super(ref);
cl = DynamicClassLoader.getCurrentClass();
}
public DynamicRemoteStub()
{
super(new UnicastRef());
cl = DynamicClassLoader.getCurrentClass();
}
// Serializable implementation -----------------------------------
Object readResolve() throws ObjectStreamException
{
if (cl == null)
return this;
DynamicStubHandler stubHandler = new DynamicStubHandler();
Object proxy = Proxy.newProxyInstance(cl.getClassLoader(),
new Class[] { cl },
stubHandler);
stubHandler.setProxy(this);
cl = null;
return proxy;
}
}