GigaSpaces XAP 10.0.1 API

com.sun.jini.proxy
Class ThrowThis

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.sun.jini.proxy.ThrowThis
All Implemented Interfaces:
Serializable

public class ThrowThis
extends Exception

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 Also:
NoSuchObjectException, ServerException, Serialized Form

Constructor Summary
ThrowThis(RemoteException toThrow)
          Simple constructor
ThrowThis(RemoteException toThrow, String message)
          Simple constructor.
 
Method Summary
 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
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThrowThis

public ThrowThis(RemoteException toThrow)
Simple constructor

Parameters:
toThrow - RemoteException you proxy to throw

ThrowThis

public ThrowThis(RemoteException toThrow,
                 String message)
Simple constructor. Note that, in general, objects of this class are just a detail of the private protocol between the proxy and its server, and are not intended to leak out of a public api.

Parameters:
toThrow - RemoteException you proxy to throw
message - Message to construct super object with
Method Detail

throwRemoteException

public void throwRemoteException()
                          throws RemoteException
Throw the RemoteException the server wants thrown

Throws:
RemoteException

getMessage

public String getMessage()
Returns the detail message, including the message from the nested exception the server wants thrown

Overrides:
getMessage in class Throwable

printStackTrace

public void printStackTrace()
Prints the composite message to System.err.

Overrides:
printStackTrace in class Throwable

printStackTrace

public void printStackTrace(PrintWriter pw)
Prints the composite message and the embedded stack trace to the specified print writer pw

Overrides:
printStackTrace in class Throwable
Parameters:
pw - the print writer

printStackTrace

public void printStackTrace(PrintStream ps)
Prints the composite message and the embedded stack trace to the specified stream ps.

Overrides:
printStackTrace in class Throwable
Parameters:
ps - the print stream

GigaSpaces XAP 10.0.1 API

Copyright © GigaSpaces.