Class TopiaConnectionProvider

java.lang.Object
org.nuiton.topia.framework.TopiaConnectionProvider
All Implemented Interfaces:
java.io.Serializable, org.hibernate.engine.jdbc.connections.spi.ConnectionProvider, org.hibernate.service.Service, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.Stoppable, org.hibernate.service.spi.Wrapped

public class TopiaConnectionProvider
extends java.lang.Object
implements org.hibernate.engine.jdbc.connections.spi.ConnectionProvider, org.hibernate.service.spi.Configurable, org.hibernate.service.spi.Stoppable
Customized connection provider. This provider fix the following bug : http://nuiton.org/issues/show/561 To use this connection provider, add this property to topia configuration
 config.setProperty(Environment.CONNECTION_PROVIDER, TopiaConnectionProvider.class.getName());
 
or in a properties file :
 hibernate.connection.provider_class=org.nuiton.topia.framework.TopiaConnectionProvider
 
Since:
2.5.3
Author:
tchemit <chemit@codelutin.com>
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected boolean autocommit
    auto commit connection state.
    protected java.util.Properties connectionProps
    All grabbed connection properties
    protected java.lang.Integer isolation
    Sql isolation level to use in connection.
    protected java.util.List<java.sql.Connection> pool
    Our pool of connections which are not closed and availables.
    protected int poolSize
    Size of connection pool.
    protected java.lang.String url
    JDBC url of connection.
  • Constructor Summary

    Constructors 
    Constructor Description
    TopiaConnectionProvider()  
  • Method Summary

    Modifier and Type Method Description
    void closeConnection​(java.sql.Connection conn)  
    void configure​(java.util.Map configurationValues)  
    protected void finalize()  
    java.sql.Connection getConnection()  
    java.util.Properties getConnectionProps()  
    java.lang.Integer getIsolation()  
    java.util.List<java.sql.Connection> getPool()  
    int getPoolSize()  
    java.lang.String getUrl()  
    boolean isAutocommit()  
    boolean isUnwrappableAs​(java.lang.Class unwrapType)  
    void stop()  
    boolean supportsAggressiveRelease()  
    <T> T unwrap​(java.lang.Class<T> unwrapType)  

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • url

      protected java.lang.String url
      JDBC url of connection. This is a mandatory hibernate configuration vi the property AvailableSettings.URL.
    • connectionProps

      protected java.util.Properties connectionProps
      All grabbed connection properties
    • isolation

      protected java.lang.Integer isolation
      Sql isolation level to use in connection. Can be configured by hibernate property AvailableSettings.ISOLATION.
      See Also:
      Connection.getTransactionIsolation()
    • autocommit

      protected boolean autocommit
      auto commit connection state. Can be configured by hibernate property AvailableSettings.AUTOCOMMIT.
      See Also:
      Connection.getAutoCommit()
    • poolSize

      protected int poolSize
      Size of connection pool. By default use 20, can be specify by using the hibernate configuration property AvailableSettings.POOL_SIZE.
    • pool

      protected final java.util.List<java.sql.Connection> pool
      Our pool of connections which are not closed and availables.
  • Constructor Details

  • Method Details

    • configure

      public void configure​(java.util.Map configurationValues) throws org.hibernate.HibernateException
      Specified by:
      configure in interface org.hibernate.service.spi.Configurable
      Throws:
      org.hibernate.HibernateException
    • getConnection

      public java.sql.Connection getConnection() throws java.sql.SQLException
      Specified by:
      getConnection in interface org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
      Throws:
      java.sql.SQLException
    • closeConnection

      public void closeConnection​(java.sql.Connection conn) throws java.sql.SQLException
      Specified by:
      closeConnection in interface org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
      Throws:
      java.sql.SQLException
    • finalize

      protected void finalize() throws java.lang.Throwable
      Overrides:
      finalize in class java.lang.Object
      Throws:
      java.lang.Throwable
    • stop

      public void stop()
      Specified by:
      stop in interface org.hibernate.service.spi.Stoppable
    • supportsAggressiveRelease

      public boolean supportsAggressiveRelease()
      Specified by:
      supportsAggressiveRelease in interface org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
    • getUrl

      public java.lang.String getUrl()
    • getConnectionProps

      public java.util.Properties getConnectionProps()
    • getIsolation

      public java.lang.Integer getIsolation()
    • getPool

      public java.util.List<java.sql.Connection> getPool()
    • getPoolSize

      public int getPoolSize()
    • isAutocommit

      public boolean isAutocommit()
    • isUnwrappableAs

      public boolean isUnwrappableAs​(java.lang.Class unwrapType)
      Specified by:
      isUnwrappableAs in interface org.hibernate.service.spi.Wrapped
    • unwrap

      public <T> T unwrap​(java.lang.Class<T> unwrapType)
      Specified by:
      unwrap in interface org.hibernate.service.spi.Wrapped