org.entityfs.error
Class LoggingErrorHandlingStrategy

java.lang.Object
  extended by org.entityfs.error.LoggingErrorHandlingStrategy
All Implemented Interfaces:
ErrorHandlingStrategy

public class LoggingErrorHandlingStrategy
extends Object
implements ErrorHandlingStrategy

This implementation of ErrorHandlingStrategy logs the exceptions and may also rethrow them. (That is configurable.)

Since:
1.0
Author:
Karl Gustafsson

Field Summary
static boolean DEFAULT_RETHROW_EXCEPTIONS
          Are Exception:s rethrown by default? (true )
static boolean DEFAULT_RETHROW_FILE_SYSTEM_EXCEPTIONS
          Are FileSystemException:s rethrown by default? (true )
static boolean DEFAULT_RETHROW_RUNTIME_EXCEPTIONS
          Are RuntimeException:s rethrown by default? (true )
 
Constructor Summary
LoggingErrorHandlingStrategy()
          Default constructor.
LoggingErrorHandlingStrategy(boolean rethrowFileSystemExceptions, boolean rethrowRuntimeExceptions, boolean rethrowExceptions)
          Constructor.
 
Method Summary
 void handleException(Exception e, LogAdapter la)
          Handle an Exception.
 void handleFileSystemException(FileSystemException e, LogAdapter la)
          Handle a FileSystemException.
 void handleRuntimeException(RuntimeException e, LogAdapter la)
          Handle a RuntimeException.
 boolean isRethrowExceptions()
          Does this error handling strategy rethrow Exception:s (wrapped in FileSystemException:s)?
 boolean isRethrowFileSystemExceptions()
          Does this error handling strategy rethrow FileSystemException:s?
 boolean isRethrowRuntimeExceptions()
          Does this error handling strategy rethrow RuntimeException:s?
 void setRethrowExceptions(boolean rethrowExceptions)
          Set to true if the error handling strategy should rethrow Exception:s (wrapped in FileSystemException:s).
 void setRethrowFileSystemExceptions(boolean rethrowFileSystemExceptions)
          Set to true if the error handling strategy should rethrow FileSystemException:s.
 void setRethrowRuntimeExceptions(boolean rethrowRuntimeExceptions)
          Set to true if the error handling strategy should rethrow RuntimeException:s.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RETHROW_FILE_SYSTEM_EXCEPTIONS

public static final boolean DEFAULT_RETHROW_FILE_SYSTEM_EXCEPTIONS
Are FileSystemException:s rethrown by default? (true )

See Also:
Constant Field Values

DEFAULT_RETHROW_RUNTIME_EXCEPTIONS

public static final boolean DEFAULT_RETHROW_RUNTIME_EXCEPTIONS
Are RuntimeException:s rethrown by default? (true )

See Also:
Constant Field Values

DEFAULT_RETHROW_EXCEPTIONS

public static final boolean DEFAULT_RETHROW_EXCEPTIONS
Are Exception:s rethrown by default? (true )

See Also:
Constant Field Values
Constructor Detail

LoggingErrorHandlingStrategy

public LoggingErrorHandlingStrategy()
Default constructor. All properties get their default values.


LoggingErrorHandlingStrategy

public LoggingErrorHandlingStrategy(boolean rethrowFileSystemExceptions,
                                    boolean rethrowRuntimeExceptions,
                                    boolean rethrowExceptions)
Constructor.

Parameters:
rethrowFileSystemExceptions - Should FileSystemException:s be rethrown?
rethrowRuntimeExceptions - Should RuntimeException:s be rethrown?
rethrowExceptions - Should Exception:s be rethrown?
Method Detail

isRethrowFileSystemExceptions

public boolean isRethrowFileSystemExceptions()
Does this error handling strategy rethrow FileSystemException:s?

Returns:
true if FileSystemException:s are rethrown, false otherwise.

setRethrowFileSystemExceptions

public void setRethrowFileSystemExceptions(boolean rethrowFileSystemExceptions)
Set to true if the error handling strategy should rethrow FileSystemException:s.

Parameters:
rethrowFileSystemExceptions - Set to true to let this error handling strategy rethrow FileSystemException:s.

isRethrowRuntimeExceptions

public boolean isRethrowRuntimeExceptions()
Does this error handling strategy rethrow RuntimeException:s?

Returns:
true if RuntimeException:s are rethrown, false otherwise.

setRethrowRuntimeExceptions

public void setRethrowRuntimeExceptions(boolean rethrowRuntimeExceptions)
Set to true if the error handling strategy should rethrow RuntimeException:s.

Parameters:
rethrowRuntimeExceptions - Set to true to let this error handling strategy rethrow RuntimeException:s.

isRethrowExceptions

public boolean isRethrowExceptions()
Does this error handling strategy rethrow Exception:s (wrapped in FileSystemException:s)?

Returns:
true if Exception:s are rethrown, false otherwise.

setRethrowExceptions

public void setRethrowExceptions(boolean rethrowExceptions)
Set to true if the error handling strategy should rethrow Exception:s (wrapped in FileSystemException:s).

Parameters:
rethrowExceptions - Set to true to let this error handling strategy rethrow Exception:s.

handleFileSystemException

public void handleFileSystemException(FileSystemException e,
                                      LogAdapter la)
                               throws FileSystemException
Description copied from interface: ErrorHandlingStrategy
Handle a FileSystemException.

Specified by:
handleFileSystemException in interface ErrorHandlingStrategy
Parameters:
e - The exception.
la - The file system's log adapter.
Throws:
FileSystemException - The implementation may choose to rethrow the handled exception.

handleRuntimeException

public void handleRuntimeException(RuntimeException e,
                                   LogAdapter la)
                            throws RuntimeException
Description copied from interface: ErrorHandlingStrategy
Handle a RuntimeException.

Specified by:
handleRuntimeException in interface ErrorHandlingStrategy
Parameters:
e - The exception.
la - The file system's log adapter.
Throws:
RuntimeException - The implementation may choose to rethrow the handled exception.

handleException

public void handleException(Exception e,
                            LogAdapter la)
                     throws FileSystemException
Description copied from interface: ErrorHandlingStrategy
Handle an Exception. If the exception should be rethrown, wrap it in a FileSystemException.

Specified by:
handleException in interface ErrorHandlingStrategy
Parameters:
e - The exception.
la - The file system's log adapter.
Throws:
FileSystemException - The implementation may choose to rethrow the handled exception wrapped in a FileSystemException.