bitronix.tm.resource.jdbc.PoolingDataSource Java Examples

The following examples show how to use bitronix.tm.resource.jdbc.PoolingDataSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JTAFlexyPoolTestConfiguration.java    From high-performance-java-persistence with Apache License 2.0 6 votes vote down vote up
@Override
public DataSource actualDataSource() {
    final PoolingDataSource poolingDataSource = (PoolingDataSource) super.actualDataSource();
    com.vladmihalcea.flexypool.config.Configuration<PoolingDataSource> configuration = new com.vladmihalcea.flexypool.config.Configuration.Builder<>(
        getClass().getSimpleName(), poolingDataSource, BitronixPoolAdapter.FACTORY).build();

    FlexyPoolDataSource<PoolingDataSource> flexyPoolDataSource = new FlexyPoolDataSource<PoolingDataSource>(configuration) {
        @Override
        public void start() {
            poolingDataSource.init();
            super.start();
        }

        @Override
        public void stop() {
            super.stop();
            poolingDataSource.close();
        }
    };
    return flexyPoolDataSource;
}
 
Example #2
Source File: EsbUtils.java    From iaf with Apache License 2.0 6 votes vote down vote up
private static PoolingDataSource setupJdbcDataSource(String url,
		String userName, String password) {
	log.debug("setting up JdbcDataSource url [" + url + "] username ["
			+ userName + "] password ["
			+ StringUtils.repeat("*", password.length()) + "]");
	PoolingDataSource jdbcDataSource = new PoolingDataSource();
	jdbcDataSource.setClassName("oracle.jdbc.xa.client.OracleXADataSource");
	jdbcDataSource.setUniqueName("oracle");
	jdbcDataSource.setMaxPoolSize(5);
	jdbcDataSource.setAllowLocalTransactions(true);
	// jdbcDataSource.setTestQuery("SELECT 1 FROM DUAL");
	jdbcDataSource.getDriverProperties().setProperty("user", userName);
	jdbcDataSource.getDriverProperties().setProperty("password", password);
	jdbcDataSource.getDriverProperties().setProperty("URL", url);
	jdbcDataSource.init();
	return jdbcDataSource;
}
 
Example #3
Source File: FlexyPoolConfiguration.java    From flexy-pool with Apache License 2.0 6 votes vote down vote up
@Bean
public Configuration<PoolingDataSource> configuration() {
    return new Configuration.Builder<PoolingDataSource>(
            uniqueId,
            poolingDataSource,
            BitronixPoolAdapter.FACTORY
    )
    .setMetricsFactory(MetricsFactoryResolver.INSTANCE.resolve())
    .setConnectionProxyFactory(ConnectionDecoratorFactoryResolver.INSTANCE.resolve())
    .setMetricLogReporterMillis(TimeUnit.SECONDS.toMillis(5))
    .setJmxEnabled(true)
    .setJmxAutoStart(true)
    .setConnectionAcquireTimeThresholdMillis(50L)
    .setConnectionLeaseTimeThresholdMillis(250L)
    .setEventListenerResolver(new EventListenerResolver() {
        @Override
        public List<EventListener<? extends Event>> resolveListeners() {
            return Arrays.<EventListener<? extends Event>>asList(
                new ConnectionAcquireTimeoutEventListener(),
                new ConnectionAcquireTimeThresholdExceededEventListener(),
                new ConnectionLeaseTimeThresholdExceededEventListener()
            );
        }
    })
    .build();
}
 
Example #4
Source File: Connections.java    From glowroot with Apache License 2.0 6 votes vote down vote up
static PoolingDataSource createBitronixWrappedDataSource() throws AssertionError {
    if (Connections.class.getClassLoader() instanceof IsolatedWeavingClassLoader) {
        throw new AssertionError("Bitronix loads JdbcProxyFactory implementation using a"
                + " parent-first class loader, which bypasses IsolatedWeavingClassLoader, must"
                + " use JavaagentContainer");
    }
    PoolingDataSource ds = new PoolingDataSource();
    ds.setClassName(JDBCXADataSource.class.getName());
    Properties props = new Properties();
    props.setProperty("url", "jdbc:hsqldb:mem:test");
    ds.setDriverProperties(props);
    ds.setMaxPoolSize(1);
    ds.setUniqueName("unique-name-" + nextUniqueNum++);
    ds.setAllowLocalTransactions(true);
    return ds;
}
 
Example #5
Source File: JTATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "close")
public PoolingDataSource actualDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName(getClass().getName());
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("url", jdbcUrl);
    return poolingDataSource;
}
 
Example #6
Source File: JTAMultipleTransactionsConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
public DataSource extraDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName("ExtraDS");
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("databaseName", jdbcDatabase);
    poolingDataSource.getDriverProperties().put("serverName", jdbcHost);
    poolingDataSource.getDriverProperties().put("portNumber", jdbcPort);
    return poolingDataSource;
}
 
Example #7
Source File: HSQLDBJtaTransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
public DataSource actualDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName(getClass().getName());
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("url", jdbcUrl);
    return poolingDataSource;
}
 
Example #8
Source File: PostgreSQLJTATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
public DataSource actualDataSource() {
    PoolingDataSource poolingDataSource = new PoolingDataSource();
    poolingDataSource.setClassName(dataSourceClassName);
    poolingDataSource.setUniqueName(getClass().getName());
    poolingDataSource.setMinPoolSize(0);
    poolingDataSource.setMaxPoolSize(5);
    poolingDataSource.setAllowLocalTransactions(true);
    poolingDataSource.setDriverProperties(new Properties());
    poolingDataSource.getDriverProperties().put("user", jdbcUser);
    poolingDataSource.getDriverProperties().put("password", jdbcPassword);
    poolingDataSource.getDriverProperties().put("databaseName", jdbcDatabase);
    poolingDataSource.getDriverProperties().put("serverName", jdbcHost);
    poolingDataSource.getDriverProperties().put("portNumber", jdbcPort);
    return poolingDataSource;
}
 
Example #9
Source File: FlexyPoolConfiguration.java    From flexy-pool with Apache License 2.0 5 votes vote down vote up
@Bean(initMethod = "start", destroyMethod = "stop")
public FlexyPoolDataSource dataSource() {
    Configuration<PoolingDataSource> configuration = configuration();
    return new FlexyPoolDataSource<PoolingDataSource>(configuration,
            new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory(5),
            new RetryConnectionAcquiringStrategy.Factory(2)
    );
}
 
Example #10
Source File: CloseXADataSourceLifecycleListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setDataSource(PoolingDataSource dataSource) {
    this.dataSource = dataSource;
}
 
Example #11
Source File: BitronixDataSourceFactoryBean.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getObjectType() {
    return PoolingDataSource.class;
}
 
Example #12
Source File: CloseXADataSourceLifecycleListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setDataSource(PoolingDataSource dataSource) {
    this.dataSource = dataSource;
}
 
Example #13
Source File: BitronixDataSourceFactoryBean.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getObjectType() {
    return PoolingDataSource.class;
}
 
Example #14
Source File: CloseXADataSourceLifecycleListener.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void setDataSource(PoolingDataSource dataSource) {
  this.dataSource = dataSource;
}
 
Example #15
Source File: BitronixDataSourceFactoryBean.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getObjectType() {
  return PoolingDataSource.class;
}
 
Example #16
Source File: BitronixPoolAdapter.java    From flexy-pool with Apache License 2.0 4 votes vote down vote up
@Override
public PoolAdapter<PoolingDataSource> newInstance(
        ConfigurationProperties<PoolingDataSource, Metrics, PoolAdapter<PoolingDataSource>> configurationProperties) {
return new BitronixPoolAdapter(configurationProperties);
}
 
Example #17
Source File: CloseXADataSourceLifecycleListener.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void setDataSource(PoolingDataSource dataSource) {
  this.dataSource = dataSource;
}
 
Example #18
Source File: BitronixDataSourceFactoryBean.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getObjectType() {
  return PoolingDataSource.class;
}
 
Example #19
Source File: BitronixPoolAdapter.java    From flexy-pool with Apache License 2.0 2 votes vote down vote up
/**
 * Init constructor
 * @param configurationProperties configuration properties
 */
public BitronixPoolAdapter(ConfigurationProperties<PoolingDataSource, Metrics, PoolAdapter<PoolingDataSource>> configurationProperties) {
    super(configurationProperties);
}