Class RhythmDatabaseFactoryImpl

java.lang.Object
org.jjazz.rhythmdatabaseimpl.api.RhythmDatabaseFactoryImpl
All Implemented Interfaces:
PropertyChangeListener, EventListener, RhythmDatabaseFactory

public class RhythmDatabaseFactoryImpl extends Object implements RhythmDatabaseFactory, PropertyChangeListener
Create and initialize the RhythmDatabase instance via a cache file.

Upon clean/fresh start:
- copy default rhythm files
- retrieve all available builtin & file-based rhythm instances by polling RhythmProviders (this can be long if many rhythm files need to be scanned).
- update the database
- save the file-based RhythmInfos to a cache file.

Then upon normal start:
- retrieve all available builtin rhythm instances by polling RhythmProviders, create the corresponding RhythmInfos.
- load additional file-based RhythmInfos from the cache file
- create Rhythm instances only when required.

  • Field Details

  • Constructor Details

    • RhythmDatabaseFactoryImpl

      public RhythmDatabaseFactoryImpl()
      Do not use, use getInstance() instead.

      This was made public because of ServiceProvider.

  • Method Details

    • getInstance

      public static RhythmDatabaseFactoryImpl getInstance()
    • initialize

      public Future<?> initialize()
      Description copied from interface: RhythmDatabaseFactory
      Initialize the RhythmDatabase instance.

      As the initialization can take some time (e.g. reading files), the implementation must launch a task in a different thread and return the corresponding Future so that caller can monitor completion.

      Specified by:
      initialize in interface RhythmDatabaseFactory
      Returns:
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: RhythmDatabaseFactory
      Check if the RhythmDatabase instance is initialized.
      Specified by:
      isInitialized in interface RhythmDatabaseFactory
      Returns:
    • get

      public RhythmDatabase get()
      Description copied from interface: RhythmDatabaseFactory
      Get the initialized instance.

      If initialization is not done, call initialize(). If initialization is not complete, wait for its completion.

      Specified by:
      get in interface RhythmDatabaseFactory
      Returns:
    • markForStartupRescan

      public void markForStartupRescan(boolean b)
      Request or cancel a full rescan upon next startup.
      Parameters:
      b -
    • isMarkedForStartupRescan

      public boolean isMarkedForStartupRescan()
      Check if a full rescan s planned for next startup.
      Returns:
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener