Package net.sf.basedb.core.log.db
Class DbLogManagerFactory
java.lang.Object
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: 2024-05-17 09:48:24 +0200 (Fri, 17 May 2024) $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DefaultEntityLogger
private final boolean
private final boolean
private final Map<Class<?>,
EntityLogger> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetActions
(InvokationContext<? super LogManagerFactory> context) This method may be called one or several times for each request.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.static DbLogManagerFactory
Get the current database log manager factory if database logging is enabled.getLogManager
(LogControl logControl) Creates a newDbLogManager
.boolean
isLoggable
(Object entity) Checks if changes to the given entity should be logged or not.boolean
Should individual log entries for each changed property be created or not?boolean
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<? extends LoggableData> clazz, EntityLogger logger) Register a special logger for entities of the given class.
-
Field Details
-
specialLoggers
-
defaultLogger
-
detailedProperties
private final boolean detailedProperties -
oldPropertyValues
private final boolean oldPropertyValues
-
-
Constructor Details
-
DbLogManagerFactory
public DbLogManagerFactory() -
DbLogManagerFactory
public DbLogManagerFactory(boolean detailedProperties, boolean oldValues)
-
-
Method Details
-
getInstanceIfEnabled
Get the current database log manager factory if database logging is enabled.- Since:
- 3.19.11
-
prepareContext
Description copied from interface:ActionFactory
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. For example, the factory may check the permissions of the logged in user and determine that they are inadequate. The boolean return value determines if the extension is enabled or disabled.
- Initialise the context with resources that the actions may need.
With the BASE web-client this means that it is possible to
add scripts or stylesheets that is needed by the extension.
See
JspContext
.
- Specified by:
prepareContext
in interfaceActionFactory<LogManagerFactory>
- Parameters:
context
- The current invokation context- Returns:
- TRUE if the extension should be enabled, FALSE if the extension should be disabled
-
getActions
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 interfaceActionFactory<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
Description copied from interface:LogManagerFactory
Checks if changes to the given entity should be logged or not. If this method returns true, thenLogManagerFactory.getEntityLogger(LogManager, Object)
mustn't return null if called with the same entity parameter.- Specified by:
isLoggable
in interfaceLogManagerFactory
- Parameters:
entity
- The entity to check- Returns:
- TRUE if the entity implements the
LoggableData
-
getEntityLogger
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 interfaceLogManagerFactory
- Parameters:
logManager
- The log manager used in the current transactionentity
- The entity to get a logger for- Returns:
- An EntityLogger or null if the entity isn't implementing
LoggableData
-
getLogManager
Creates a newDbLogManager
.- Specified by:
getLogManager
in interfaceLogManagerFactory
- Parameters:
logControl
- A log controller with information about the current transaction- Returns:
- A log manager object
-
setSpecialLogger
Register a special logger for entities of the given class.- Parameters:
clazz
- The class to register a logger for. The class must implement theLoggableData
interfacelogger
- The logger to use. It must be a thread-safe implementation since it can be used by multiple threads at the same time
-
isLoggingDetailedProperties
public boolean isLoggingDetailedProperties()Should individual log entries for each changed property be created or not?- Since:
- 3.3
-
isLoggingOldPropertyValues
public boolean isLoggingOldPropertyValues()Should log entries with old property values be created or not?- Since:
- 3.3
-