com.amazon.carbonado.spi
Class ExceptionTransformer

java.lang.Object
  extended by com.amazon.carbonado.spi.ExceptionTransformer

public class ExceptionTransformer
extends Object

Supports transforming arbitrary exceptions into appropriate repository exceptions. Repositories will likely extend this class, providing custom transformation rules.

Author:
Brian S O'Neill

Constructor Summary
ExceptionTransformer()
           
 
Method Summary
static ExceptionTransformer getInstance()
          Returns a generic instance.
 FetchException toFetchException(Throwable e)
          Transforms the given throwable into an appropriate fetch exception.
 PersistException toPersistException(Throwable e)
          Transforms the given throwable into an appropriate persist exception.
 RepositoryException toRepositoryException(Throwable e)
          Transforms the given throwable into an appropriate repository exception.
protected  FetchException transformIntoFetchException(Throwable e)
          Override to support custom transformations, returning null if none is applicable.
protected  PersistException transformIntoPersistException(Throwable e)
          Override to support custom transformations, returning null if none is applicable.
protected  RepositoryException transformIntoRepositoryException(Throwable e)
          Override to support custom transformations, returning null if none is applicable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionTransformer

public ExceptionTransformer()
Method Detail

getInstance

public static ExceptionTransformer getInstance()
Returns a generic instance.


toFetchException

public FetchException toFetchException(Throwable e)
Transforms the given throwable into an appropriate fetch exception. If it already is a fetch exception, it is simply casted.

Parameters:
e - required exception to transform
Returns:
FetchException, never null

toPersistException

public PersistException toPersistException(Throwable e)
Transforms the given throwable into an appropriate persist exception. If it already is a persist exception, it is simply casted.

Parameters:
e - required exception to transform
Returns:
PersistException, never null

toRepositoryException

public RepositoryException toRepositoryException(Throwable e)
Transforms the given throwable into an appropriate repository exception. If it already is a repository exception, it is simply casted.

Parameters:
e - required exception to transform
Returns:
RepositoryException, never null

transformIntoFetchException

protected FetchException transformIntoFetchException(Throwable e)
Override to support custom transformations, returning null if none is applicable. Be sure to call super first. If it returns non-null, return that result.

Parameters:
e - required exception to transform
Returns:
FetchException, or null if no applicable transform

transformIntoPersistException

protected PersistException transformIntoPersistException(Throwable e)
Override to support custom transformations, returning null if none is applicable. Be sure to call super first. If it returns non-null, return that result.

Parameters:
e - required exception to transform
Returns:
PersistException, or null if no applicable transform

transformIntoRepositoryException

protected RepositoryException transformIntoRepositoryException(Throwable e)
Override to support custom transformations, returning null if none is applicable. Be sure to call super first. If it returns non-null, return that result.

Parameters:
e - required exception to transform
Returns:
RepositoryException, or null if no applicable transform


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.