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

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.logging.SpiLoggerFactory

public final class SpiLoggerFactory
extends Object

Static factory for creating instances of the various spi loggers derived from AbstractLogger. In the most simple case

   RepositoryService loggingService = SpiLoggerFactory.create(service);
 
creates a log wrapper for service which logs all calls to its methods if logging at the debug level is enabled. If logging is not enabled, no log wrapper is created at all and service itself is returned. There is thus virtually no overhead from disabled loggers. Loggers are enabled and disabled via the configuration mechanism of the logging framework which is in place. There are log wrappers for the following SPI entities
SPI entitylog wrapper
RepositoryServiceRepositoryServiceLogger
NameFactoryNameFactoryLogger
PathFactoryPathFactoryLogger
IdFactoryIdFactoryLogger
QValueFactoryQValueFactoryLogger
SessionInfoSessionInfoLogger
BatchBatchLogger
The more general form
   RepositoryService loggingService = SpiLoggerFactory.create(service, logWriterProvider);
 
allows specification of a LogWriterProvider. A LogWriterProvider provides the LogWriters for the individual SPI entities. If the LogWriter does not provide a LogWriter for a certain SPI entity no log wrapper is created for that entity. In the case of Slf4jLogWriterProvider, a LogWriter is only provided if the logger of the implementation class of the respective SPI entity is names after the class and has debug level enabled.


Method Summary
static Batch create(Batch batch, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given batch which logs a calls to its methods if logWriterProvider returns a LogWriter instance for batch.
static IdFactory create(IdFactory idFactory, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given idFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for idFactory.
static NameFactory create(NameFactory nameFactory, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given nameFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for nameFactory.
static PathFactory create(PathFactory pathFactory, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given pathFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for pathFactory.
static QValueFactory create(QValueFactory qValueFactory, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given qValueFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for qValueFactory.
static RepositoryService create(RepositoryService service)
          Shortcut for create(service, new Slf4jLogWriterProvider());
static RepositoryService create(RepositoryService service, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given service which logs a calls to its methods if logWriterProvider returns a LogWriter instance for service.
static SessionInfo create(SessionInfo sessionInfo, LogWriterProvider logWriterProvider)
          Returns a log wrapper for the given sessionInfo which logs a calls to its methods if logWriterProvider returns a LogWriter instance for sessionInfo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static RepositoryService create(RepositoryService service)
Shortcut for
   create(service, new Slf4jLogWriterProvider());
 

Parameters:
service -
Returns:
See Also:
create(RepositoryService, LogWriterProvider)

create

public static RepositoryService create(RepositoryService service,
                                       LogWriterProvider logWriterProvider)
Returns a log wrapper for the given service which logs a calls to its methods if logWriterProvider returns a LogWriter instance for service. Otherwise returns service.

Parameters:
service -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null

create

public static NameFactory create(NameFactory nameFactory,
                                 LogWriterProvider logWriterProvider)
Returns a log wrapper for the given nameFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for nameFactory. Otherwise returns nameFactory.

Parameters:
nameFactory -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null

create

public static PathFactory create(PathFactory pathFactory,
                                 LogWriterProvider logWriterProvider)
Returns a log wrapper for the given pathFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for pathFactory. Otherwise returns pathFactory.

Parameters:
pathFactory -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null

create

public static IdFactory create(IdFactory idFactory,
                               LogWriterProvider logWriterProvider)
Returns a log wrapper for the given idFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for idFactory. Otherwise returns idFactory.

Parameters:
idFactory -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null

create

public static QValueFactory create(QValueFactory qValueFactory,
                                   LogWriterProvider logWriterProvider)
Returns a log wrapper for the given qValueFactory which logs a calls to its methods if logWriterProvider returns a LogWriter instance for qValueFactory. Otherwise returns qValueFactory.

Parameters:
qValueFactory -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null

create

public static SessionInfo create(SessionInfo sessionInfo,
                                 LogWriterProvider logWriterProvider)
Returns a log wrapper for the given sessionInfo which logs a calls to its methods if logWriterProvider returns a LogWriter instance for sessionInfo. Otherwise returns sessionInfo.

Parameters:
sessionInfo -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null

create

public static Batch create(Batch batch,
                           LogWriterProvider logWriterProvider)
Returns a log wrapper for the given batch which logs a calls to its methods if logWriterProvider returns a LogWriter instance for batch. Otherwise returns batch.

Parameters:
batch -
logWriterProvider -
Returns:
Throws:
IllegalArgumentException - if either argument is null


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