isStateful = true;
}
Integer serverID = server.getID();
// Build the handler
AbsInvocationHandler handler = null;
if (isLocalProxy) {
// local handler
handler = new LocalCallInvocationHandler(serverID, containerID, factoryName, isStateful);
} else {
// remote handler
handler = new ClientRPCInvocationHandler(containerID, factoryName, isStateful);
try {
((ClientRPCInvocationHandler) handler).setRMIEnv(new InitialContext().getEnvironment());
} catch (NamingException e) {
throw new IllegalArgumentException("Unable to get environment", e);
}
}
// handler used for getBusinessObject() method
handler.setBusinessObjectMode(true);
// Load the interface with the classloader of the thread
// Get current classloader
ClassLoader classLoader = interfaceClass.getClassLoader();
// set the interface class
handler.setInterfaceClass(interfaceClass);
// return the proxy
return (T) Proxy.newProxyInstance(classLoader, new Class[] {interfaceClass}, handler);
}