- java.lang.Object
-
- org.tentackle.session.AbstractSessionConfiguration
-
- org.tentackle.session.BackendConfiguration
-
- All Implemented Interfaces:
org.tentackle.validate.ScopeConfigurator,org.tentackle.validate.Validateable
public class BackendConfiguration extends AbstractSessionConfiguration
Configuration for a database backend.
The configuration is stored via the standardPreferencesand provides the paramaters necessary to connect to the database backend.
The config refers to aDriverConfigurationthat 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
Cryptoris configured for the application.
-
-
Constructor Summary
Constructors Constructor Description BackendConfiguration(java.lang.String application, java.lang.String name, java.lang.String url, java.lang.String options, DriverConfiguration driver, java.lang.String user, java.lang.String password)Creates a backend configuration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.StringgetApplication()Gets the application name.static java.util.Map<java.lang.String,BackendConfiguration>getBackendConfigurations(java.lang.String application, boolean system)Loads all backend configurations for a given application.static BackendConfigurationgetDefault(java.lang.String application, boolean system)Gets the default backend configuration.DriverConfigurationgetDriver()Gets the driver configuration.java.lang.StringgetOptions()Gets other options.
Each option goes into a separate line.java.lang.StringgetPassword()Gets the optional password.java.lang.StringgetUrl()Gets the host- or service url.java.lang.StringgetUser()Gets the optional username.inthashCode()voidpersist(boolean system)Persists this configuration.voidremove(boolean system)Removes this configuration.static voidremoveBackendConfigurations(java.lang.String application, boolean system)Removes all backend configurations for given application.voidsetApplication(java.lang.String application)Sets the application name.static voidsetDefault(BackendConfiguration backend, java.lang.String application, boolean system)Sets the default backend configuration.voidsetDriver(DriverConfiguration driver)Sets the driver configuration.voidsetOptions(java.lang.String options)Sets the options.voidsetPassword(java.lang.String password)Sets the password.voidsetUrl(java.lang.String url)Sets the host- or service url.voidsetUser(java.lang.String user)Gets the username.-
Methods inherited from class org.tentackle.session.AbstractSessionConfiguration
getDefaultScopes, getName, getPrefNode, isPersisted, setName, setPersisted, toString, validate
-
-
-
-
Constructor Detail
-
BackendConfiguration
public BackendConfiguration(java.lang.String application, java.lang.String name, java.lang.String url, java.lang.String options, DriverConfiguration driver, java.lang.String user, java.lang.String password)Creates a backend configuration.- Parameters:
application- the application namename- the symbolic backend nameurl- the host- or service urldriver- the symbolic driver name, seeDriverConfiguration, null or empty if remoteuser- the optional username, null or empty if nonepassword- the optional password, null or empty if none
-
-
Method Detail
-
getBackendConfigurations
public static java.util.Map<java.lang.String,BackendConfiguration> getBackendConfigurations(java.lang.String application, boolean system)
Loads all backend configurations for a given application.- Parameters:
application- the application namesystem- true if load from system preferences, else user preferences- Returns:
- the backend configurations
-
removeBackendConfigurations
public static void removeBackendConfigurations(java.lang.String application, boolean system)Removes all backend configurations for given application.- Parameters:
application- the application namesystem- true if load from system preferences, else user preferences
-
setDefault
public static void setDefault(BackendConfiguration backend, java.lang.String application, boolean system)
Sets the default backend configuration.- Parameters:
backend- the configuration, null to clearapplication- the application namesystem- true if save to system preferences, else user preferences
-
getDefault
public static BackendConfiguration getDefault(java.lang.String application, boolean system)
Gets the default backend configuration.- Parameters:
application- the application namesystem- true if load from system preferences, else user preferences- Returns:
- the configuration, null if no default
-
getApplication
@Bindable @NotNull public java.lang.String getApplication()
Gets the application name.- Returns:
- the application name
-
setApplication
@Bindable public void setApplication(java.lang.String application)
Sets the application name.- Parameters:
application- the application name
-
getUrl
@Bindable @NotNull public java.lang.String getUrl()
Gets the host- or service url.- Returns:
- the url
-
setUrl
@Bindable public void setUrl(java.lang.String url)
Sets the host- or service url.- Parameters:
url- the url
-
getOptions
@Bindable public java.lang.String getOptions()
Gets other options.
Each option goes into a separate line.- Returns:
- the options
-
setOptions
@Bindable public void setOptions(java.lang.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 java.lang.String getUser()
Gets the optional username.- Returns:
- the username
-
setUser
@Bindable public void setUser(java.lang.String user)
Gets the username.- Parameters:
user- the username
-
getPassword
@Bindable public java.lang.String getPassword()
Gets the optional password.- Returns:
- the password
-
setPassword
@Bindable public void setPassword(java.lang.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(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-