Class 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 Detail

      • BareConfiguration

        public BareConfiguration()
    • Method Detail

      • getConfigurationParameters

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

        public <T> java.lang.Object addConfigurationParameter​(java.lang.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 java.sql.Connection getManagedConnection​(java.lang.String dbSourceName)
                                                 throws java.lang.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:
        java.lang.Exception - in case something went wrong. Especially, if the current thread is not bound to a HTTP request.
      • getManagedConnection

        public java.sql.Connection getManagedConnection​(java.lang.String dbSourceName,
                                                        boolean closedByRequestLifeCycleFilter)
                                                 throws java.lang.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:
        java.lang.Exception
      • closeAllConnections

        public void closeAllConnections​(boolean rollback)
                                 throws java.sql.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:
        java.sql.SQLException
      • getUnmanagedConnection

        public java.sql.Connection getUnmanagedConnection​(java.lang.String dbSourceName)
                                                   throws java.lang.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:
        java.lang.Exception
      • getRawDataSource

        public javax.sql.DataSource getRawDataSource​(java.lang.String dbSourceName)
                                              throws java.lang.Exception
        Parameters:
        dbSourceName -
        Returns:
        Throws:
        java.lang.Exception
      • getUnmanagedDataSource

        public static javax.sql.DataSource getUnmanagedDataSource​(ConfigurationProvider provider,
                                                                  java.lang.String dbSourceName)
                                                           throws java.lang.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:
        java.lang.Exception
      • getRawDataSource

        public static javax.sql.DataSource getRawDataSource​(ConfigurationProvider provider,
                                                            java.lang.String dbSourceName)
                                                     throws java.lang.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:
        java.lang.Exception
      • isCacheDisabled

        public boolean isCacheDisabled()