Class BackendConfiguration

java.lang.Object
org.tentackle.session.AbstractSessionConfiguration
org.tentackle.session.BackendConfiguration
All Implemented Interfaces:
ScopeConfigurator, Validateable

public class BackendConfiguration extends AbstractSessionConfiguration
Configuration for a database backend.
The configuration is stored via the standard Preferences and provides the parameters necessary to connect to the database backend.
The config refers to a DriverConfiguration that loads the corresponding driver.

Whether username and password are optional depends on the use case. If the configuration is used by a standard DesktopApplication (see fx-rdc module), the user/password is mandatory for local sessions (with driver) and optional for remote sessions (without driver).
Other application types may enforce their own rules.

Notice that the implementation does not depend on the tentackle-database or tentackle-sql module!

Passwords are stored encrypted if a Cryptor is configured for the application.

  • Constructor Details

    • BackendConfiguration

      public BackendConfiguration(String application, String name, String url, String options, DriverConfiguration driver, String user, String password)
      Creates a backend configuration.
      Parameters:
      application - the application name
      name - the symbolic backend name
      url - the host- or service url
      driver - the symbolic driver name, see DriverConfiguration, null or empty if remote
      user - the optional username, null or empty if none
      password - the optional password, null or empty if none
  • Method Details

    • getBackendConfigurations

      public static Map<String,BackendConfiguration> getBackendConfigurations(String application, boolean system)
      Loads all backend configurations for a given application.
      Parameters:
      application - the application name
      system - true if load from system preferences, else user preferences
      Returns:
      the backend configurations
    • removeBackendConfigurations

      public static void removeBackendConfigurations(String application, boolean system)
      Removes all backend configurations for given application.
      Parameters:
      application - the application name
      system - true if load from system preferences, else user preferences
    • setDefault

      public static void setDefault(BackendConfiguration backend, String application, boolean system)
      Sets the default backend configuration.
      Parameters:
      backend - the configuration, null to clear
      application - the application name
      system - true if save to system preferences, else user preferences
    • getDefault

      public static BackendConfiguration getDefault(String application, boolean system)
      Gets the default backend configuration.
      Parameters:
      application - the application name
      system - true if load from system preferences, else user preferences
      Returns:
      the configuration, null if no default
    • getApplication

      @Bindable @NotNull public String getApplication()
      Gets the application name.
      Returns:
      the application name
    • setApplication

      @Bindable public void setApplication(String application)
      Sets the application name.
      Parameters:
      application - the application name
    • getUrl

      @Bindable @NotNull public String getUrl()
      Gets the host- or service url.
      Returns:
      the url
    • setUrl

      @Bindable public void setUrl(String url)
      Sets the host- or service url.
      Parameters:
      url - the url
    • getOptions

      @Bindable public String getOptions()
      Gets other options.
      Each option goes into a separate line.
      Returns:
      the options
    • setOptions

      @Bindable public void setOptions(String options)
      Sets the options.
      Parameters:
      options - the options, null if none
    • getDriver

      @Bindable public DriverConfiguration getDriver()
      Gets the driver configuration.
      Returns:
      the driver, null if remote or from classpath
    • setDriver

      @Bindable public void setDriver(DriverConfiguration driver)
      Sets the driver configuration.
      Parameters:
      driver - the driver, null if remote or from classpath
    • getUser

      @Bindable public String getUser()
      Gets the optional username.
      Returns:
      the username
    • setUser

      @Bindable public void setUser(String user)
      Gets the username.
      Parameters:
      user - the username
    • getPassword

      @Bindable public String getPassword()
      Gets the optional password.
      Returns:
      the password
    • setPassword

      @Bindable public void setPassword(String password)
      Sets the password.
      Parameters:
      password - the password
    • persist

      public void persist(boolean system)
      Persists this configuration.
      Parameters:
      system - true if store in system preferences (requires extra permission), else user preferences
    • remove

      public void remove(boolean system)
      Removes this configuration.
      Parameters:
      system - true if store in system preferences (requires extra permission), else user preferences
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object