2.17.2: 2011-06-17

net.sf.basedb.core.log.db
Class DbLogManagerFactory

java.lang.Object
  extended by net.sf.basedb.core.log.db.DbLogManagerFactory
All Implemented Interfaces:
LogManagerFactory

public class DbLogManagerFactory
extends Object
implements LogManagerFactory

Log manager factory implementationt that logs changes to the database. Only items that has been tagged with the LoggableData interface are logged.

Version:
2.13
Author:
Nicklas
Last modified
$Date: 2009-08-20 09:14:03 +0200 (Thu, 20 Aug 2009) $

Field Summary
private  DefaultEntityLogger defaultLogger
           
private  boolean detailedProperties
           
private  Map<Class,EntityLogger> specialLoggers
           
 
Constructor Summary
DbLogManagerFactory()
           
 
Method Summary
 EntityLogger getEntityLogger(LogManager logManager, Object entity)
          If a special logger has been registered for the class of the given entity, use that logger, otherwise use the default logger.
 LogManager getLogManager(LogControl logControl)
          Creates a new DbLogManager.
 boolean isLoggable(Object entity)
          Checks if changes to the given entity should be logged or not.
 void setSpecialLogger(Class clazz, EntityLogger logger)
          Register a special logger for entities of the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

specialLoggers

private final Map<Class,EntityLogger> specialLoggers

defaultLogger

private final DefaultEntityLogger defaultLogger

detailedProperties

private final boolean detailedProperties
Constructor Detail

DbLogManagerFactory

public DbLogManagerFactory()
Method Detail

isLoggable

public boolean isLoggable(Object entity)
Description copied from interface: LogManagerFactory
Checks if changes to the given entity should be logged or not. If this method returns true, then LogManagerFactory.getEntityLogger(LogManager, Object) mustn't return null if called with the same entity parameter.

Specified by:
isLoggable in interface LogManagerFactory
Parameters:
entity - The entity to check
Returns:
TRUE if the entity implements the LoggableData

getEntityLogger

public EntityLogger getEntityLogger(LogManager logManager,
                                    Object entity)
If a special logger has been registered for the class of the given entity, use that logger, otherwise use the default logger.

Specified by:
getEntityLogger in interface LogManagerFactory
Parameters:
logManager - The log manager used in the current transaction
entity - The entity to get a logger for
Returns:
An EntityLogger or null if the entity isn't implementing LoggableData

getLogManager

public LogManager getLogManager(LogControl logControl)
Creates a new DbLogManager.

Specified by:
getLogManager in interface LogManagerFactory
Parameters:
logControl - A log controller with information about the current transaction
Returns:
A log manager object

setSpecialLogger

public void setSpecialLogger(Class clazz,
                             EntityLogger logger)
Register a special logger for entities of the given class.

Parameters:
clazz - The class to register a logger for. The class must implement the LoggableData interface
logger - The logger to use. It must be a thread-safe implementation since it can be used by multiple threads at the same time

2.17.2: 2011-06-17