Class 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.
Last modified
$Date: 2020-05-19 14:24:30 +0200 (Tue, 19 May 2020) $
  • Field Details

    • specialLoggers

      private final Map<Class<?>,​EntityLogger> specialLoggers
    • defaultLogger

      private final DefaultEntityLogger 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

    • 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:
      • 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 interface ActionFactory<LogManagerFactory>
      context - The current invokation context
      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>
      context - The current invokation context
      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
      entity - The entity to check
      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
      logManager - The log manager used in the current transaction
      entity - The entity to get a logger for
      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
      logControl - A log controller with information about the current transaction
      A log manager object
    • setSpecialLogger

      public void setSpecialLogger​(Class<? extends LoggableData> clazz, EntityLogger logger)
      Register a special logger for entities of the given class.
      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
    • isLoggingDetailedProperties

      public boolean isLoggingDetailedProperties()
      Should individual log entries for each changed property be created or not?
    • isLoggingOldPropertyValues

      public boolean isLoggingOldPropertyValues()
      Should log entries with old property values be created or not?