public class ThrowThis extends Exception
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.
NoSuchObjectException
,
ServerException
,
Serialized FormConstructor and Description |
---|
ThrowThis(RemoteException toThrow)
Simple constructor
|
ThrowThis(RemoteException toThrow,
String message)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getMessage()
Returns the detail message, including the message from the nested
exception the server wants thrown
|
void |
printStackTrace()
Prints the composite message to
System.err . |
void |
printStackTrace(PrintStream ps)
Prints the composite message and the embedded stack trace to
the specified stream
ps . |
void |
printStackTrace(PrintWriter pw)
Prints the composite message and the embedded stack trace to
the specified print writer
pw |
void |
throwRemoteException()
Throw the
RemoteException the server wants thrown |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
public ThrowThis(RemoteException toThrow)
toThrow
- RemoteException
you proxy to throwpublic ThrowThis(RemoteException toThrow, String message)
toThrow
- RemoteException
you proxy to throwmessage
- Message to construct super object withpublic void throwRemoteException() throws RemoteException
RemoteException
the server wants thrownRemoteException
public String getMessage()
getMessage
in class Throwable
public void printStackTrace()
System.err
.printStackTrace
in class Throwable
public void printStackTrace(PrintWriter pw)
pw
printStackTrace
in class Throwable
pw
- the print writerpublic void printStackTrace(PrintStream ps)
ps
.printStackTrace
in class Throwable
ps
- the print streamCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.