java.lang.Object
org.apache.juneau.Context
org.apache.juneau.config.store.ConfigStore
org.apache.juneau.examples.core.config.store.SqlStore
All Implemented Interfaces:
Closeable, AutoCloseable, AnnotationProvider

public class SqlStore extends ConfigStore
Example of a ConfigStore that uses a relational database as a backend.

This class provides a basic framework but requires implementing the following methods:

See Also:
  • Constructor Details

    • SqlStore

      protected SqlStore(SqlStore.Builder builder)
      Constructor.
      Parameters:
      builder - The builder for this object.
  • Method Details

    • create

      public static SqlStore.Builder create()
      Instantiates a builder for this object.
      Returns:
      A new builder for this object.
    • getDatabaseValue

      protected String getDatabaseValue(String name)
    • exists

      public boolean exists(String name)
      Description copied from class: ConfigStore
      Checks whether the configuration with the specified name exists in this store.
      Specified by:
      exists in class ConfigStore
      Parameters:
      name - The config name.
      Returns:
      true if the configuration with the specified name exists in this store.
    • read

      public String read(String name)
      Description copied from class: ConfigStore
      Returns the contents of the configuration file.
      Specified by:
      read in class ConfigStore
      Parameters:
      name - The config file name.
      Returns:
      The contents of the configuration file.
      A blank string if the config does not exist.
      Never null.
    • write

      public String write(String name, String expectedContents, String newContents)
      Description copied from class: ConfigStore
      Saves the contents of the configuration file if the underlying storage hasn't been modified.
      Specified by:
      write in class ConfigStore
      Parameters:
      name - The config file name.
      expectedContents - The expected contents of the file.
      newContents - The new contents.
      Returns:
      If null, then we successfully stored the contents of the file.
      Otherwise the contents of the file have changed and we return the new contents of the file.
    • update

      public SqlStore update(String name, String newContents)
      Description copied from class: ConfigStore
      Called when the physical contents of a config file have changed.

      Triggers calls to ConfigStoreListener.onChange(String) on all registered listeners.

      Overrides:
      update in class ConfigStore
      Parameters:
      name - The config name (e.g. the filename without the extension).
      newContents - The new contents.
      Returns:
      This object.
    • close

      public void close()