The semi-official way for remote methods on registration objects (e.g
LeaseRenewalSet,
LookupDiscoveryRegistration,
MailboxRegistration) to indicate that the registration no longer exists is to throw
NoSuchObjectException. Unfortunately if the registration object is implemented as a smart proxy that uses RMI to communicate back to the server (instead of a straight RMI object) it is not possible for the server to throw
NoSuchObjectException directly since RMI will wrap such an exception in a
ServerException.
ThrowThis provides a solution to this problem. When the server wants to throw a RemoteException it creates a ThrowThis object that wraps the RemoteException and then throws the ThrowThis. The proxy catches ThrowThis exceptions and in the catch block and calls throwRemoteException to throw the intended exception.
@author Sun Microsystems, Inc.
@see java.rmi.NoSuchObjectException
@see java.rmi.ServerException