Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jini.proxy
Class ThrowThis

    java.lang.Object
      java.lang.Throwable
          java.lang.Exception
              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.

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

### printStackTrace

    public void printStackTrace()

  Prints the composite message to `System.err`.

### printStackTrace

    public void printStackTrace(PrintWriter pw)

  Prints the composite message and the embedded stack trace to the specified print writer `pw`

  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`.

  Parameters:
    `ps` - the print stream

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 Sun Microsystems, Inc. All rights reserved