Class BareConfiguration
java.lang.Object
de.businesscode.util.JNDIProvider
de.businesscode.bcdui.toolbox.config.BareConfiguration
- All Implemented Interfaces:
ConfigurationProvider
bare configuration singleton, this class is for internal purpose and must not be used in
projects, consider using
Configuration
that purpose. This class has to be used in cases
where static or instance initializers directly or transitively depend on BindingSet-
Field Summary
Fields inherited from class de.businesscode.util.JNDIProvider
configurationParameters
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Object
addConfigurationParameter
(String id, T value) add new or overwrite existing configuration parametervoid
closeAllConnections
(boolean rollback) This method closes all connections opened with getConnection and belonging to the current thread.configuration parameter map.static BareConfiguration
getManagedConnection
(String dbSourceName) This function gets a managed connection from the specified dbSourceName.getManagedConnection
(String dbSourceName, boolean closedByRequestLifeCycleFilter) This is meant to be used in non-HTTP-requests like batch engines Returns a managed connections but the caller will explicitly call closeAllConnections() for the current thread and does not rely on RequestlifecycleFilter to do so.static DataSource
getRawDataSource
(ConfigurationProvider provider, String dbSourceName) Gets the not wrapped DataSource associated with the specified dbSourceName.getRawDataSource
(String dbSourceName) getUnmanagedConnection
(String dbSourceName) Takes a new connection from the specified DataSource.static DataSource
getUnmanagedDataSource
(ConfigurationProvider provider, String dbSourceName) Gets the DataSource associated with the specified dbSourceName.getUnmanagedDataSource
(String dbSourceName) boolean
Methods inherited from class de.businesscode.util.JNDIProvider
getConfigurationParameter, getConfigurationParameter, getConfigurationParameterOrNull, getLocalInstance, init, purgeCache, putConfigurationParameter
-
Constructor Details
-
BareConfiguration
public BareConfiguration()
-
-
Method Details
-
getInstance
-
getConfigurationParameters
configuration parameter map.- Returns:
-
addConfigurationParameter
add new or overwrite existing configuration parameter- Parameters:
id
-value
-- Returns:
- old parameters value in case the parameter has been overwritten or null
-
getManagedConnection
This function gets a managed connection from the specified dbSourceName. It is managed for three reasons:- Each request gets only one single connection per dbSourceName.
- All connections are closed at the end of the request. They must not be closed manually.
- transaction scope: a managed connection is always initialized with autocommit = false and comitted at the end of the httprequest lifecycle (or rolled back in case of exception)
ATTENTION: A managed connection may only be obtained within HttpRequest scope which is managed by
RequestLifeCycleFilter
responsible to tidy up the resources. This method will throw an exception in case of usage out of HttpRequest scope. Please use thegetUnmanagedConnection(String)
instead and close the obtainedConnection
manually.- Parameters:
dbSourceName
- The datasource name. May be NULL so a default connection is returned.- Returns:
- A managed connection from the configured dataSource with non-autocommit.
- Throws:
Exception
- in case something went wrong. Especially, if the current thread is not bound to a HTTP request.
-
getManagedConnection
public Connection getManagedConnection(String dbSourceName, boolean closedByRequestLifeCycleFilter) throws Exception This is meant to be used in non-HTTP-requests like batch engines Returns a managed connections but the caller will explicitly call closeAllConnections() for the current thread and does not rely on RequestlifecycleFilter to do so.- Parameters:
dbSourceName
-closedByRequestLifeCycleFilter
-- Returns:
- Throws:
Exception
-
closeAllConnections
This method closes all connections opened with getConnection and belonging to the current thread. It is called by the RequestLifeCycleFilter.- Parameters:
rollback
- Set this to true if rollback should be made instead of commit. The default is "false" - so a commit is applied on managed connections- Throws:
SQLException
-
getUnmanagedConnection
Takes a new connection from the specified DataSource. This connection is not managed meaning that it is always a new connection for each call and it needs to be closed manually, as well as this connection is autocommit as per default.- Parameters:
dbSourceName
- The DataSource generating the connection.- Returns:
- The new unmanaged connection, with autocommit.
- Throws:
Exception
-
getUnmanagedDataSource
- Parameters:
dbSourceName
-- Returns:
- Throws:
Exception
-
getRawDataSource
- Parameters:
dbSourceName
-- Returns:
- Throws:
Exception
-
getUnmanagedDataSource
public static DataSource getUnmanagedDataSource(ConfigurationProvider provider, String dbSourceName) throws Exception Gets the DataSource associated with the specified dbSourceName. This DataSource does not return managed connections in contrast togetManagedConnection(String)
.- Parameters:
dbSourceName
- , if null then configured default datasource is returned. May be NULL so a default connection is returned.- Returns:
- the dataSource with the given ID or the default dataSource (configuring in DEFAULT_DB_CONTEXT_ID)
- Throws:
Exception
-
getRawDataSource
public static DataSource getRawDataSource(ConfigurationProvider provider, String dbSourceName) throws Exception Gets the not wrapped DataSource associated with the specified dbSourceName. This DataSource does not return managed connections in contrast togetManagedConnection(String)
.- Parameters:
dbSourceName
- , if null then configured default datasource is returned. May be NULL so a default connection is returned.- Returns:
- the dataSource with the given ID or the default dataSource (configuring in DEFAULT_DB_CONTEXT_ID)
- Throws:
Exception
-
isCacheDisabled
public boolean isCacheDisabled()
-