Java 类org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl 实例源码

项目:gorm-hibernate5    文件:GrailsHibernateTemplate.java   
public GrailsHibernateTemplate(SessionFactory sessionFactory) {
    Assert.notNull(sessionFactory, "Property 'sessionFactory' is required");
    this.sessionFactory = sessionFactory;

    ConnectionProvider connectionProvider = ((SessionFactoryImplementor) sessionFactory).getServiceRegistry().getService(ConnectionProvider.class);
    if(connectionProvider instanceof DatasourceConnectionProviderImpl) {
        this.dataSource = ((DatasourceConnectionProviderImpl) connectionProvider).getDataSource();
        if(dataSource instanceof TransactionAwareDataSourceProxy) {
            this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
        }
        jdbcExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(dataSource);
    }
    else {
        // must be in unit test mode, setup default translator
        SQLErrorCodeSQLExceptionTranslator sqlErrorCodeSQLExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator();
        sqlErrorCodeSQLExceptionTranslator.setDatabaseProductName("H2");
        jdbcExceptionTranslator = sqlErrorCodeSQLExceptionTranslator;
    }
}
项目:CredentialStorageService-dw-hibernate    文件:SessionFactoryFactory.java   
private ConnectionProvider buildConnectionProvider(final DataSource dataSource,
        final Map<String, String> properties) {
    final DatasourceConnectionProviderImpl connectionProvider = new DatasourceConnectionProviderImpl();
    connectionProvider.setDataSource(dataSource);
    connectionProvider.configure(properties);
    return connectionProvider;
}
项目:nway-jdbc    文件:JndiConnectionProvider.java   
@Override
@SuppressWarnings({ "unchecked" })
public <T> T unwrap(Class<T> unwrapType) {
    if (ConnectionProvider.class.equals(unwrapType)
            || DatasourceConnectionProviderImpl.class.isAssignableFrom(unwrapType)) {
        return (T) this;
    } else if (DataSource.class.isAssignableFrom(unwrapType)) {
        return (T) this.dataSource;
    } else {
        throw new UnknownUnwrapTypeException(unwrapType);
    }
}
项目:rjb-blog-multitenancy    文件:MultiTenantConnectionProviderImpl.java   
public MultiTenantConnectionProviderImpl(MultiTenantDataSource dataSource) {
    this.dataSourceConnectionProvider = new DatasourceConnectionProviderImpl();
    this.dataSourceConnectionProvider.setDataSource(dataSource);
    // this triggers the 'available' flag
    this.dataSourceConnectionProvider.configure(new HashMap<Object, Object>());
}
项目:rjb-blog-multitenancy    文件:MultiTenantConnectionProviderImpl.java   
protected DatasourceConnectionProviderImpl getDatasourceConnectionProvider() {
    return this.dataSourceConnectionProvider;
}
项目:rjb-blog-multitenancy    文件:MultiTenantConnectionProviderImpl.java   
public MultiTenantConnectionProviderImpl(MultiTenantDataSource dataSource) {
    this.dataSourceConnectionProvider = new DatasourceConnectionProviderImpl();
    this.dataSourceConnectionProvider.setDataSource(dataSource);
    // this triggers the 'available' flag
    this.dataSourceConnectionProvider.configure(new HashMap<Object, Object>());
}
项目:rjb-blog-multitenancy    文件:MultiTenantConnectionProviderImpl.java   
protected DatasourceConnectionProviderImpl getDatasourceConnectionProvider() {
    return this.dataSourceConnectionProvider;
}
项目:nway-jdbc    文件:JndiConnectionProvider.java   
@Override
public boolean isUnwrappableAs(Class unwrapType) {
    return ConnectionProvider.class.equals(unwrapType)
            || DatasourceConnectionProviderImpl.class.isAssignableFrom(unwrapType)
            || DataSource.class.isAssignableFrom(unwrapType);
}
项目:ignite    文件:HibernateL2CacheTransactionalSelfTest.java   
/** {@inheritDoc} */
@Nullable @Override protected StandardServiceRegistryBuilder registryBuilder() {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();

    BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.

    dataSrc.setTransactionManager(jotm.getTransactionManager());

    dataSrc.setDefaultAutoCommit(false);

    JdbcDataSource h2DataSrc = new JdbcDataSource();

    h2DataSrc.setURL(CONNECTION_URL);

    dataSrc.setXaDataSourceInstance(h2DataSrc);

    connProvider.setDataSource(dataSrc);

    connProvider.configure(Collections.emptyMap());

    builder.addService(ConnectionProvider.class, connProvider);

    builder.addService(JtaPlatform.class, new TestJtaPlatform());

    builder.applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName());

    return builder;
}
项目:dropwizard-routing    文件:RoutingSessionFactoryFactory.java   
/**
 * Builds a {@link ConnectionProvider}
 * @param dataSource
 *            the datasource
 * @param properties
 *            the connection properties
 * @return {@link ConnectionProvider}
 */
private ConnectionProvider buildConnectionProvider(DataSource dataSource, Map<String, String> properties) {
    final DatasourceConnectionProviderImpl connectionProvider = new DatasourceConnectionProviderImpl();
    connectionProvider.setDataSource(dataSource);
    connectionProvider.configure(properties);
    return connectionProvider;
}