}
/*
* Export the remote object using the underlying exporter.
*/
Remote uproxy = underlyingExporter.export(impl);
used = true;
boolean success = false;
try {
/*
* Choose class loader for proxy's class.
*/
Class uproxyClass = uproxy.getClass();
ClassLoader proxyLoader;
if (loader != null) {
proxyLoader = loader;
} else {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(getClassLoaderPermission);
}
proxyLoader = uproxyClass.getClassLoader();
}
/*
* Get superinterfaces of underlying proxy.
*/
Set interfaceList = new LinkedHashSet();
boolean isConstrainable = uproxy instanceof RemoteMethodControl;
boolean checkPublic =
!Modifier.isPublic(uproxyClass.getModifiers());
getSuperinterfaces(interfaceList, uproxyClass,
isConstrainable, checkPublic);
Class[] proxyInterfaces = (Class[])
interfaceList.toArray(new Class[interfaceList.size()]);
/*
* Create a dynamic proxy with an ActivatableInvocationHandler.
*/
InvocationHandler handler =
new ActivatableInvocationHandler(id, uproxy);
Remote proxy = (Remote)
Proxy.newProxyInstance(proxyLoader,
proxyInterfaces,
handler);
success = true;
return proxy;