com.bea.wli.config.component
Class WrappedThrowable

java.lang.Object
  extended by com.bea.wli.config.component.WrappedThrowable
All Implemented Interfaces:
Serializable

public class WrappedThrowable
extends Object
implements Serializable

Wraps an exception that was thrown on the server so that information about the exception can be obtained by any client without having to worry about whether the original exception is in the classpath of the caller. This is required if an exception thrown on the server is not necessarily on clients classpath. Such Throwables are wrapped by serializing them into a byte array so that they can be selectively deserialized on the client. If the deserialization of the original exception fails the client can ask for a simpler representation of the original exception that is guaranteed to be on clients classpath. This simple representation has stack trace and exception message of the original throwable.

This exception is also useful if the Exception is not serializable on the server as well. This happens if the implementation of the exception does not obey the contract of the Serializable interface and contains a non-serializable element.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Constructor Summary
WrappedThrowable(Throwable wrappedThrowable)
          Constructor for wrapping a throwable.
 
Method Summary
static Throwable computeSimpleForm(Throwable t)
           
 Throwable getOriginalForm()
          Returns the original (wrapped) throwable.
 String getOriginalThrowableClassName()
          Returns the class name of the wrapped Throwable.
 Throwable getSimpleForm()
          Returns a simple representation of the original throwable.
 Throwable getThrowable()
          Returns the original exception if it can be deserialized without errors and if it is not null.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

WrappedThrowable

public WrappedThrowable(Throwable wrappedThrowable)
Constructor for wrapping a throwable.

Parameters:
wrappedThrowable - the throwable to be wrapped
Method Detail

computeSimpleForm

public static final Throwable computeSimpleForm(Throwable t)

getOriginalThrowableClassName

public String getOriginalThrowableClassName()
Returns the class name of the wrapped Throwable. This method can be used to verify if the original throwable is in the classpath of the caller, before calling getOriginalForm()

Returns:

getOriginalForm

public Throwable getOriginalForm()
                          throws IOException,
                                 ClassNotFoundException
Returns the original (wrapped) throwable. This method should be called only if the class of the wrapped throwable is known to be in the classpath of the caller. The caller should typically call getSimpleForm() to get the alternative simpler representation of this class if the original form could not be obtained due to an exception

Returns:
the original wrapped throwable. Returns null if the original Throwable could not be serialized due to some serialization error.
Throws:
IOException
ClassNotFoundException

getSimpleForm

public Throwable getSimpleForm()
Returns a simple representation of the original throwable. This method should be used if the call to getOriginalForm() has failed because the class of the original Throwable was not on callers classpath.

Returns:
a simple representation of the original throwable.

getThrowable

public Throwable getThrowable()
Returns the original exception if it can be deserialized without errors and if it is not null. Otherwise returns the simple form.