Class Sabi

java.lang.Object
com.github.sttk.sabi.Sabi

public final class Sabi extends Object
Utility class for managing and setting up global DataSrc instances.

Applications can register global data sources using uses(String, DataSrc) during startup, and then call setup() or setup(String...) to set them up. The returned AutoCloseable handles shutting down and closing global data sources when the application terminates or finishes using them.

  • Method Details

    • uses

      public static void uses(String name, DataSrc ds)
      Registers a global data source with the specified logical name.
      Parameters:
      name - the logical name for the global data source
      ds - the DataSrc instance to register
    • setup

      public static AutoCloseable setup() throws com.github.sttk.errs.Err
      Sets up all registered global data sources in their registration order.
      Returns:
      an AutoCloseable that closes all initialized global data sources when closed
      Throws:
      com.github.sttk.errs.Err - if setting up any global data source fails
    • setup

      public static AutoCloseable setup(String... names) throws com.github.sttk.errs.Err
      Sets up registered global data sources matching the specified names in the given order.
      Parameters:
      names - varargs array of global data source names to set up
      Returns:
      an AutoCloseable that closes the set-up global data sources when closed
      Throws:
      com.github.sttk.errs.Err - if setting up any of the specified global data sources fails
    • setup

      public static AutoCloseable setup(List<String> names) throws com.github.sttk.errs.Err
      Sets up registered global data sources matching the specified list of names in the given order.
      Parameters:
      names - list of global data source names to set up
      Returns:
      an AutoCloseable that closes the set-up global data sources when closed
      Throws:
      com.github.sttk.errs.Err - if setting up any of the specified global data sources fails