org.apache.jackrabbit.spi.commons.logging
Class AbstractLogger

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.logging.AbstractLogger
Direct Known Subclasses:
BatchLogger, IdFactoryLogger, NameFactoryLogger, PathFactoryLogger, QValueFactoryLogger, RepositoryServiceLogger, SessionInfoLogger

public class AbstractLogger
extends Object

Common base class for all log wrappers of SPI entities.


Nested Class Summary
protected static interface AbstractLogger.Callable
          Type of thunk used in {@link AbstractLogger#execute(Callable, String, Object[])
protected static interface AbstractLogger.SafeCallable
          Type of thunk used in {@link AbstractLogger#execute(SafeCallable, String, Object[])
 
Field Summary
protected  LogWriter writer
          The LogWriter used by this instance for persisting log messages.
 
Constructor Summary
AbstractLogger(LogWriter writer)
          Create a new instance of this log wrapper which uses writer for persisting log messages.
 
Method Summary
protected  Object execute(AbstractLogger.Callable thunk, String methodName, Object[] args)
          Execute a thunk of a method which might throw a RepositoryException.
protected  Object execute(AbstractLogger.SafeCallable thunk, String methodName, Object[] args)
          Execute a thunk of a method which does not throw any checked exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected final LogWriter writer
The LogWriter used by this instance for persisting log messages.

Constructor Detail

AbstractLogger

public AbstractLogger(LogWriter writer)
Create a new instance of this log wrapper which uses writer for persisting log messages.

Parameters:
writer -
Method Detail

execute

protected Object execute(AbstractLogger.Callable thunk,
                         String methodName,
                         Object[] args)
                  throws RepositoryException
Execute a thunk of a method which might throw a RepositoryException. The call is logged to writer right before it is actually performed and after it returns. Any exception thrown by the call is logged before it is re-thrown.

Parameters:
thunk - thunk of the method to execute
methodName - the name of the method
args - the arguments passed to the method
Returns:
the value returned from executing the thunk
Throws:
RepositoryException - if executing the thunk throws an Exception the exception is re-thrown.

execute

protected Object execute(AbstractLogger.SafeCallable thunk,
                         String methodName,
                         Object[] args)
Execute a thunk of a method which does not throw any checked exception. The call is logged to writer right before it is actually performed and after it returns.

Parameters:
thunk - thunk of the method to execute
methodName - the name of the method
args - the arguments passed to the method
Returns:
the value returned from executing the thunk


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.