We are right now using DBCP datasource. But we would like to configure
HikariCP.
Could one of you please help validate if what we are doing below is the
correct way to get HikariCP Datasource works in container managed
transaction in embedded container.
Create a custom DataSourceCreator class for Hikari datasource and
set the “DataSourceCreator” property to the custom DataSourceCreator class.
Also should autoCommit be true when creating the HikariDataSource object in
the DataSourceCreator class?
public class HikariDataSourceCreator extends
org.apache.openejb.resource.jdbc.pool.PoolDataSourceCreator {
@Override
protected void doDestroy(CommonDataSource commonDataSource) throws
Throwable {
((HikariDataSource)commonDataSource).close();
}
@Override
public DataSource pool(String name, DataSource ds, Properties properties)
{
throw new UnsupportedOperationException("");
}
@Override
public CommonDataSource pool(String name, String driver, Properties
properties) {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setPoolName(name);
hikariConfig.setJdbcUrl(properties.getProperty("JdbcUrl"));
hikariConfig.setUsername(properties.getProperty("Username"));
hikariConfig.setPassword(properties.getProperty("Password"));
hikariConfig.setMaximumPoolSize(Integer.parseInt(properties.getProperty("maxActive")));
hikariConfig.setMinimumIdle(Integer.parseInt(properties.getProperty("initialSize")));
HikariDataSource dataSource = new HikariDataSource(hikariConfig);
return dataSource;
}
}
contextProperties.put(dataSourceName,"new://Resource?type=javax.sql.DataSource");
contextProperties.put(dataSourceName+".DataSourceCreator","org.superbiz.ejblookup.HikariDataSourceCreator");
contextProperties.put(dataSourceName+".JdbcDriver",
"oracle.jdbc.OracleDriver");
contextProperties.put(dataSourceName+".JtaManaged", "true”);
Please confirm
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html