com.ibm.websphere.exception

Interface DistributedExceptionEnabled

All known implementing classes:
CommandException, DistributedEJBCreateException, DistributedEJBRemoveException, DistributedException, ExceptionInstantiationException, NotOriginator, NoWorkArea, PropertyFixed, PropertyReadOnly, UnauthorizedAccessException, UnavailableCompensatingCommandException, UnsetInputPropertiesException, WorkAreaException

  1. public interface DistributedExceptionEnabled
Enables an exception to be treated as a distributed exception.. This interface should be used by an exception that is not a subclass of DistributedException.

In addition to implementing the required methods, the implementing class should create an attribute, a DistributedExceptionInfo object, in each constructor, after it has done it's other work. This object will do most of the work for the methods. For all of the examples in the Javadoc of the methods, it is assumed that the name of this attribute is distributedExceptionInfo.

Typically, the implementor of this interface will have multiple constructors. See com.ibm.websphere.DistributedException for examples.

See Also:
com.ibm.websphere.DistributedException, com.ibm.websphere.DistributedExceptionInfo

Method Summary

Modifier and Type Method and Description
  1. java.lang.Throwable
getException(java.lang.String exceptionClassName)
Get a specific exception in a possible chain of exceptions.
  1. DistributedExceptionInfo
getExceptionInfo()
Retrieve the exception info for this exception.
  1. java.lang.String
getMessage()
Retrieve the message for this exception.
  1. java.lang.Throwable
getOriginalException()
Get the original exception in a possible chain of exceptions.
  1. java.lang.Throwable
getPreviousException()
Get the previous exception, in a possible chain of exceptions.
  1. void
printStackTrace()
Print the stack trace for this exception and all chained exceptions.
  1. void
printStackTrace(java.io.PrintWriter pw)
Print the exception execution stack to a print writer.
  1. void
printSuperStackTrace(java.io.PrintWriter pw)
This method is called by DistributedExceptionInfo to retrieve and save the current stack trace.

Method Detail

getException

  1. java.lang.Throwable getException( java.lang.String exceptionClassName)
  2. throws ExceptionInstantiationException
Get a specific exception in a possible chain of exceptions. If there are multiple exceptions in the chain, the most recent one thrown will be returned. If the exception does not exist or no exceptions have been chained, null will be returned.

If the DistributedExceptionInfo attribute is not null, the return value can be retrieved with the following code:

distributedExceptionInfo.getException(exceptionClassName);

Returns:
java.lang.Throwable: The specific exception in a chain of exceptions.
Throws:
ExceptionInstantiationException - An exception occurred while trying to re-create the exception object. If this exception is thrown, the relevant information can be retrieved by using the getExceptionInfo() method followed by recursively using the getPreviousExceptionInfo() method on the DistributedExceptionInfo object.

getExceptionInfo

  1. DistributedExceptionInfo getExceptionInfo( )
Retrieve the exception info for this exception.

This could be coded as:

return distributedExceptionInfo;

Returns:
com.ibm.websphere.exception.DistributedExceptionInfo

getMessage

  1. java.lang.String getMessage()
Retrieve the message for this exception.

The following is an example of the code that should be used:

if (distributedExceptionInfo != null)
return distributedExceptionInfo.getMessage();
else
return null

Note: During the construction of the exception and the DistributedExceptionInfo object, there is one situation that results in a call to this method. Since distributedExceptionInfo is still null, a NullPointerException could occur if the check for null is excluded.

Returns:
java.lang.String

getOriginalException

  1. java.lang.Throwable getOriginalException( )
  2. throws ExceptionInstantiationException
Get the original exception in a possible chain of exceptions. If no previous exceptions have been chained, null will be returned.

If the DistributedExceptionInfo attribute is not null, the return value can be retrieved with the following code:

distributedExceptionInfo.getOriginalException();

Returns:
java.lang.Throwable: The first exception in a chain of exceptions. If no exceptions have been chained, null will be returned.
Throws:
ExceptionInstantiationException - An exception occurred while trying to re-create the exception object. If this exception is thrown, the relevant information can be retrieved by using the getExceptionInfo() method followed by recursively using the getPreviousExceptionInfo() method on the DistributedExceptionInfo object.

getPreviousException

  1. java.lang.Throwable getPreviousException( )
  2. throws ExceptionInstantiationException
Get the previous exception, in a possible chain of exceptions.

If the DistributedExceptionInfo attribute is not null, the return value can be retrieved with the following code:

distributedExceptionInfo.getPreviousException();

Returns:
java.lang.Throwable: The previous exception. If there was no previous exception, null will be returned.
Throws:
ExceptionInstantiationException - An exception occurred while trying to re-create the exception object. If this exception is thrown, the relevant information can be retrieved by using the getExceptionInfo() method.

printStackTrace

  1. void printStackTrace()
Print the stack trace for this exception and all chained exceptions. This will include the stack trace from the location where the exception was created, as well as the stack traces of previous exceptions in the exception chain.

If the DistributedExceptionInfo attribute is not null, the the following code will accomplish this:

distributedExceptionInfo.printStackTrace();


printStackTrace

  1. void printStackTrace(java.io.PrintWriter pw)
Print the exception execution stack to a print writer. This will include the stack trace from the location where the exception was created, as well as the stack traces of previous exceptions in the exception chain.

If the DistributedExceptionInfo attribute is not null, the the following code will accomplish this:

distributedExceptionInfo.printStackTrace(pw);

Parameters:
pw - java.io.PrintWriter

printSuperStackTrace

  1. void printSuperStackTrace(java.io.PrintWriter pw)
This method is called by DistributedExceptionInfo to retrieve and save the current stack trace.

super.printStackTrace(pw)