Class BareConfiguration

java.lang.Object
de.businesscode.util.JNDIProvider
de.businesscode.bcdui.toolbox.config.BareConfiguration
All Implemented Interfaces:
ConfigurationProvider

public class BareConfiguration extends JNDIProvider
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
  • Constructor Details

    • BareConfiguration

      public BareConfiguration()
  • Method Details

    • getInstance

      public static BareConfiguration getInstance()
    • getConfigurationParameters

      public Map<String,Object> getConfigurationParameters()
      configuration parameter map.
      Returns:
    • addConfigurationParameter

      public <T> Object addConfigurationParameter(String id, T value)
      add new or overwrite existing configuration parameter
      Parameters:
      id -
      value -
      Returns:
      old parameters value in case the parameter has been overwritten or null
    • getManagedConnection

      public Connection getManagedConnection(String dbSourceName) throws Exception
      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 the getUnmanagedConnection(String) instead and close the obtained Connection 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

      public void closeAllConnections(boolean rollback) throws SQLException
      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

      public Connection getUnmanagedConnection(String dbSourceName) throws Exception
      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

      public DataSource getUnmanagedDataSource(String dbSourceName) throws Exception
      Parameters:
      dbSourceName -
      Returns:
      Throws:
      Exception
    • getRawDataSource

      public DataSource getRawDataSource(String dbSourceName) throws Exception
      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 to getManagedConnection(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 to getManagedConnection(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()