3.2.4: 2013-12-06

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

java.lang.Object
  extended by net.sf.basedb.core.log.db.DbLogManagerFactory
All Implemented Interfaces:
LogManagerFactory, Action, ActionFactory<LogManagerFactory>

public class DbLogManagerFactory
extends Object
implements LogManagerFactory, ActionFactory<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: 2012-08-06 15:20:43 +0200 (Mon, 06 Aug 2012) $

Field Summary
private  DefaultEntityLogger defaultLogger
           
private  boolean detailedProperties
           
private  Map<Class,EntityLogger> specialLoggers
           
 
Constructor Summary
DbLogManagerFactory()
           
 
Method Summary
 LogManagerFactory[] getActions(InvokationContext<? super LogManagerFactory> context)
          This method may be called one or several times for each request.
 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.
 boolean prepareContext(InvokationContext<? super LogManagerFactory> context)
          This method is called once for each request/use of an extension and have two purposes: The factory should decide if the extension should be enabled 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

prepareContext

public boolean prepareContext(InvokationContext<? super LogManagerFactory> context)
Description copied from interface: ActionFactory
This method is called once for each request/use of an extension and have two purposes:

Specified by:
prepareContext in interface ActionFactory<LogManagerFactory>
Parameters:
context - The current invokation context
Returns:
TRUE if the extension should be enabled, FALSE if the extension should be disabled

getActions

public LogManagerFactory[] getActions(InvokationContext<? super LogManagerFactory> context)
Description copied from interface: ActionFactory
This method may be called one or several times for each request. This is decided by the extension point. If, for example, the extension point is a pure single-item extension point then this method is probably only called once. If the extension point is a per-item extension point in a list context, then this method may be called once for every item in the list. The context parameter contains all information about the context of the extension point, including the current item, if any.

Specified by:
getActions in interface ActionFactory<LogManagerFactory>
Parameters:
context - The current invokation context
Returns:
An array of actions that should be added to the extension point. Returns null or an empty array if there are no actions in the current context.

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

3.2.4: 2013-12-06