Class PerUserPoolDataSource

  • All Implemented Interfaces:
    Serializable, AutoCloseable, Wrapper, Referenceable, CommonDataSource, DataSource

    public class PerUserPoolDataSource
    extends InstanceKeyDataSource

    A pooling DataSource appropriate for deployment within J2EE environment. There are many configuration options, most of which are defined in the parent class. This datasource uses individual pools per user, and some properties can be set specifically for a given user, if the deployment environment can support initialization of mapped properties. So for example, a pool of admin or write-access Connections can be guaranteed a certain number of connections, separate from a maximum set for users with read-only connections.

    User passwords can be changed without re-initializing the datasource. When a getConnection(userName, password) request is processed with a password that is different from those used to create connections in the pool associated with userName, an attempt is made to create a new connection using the supplied password and if this succeeds, the existing pool is cleared and a new pool is created for connections using the new password.

    Since:
    2.0
    See Also:
    Serialized Form
    • Constructor Detail

      • PerUserPoolDataSource

        public PerUserPoolDataSource()
        Default no-arg constructor for Serialization.
    • Method Detail

      • clear

        public void clear()
        Clears pool(s) maintained by this data source.
        Since:
        2.3.0
        See Also:
        ObjectPool.clear()
      • getConnectionManager

        protected org.datanucleus.store.rdbms.datasource.dbcp2.datasources.PooledConnectionManager getConnectionManager​(org.datanucleus.store.rdbms.datasource.dbcp2.datasources.UserPassKey upKey)
        Specified by:
        getConnectionManager in class InstanceKeyDataSource
      • getNumActive

        public int getNumActive()
        Gets the number of active connections in the default pool.
        Returns:
        The number of active connections in the default pool.
      • getNumActive

        public int getNumActive​(String userName)
        Gets the number of active connections in the pool for a given user.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getNumIdle

        public int getNumIdle()
        Gets the number of idle connections in the default pool.
        Returns:
        The number of idle connections in the default pool.
      • getNumIdle

        public int getNumIdle​(String userName)
        Gets the number of idle connections in the pool for a given user.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserBlockWhenExhausted

        public boolean getPerUserBlockWhenExhausted​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getBlockWhenExhausted() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserDefaultAutoCommit

        public Boolean getPerUserDefaultAutoCommit​(String userName)
        Gets the user specific default value for Connection.setAutoCommit(boolean) for the specified user's pool.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserDefaultReadOnly

        public Boolean getPerUserDefaultReadOnly​(String userName)
        Gets the user specific default value for Connection.setReadOnly(boolean) for the specified user's pool.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserDefaultTransactionIsolation

        public Integer getPerUserDefaultTransactionIsolation​(String userName)
        Gets the user specific default value for Connection.setTransactionIsolation(int) for the specified user's pool.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserEvictionPolicyClassName

        public String getPerUserEvictionPolicyClassName​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getEvictionPolicyClassName() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserLifo

        public boolean getPerUserLifo​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getLifo() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserMaxIdle

        public int getPerUserMaxIdle​(String userName)
        Gets the user specific value for GenericObjectPool.getMaxIdle() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserMaxTotal

        public int getPerUserMaxTotal​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getMaxTotal() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserMaxWaitMillis

        public long getPerUserMaxWaitMillis​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getMaxWaitMillis() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserMinEvictableIdleTimeMillis

        public long getPerUserMinEvictableIdleTimeMillis​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getMinEvictableIdleTimeMillis() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserMinIdle

        public int getPerUserMinIdle​(String userName)
        Gets the user specific value for GenericObjectPool.getMinIdle() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserNumTestsPerEvictionRun

        public int getPerUserNumTestsPerEvictionRun​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getNumTestsPerEvictionRun() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserSoftMinEvictableIdleTimeMillis

        public long getPerUserSoftMinEvictableIdleTimeMillis​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserTestOnBorrow

        public boolean getPerUserTestOnBorrow​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getTestOnBorrow() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserTestOnCreate

        public boolean getPerUserTestOnCreate​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getTestOnCreate() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserTestOnReturn

        public boolean getPerUserTestOnReturn​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getTestOnReturn() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserTestWhileIdle

        public boolean getPerUserTestWhileIdle​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getTestWhileIdle() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • getPerUserTimeBetweenEvictionRunsMillis

        public long getPerUserTimeBetweenEvictionRunsMillis​(String userName)
        Gets the user specific value for BaseGenericObjectPool.getTimeBetweenEvictionRunsMillis() for the specified user's pool or the default if no user specific value is defined.
        Parameters:
        userName - The user name key.
        Returns:
        The user specific value.
      • setPerUserBlockWhenExhausted

        public void setPerUserBlockWhenExhausted​(String userName,
                                                 Boolean value)
        Sets a user specific value for BaseGenericObjectPool.getBlockWhenExhausted() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserDefaultAutoCommit

        public void setPerUserDefaultAutoCommit​(String userName,
                                                Boolean value)
        Sets a user specific default value for Connection.setAutoCommit(boolean) for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserDefaultReadOnly

        public void setPerUserDefaultReadOnly​(String userName,
                                              Boolean value)
        Sets a user specific default value for Connection.setReadOnly(boolean) for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserDefaultTransactionIsolation

        public void setPerUserDefaultTransactionIsolation​(String userName,
                                                          Integer value)
        Sets a user specific default value for Connection.setTransactionIsolation(int) for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserLifo

        public void setPerUserLifo​(String userName,
                                   Boolean value)
        Sets a user specific value for BaseGenericObjectPool.getLifo() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserMaxIdle

        public void setPerUserMaxIdle​(String userName,
                                      Integer value)
        Sets a user specific value for GenericObjectPool.getMaxIdle() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserMaxTotal

        public void setPerUserMaxTotal​(String userName,
                                       Integer value)
        Sets a user specific value for BaseGenericObjectPool.getMaxTotal() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserMaxWaitMillis

        public void setPerUserMaxWaitMillis​(String userName,
                                            Long value)
        Sets a user specific value for BaseGenericObjectPool.getMaxWaitMillis() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserMinIdle

        public void setPerUserMinIdle​(String userName,
                                      Integer value)
        Sets a user specific value for GenericObjectPool.getMinIdle() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserTestOnBorrow

        public void setPerUserTestOnBorrow​(String userName,
                                           Boolean value)
        Sets a user specific value for BaseGenericObjectPool.getTestOnBorrow() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserTestOnCreate

        public void setPerUserTestOnCreate​(String userName,
                                           Boolean value)
        Sets a user specific value for BaseGenericObjectPool.getTestOnCreate() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserTestOnReturn

        public void setPerUserTestOnReturn​(String userName,
                                           Boolean value)
        Sets a user specific value for BaseGenericObjectPool.getTestOnReturn() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserTestWhileIdle

        public void setPerUserTestWhileIdle​(String userName,
                                            Boolean value)
        Sets a user specific value for BaseGenericObjectPool.getTestWhileIdle() for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.
      • setPerUserTimeBetweenEvictionRunsMillis

        public void setPerUserTimeBetweenEvictionRunsMillis​(String userName,
                                                            Long value)
        Sets a user specific value for () for the specified user's pool.
        Parameters:
        userName - The user name key.
        value - The user specific value.