public class DbLogManagerFactory extends Object implements LogManagerFactory, ActionFactory<LogManagerFactory>
LoggableData
interface are logged.Modifier and Type | Field and Description |
---|---|
private DefaultEntityLogger |
defaultLogger |
private boolean |
detailedProperties |
private boolean |
oldPropertyValues |
private Map<Class,EntityLogger> |
specialLoggers |
Constructor and Description |
---|
DbLogManagerFactory() |
DbLogManagerFactory(boolean detailedProperties,
boolean oldValues) |
Modifier and Type | Method and Description |
---|---|
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 |
isLoggingDetailedProperties()
Should individual log entries for each changed property be created or not?
|
boolean |
isLoggingOldPropertyValues()
Should log entries with old property values be created 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.
|
private final Map<Class,EntityLogger> specialLoggers
private final DefaultEntityLogger defaultLogger
private final boolean detailedProperties
private final boolean oldPropertyValues
public DbLogManagerFactory()
public DbLogManagerFactory(boolean detailedProperties, boolean oldValues)
public boolean prepareContext(InvokationContext<? super LogManagerFactory> context)
ActionFactory
JspContext
.
prepareContext
in interface ActionFactory<LogManagerFactory>
context
- The current invokation contextpublic LogManagerFactory[] getActions(InvokationContext<? super LogManagerFactory> context)
ActionFactory
getActions
in interface ActionFactory<LogManagerFactory>
context
- The current invokation contextpublic boolean isLoggable(Object entity)
LogManagerFactory
LogManagerFactory.getEntityLogger(LogManager, Object)
mustn't return null if called with the same entity parameter.isLoggable
in interface LogManagerFactory
entity
- The entity to checkLoggableData
public EntityLogger getEntityLogger(LogManager logManager, Object entity)
getEntityLogger
in interface LogManagerFactory
logManager
- The log manager used in the current transactionentity
- The entity to get a logger forLoggableData
public LogManager getLogManager(LogControl logControl)
DbLogManager
.getLogManager
in interface LogManagerFactory
logControl
- A log controller with information about the
current transactionpublic void setSpecialLogger(Class clazz, EntityLogger logger)
clazz
- The class to register a logger for. The class
must implement the LoggableData
interfacelogger
- The logger to use. It must be a thread-safe
implementation since it can be used by multiple threads
at the same timepublic boolean isLoggingDetailedProperties()
public boolean isLoggingOldPropertyValues()