java.lang.Object
org.tentackle.session.AbstractSessionConfiguration
org.tentackle.session.BackendConfiguration
- All Implemented Interfaces:
ScopeConfigurator,Validateable
Configuration for a database backend.
The configuration is stored via the standard
The config refers to a
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 Summary
ConstructorsConstructorDescriptionBackendConfiguration(String application, String name, String url, String options, DriverConfiguration driver, String user, String password) Creates a backend configuration. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the application name.static Map<String,BackendConfiguration> getBackendConfigurations(String application, boolean system) Loads all backend configurations for a given application.static BackendConfigurationgetDefault(String application, boolean system) Gets the default backend configuration.Gets the driver configuration.Gets other options.
Each option goes into a separate line.Gets the optional password.getUrl()Gets the host- or service url.getUser()Gets the optional username.inthashCode()voidpersist(boolean system) Persists this configuration.voidremove(boolean system) Removes this configuration.static voidremoveBackendConfigurations(String application, boolean system) Removes all backend configurations for given application.voidsetApplication(String application) Sets the application name.static voidsetDefault(BackendConfiguration backend, String application, boolean system) Sets the default backend configuration.voidsetDriver(DriverConfiguration driver) Sets the driver configuration.voidsetOptions(String options) Sets the options.voidsetPassword(String password) Sets the password.voidSets the host- or service url.voidGets the username.Methods inherited from class org.tentackle.session.AbstractSessionConfiguration
getDefaultScopes, getName, getPrefNode, isPersisted, setName, setPersisted, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tentackle.validate.Validateable
validate
-
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 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 Details
-
getBackendConfigurations
public static Map<String,BackendConfiguration> getBackendConfigurations(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
Removes all backend configurations for given application.- Parameters:
application- the application namesystem- true if load from system preferences, else user preferences
-
setDefault
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
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
Gets the application name.- Returns:
- the application name
-
setApplication
Sets the application name.- Parameters:
application- the application name
-
getUrl
Gets the host- or service url.- Returns:
- the url
-
setUrl
Sets the host- or service url.- Parameters:
url- the url
-
getOptions
Gets other options.
Each option goes into a separate line.- Returns:
- the options
-
setOptions
Sets the options.- Parameters:
options- the options, null if none
-
getDriver
Gets the driver configuration.- Returns:
- the driver, null if remote or from classpath
-
setDriver
Sets the driver configuration.- Parameters:
driver- the driver, null if remote or from classpath
-
getUser
Gets the optional username.- Returns:
- the username
-
setUser
Gets the username.- Parameters:
user- the username
-
getPassword
Gets the optional password.- Returns:
- the password
-
setPassword
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
-
hashCode
public int hashCode()
-