Class IntradayLoggerFactory

java.lang.Object
com.illumon.iris.db.tables.dataimport.IntradayLoggerFactory

public class IntradayLoggerFactory extends Object
The IntradayLoggerFactory generates the loggers and listeners for tables defined in the database schema.

We run this before build time to generate the logger/listener, and then check in the appropriate logger/listener.

At runtime, the logger is regenerated; and its CRC is compared to the CRC of the logger that was loaded from the build. If the CRCs don't match an exception is thrown and the logger is not instantiated.

  • Field Details

  • Constructor Details

    • IntradayLoggerFactory

      public IntradayLoggerFactory(com.fishlib.io.logger.Logger log, @NotNull String copyrightNotice, SchemaService schemaService)
    • IntradayLoggerFactory

      public IntradayLoggerFactory(com.fishlib.io.logger.Logger log, com.fishlib.configuration.Configuration configuration, @NotNull String copyrightNotice, SchemaService schemaService)
    • IntradayLoggerFactory

      public IntradayLoggerFactory()
  • Method Details

    • setJavaGenerationDirectory

      public void setJavaGenerationDirectory(String javaGenerationDirectory)
    • generateTableListener

      public void generateTableListener(SchemaXml schema) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • generateTableListener

      public void generateTableListener(org.jdom2.Element tableElement, String packageName) throws IOException
      Throws:
      IOException
    • getTableListenerPackage

      public static String getTableListenerPackage(String namespace, org.jdom2.Element listenerElement)
      Get the listenerPackage attribute, or fabricate one (from properties) if it is not found.
      Parameters:
      namespace - use this namespace to generate the listenerPackage value if the attribute is not set
      listenerElement - the listener element
      Returns:
      the listener package value
    • getLoggerListenerList

      public static List<LoggerListenerGenerationInfo> getLoggerListenerList(org.jdom2.Element tableElement, boolean relaxedChecking)
      Retrieve the Logger/Listener listener blocks from a table.
      Parameters:
      relaxedChecking - when loading intermediate states; we may want to be more tolerant of certain errors in the XML Document
      ApiNote:
      This function is not part of the stable Illumon API; and is subject to change or removal. User code should never reference getLoggerListenerList.
    • makeDefaultLoggerListener

      public static LoggerListenerGenerationInfo makeDefaultLoggerListener(org.jdom2.Element tableElement)
      Generate as generic logger and listener block from this table element, for use as a default starting point in the schema editor.
      Parameters:
      tableElement - the XML element of the table we are going to generate a default LoggerListener for
      Returns:
      a new LoggerListenerGenerationInfo
      ApiNote:
      This function is not part of the stable Illumon API; and is subject to change or removal. User code should never reference makeDefaultLoggerListener.
    • getLoggerFromTableDefinition

      public static <T extends com.illumon.intradaylogger.IntradayLogger> T getLoggerFromTableDefinition(com.fishlib.io.logger.Logger log, TableDefinition tableDefinition, Class<T> loggerType, boolean generateLogCalls)
      Delegate to getLoggerFromTableDefinition(Logger, TableDefinition, boolean) and then verify the returned value against the given loggerType.
      Parameters:
      log - the Logger instance to log messages during class generation
      tableDefinition - the table definition
      loggerType - the expected class type of the generated logger
      generateLogCalls - if true, generate the log(...) calls, if false then don't generate these calls
      Returns:
      the generated IntradayLogger, cast to type T
    • getLoggerFromTableDefinition

      public static com.illumon.intradaylogger.IntradayLogger getLoggerFromTableDefinition(com.fishlib.io.logger.Logger log, TableDefinition tableDefinition, boolean generateLogCalls)
      Generate the IntradayLogger class from a table definition.
      Parameters:
      log - the Logger instance to log messages during class generation
      tableDefinition - the table definition
      generateLogCalls - if true, generate the log(...) calls, if false then don't generate these calls
      Returns:
      the generated IntradayLogger
    • getListener

      public static TableListener getListener(com.fishlib.io.logger.Logger log, TableDefinition tableDefinition)
      Generate a TableListener class from the given TableDefinition.
      Parameters:
      log - the Logger instance to log messages during class generation
      tableDefinition - the table definition
      Returns:
      the TableListener class
    • getPrecompiledLogger

      @Deprecated public static com.illumon.intradaylogger.IntradayLogger getPrecompiledLogger(SchemaService schemaService, String namespace, String tableName) throws ClassNotFoundException, IllegalAccessException, InstantiationException
      Deprecated.
      Throws:
      ClassNotFoundException
      IllegalAccessException
      InstantiationException
    • getLoggerChecksum

      public long getLoggerChecksum(String namespace, String tableName, String loggerClass)
    • getLoggerChecksum

      public long getLoggerChecksum(String schemaStr, String loggerClass)
    • getLoggerClass

      public static String getLoggerClass(org.jdom2.Element element, String tableName)
      Get the listener class attribute from the listener element, or make up a default one using the tableName.
      Parameters:
      element - the listener element
      tableName - the table name containing the element
      Returns:
      the listenerClass value
    • getListenerClass

      public static String getListenerClass(org.jdom2.Element element, String tableName)
      Get the listener class attribute from the listener element, or make up a default one using the tableName.
      Parameters:
      element - the listener element
      tableName - the table name containing the element
      Returns:
      the listenerClass value
    • getLoggerBody

      public String getLoggerBody(org.jdom2.Element tableElement)
    • getAdoGetter

      public static String getAdoGetter(com.fishlib.dataobjects.WColumn column)
    • getColumnNames

      public static String getColumnNames(LoggerListenerGenerationInfo generationInfo)
    • getInputToTypeMeta

      public static Map<String,Object> getInputToTypeMeta(org.jdom2.Element tableDefinition)
    • generateLogger

      public void generateLogger(SchemaXml schema) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • getModuleName

      public static String getModuleName(String className, String loggerPackage)
    • getModuleName

      public static String getModuleName(String javaGenerationDirectory, String className, String loggerPackage)
    • main

      public static void main(String[] args) throws ClassNotFoundException, IOException
      Throws:
      ClassNotFoundException
      IOException
    • setDefaultService

      public static SchemaService setDefaultService(@Nullable SchemaService service)
    • makeSingleRowTableListener

      public static TableListener makeSingleRowTableListener(@NotNull SchemaXml schema, @NotNull TableDefinition tableDefinition, int applicationVersion)
    • makeSingleRowTableListener

      public static TableListener makeSingleRowTableListener(@NotNull SchemaXml schema, @NotNull TableDefinition tableDefinition, int applicationVersion, @Nullable com.fishlib.io.logger.Logger log)
    • makeBatchedImportRowBufferProcessor

      public static <LISTENER_TYPE extends BatchedImportRowBufferProcessor> LISTENER_TYPE makeBatchedImportRowBufferProcessor(@NotNull SchemaXml schema, @NotNull TableDefinition tableDefinition, int applicationVersion, int rowBatchCapacity, int parallelism)
    • makeBatchedImportRowBufferProcessor

      public static <LISTENER_TYPE extends BatchedImportRowBufferProcessor> LISTENER_TYPE makeBatchedImportRowBufferProcessor(@NotNull SchemaXml schema, @NotNull TableDefinition tableDefinition, int applicationVersion, int rowBatchCapacity, int parallelism, @Nullable com.fishlib.io.logger.Logger log)
    • getCompilerContext

      public static com.illumon.compilertools.CompilerTools.Context getCompilerContext()
      Retrieve the compiler context for logger and listener compilations.
      Returns:
      the compiler context used for compilations.