private static void configureJdbcPool( Map<String, PoolingDataSource> dataSources, Set<ResourceBean> started, Configuration config) throws ConfigurationException { PoolingDataSource ds = new PoolingDataSource(); final String uniqueName = confgureResourceBean(ds, config); for (Configuration child : config.getChildren()) { switch (child.getName()) { case "testQuery": ds.setTestQuery(child.getValue()); break; case "enableJdbc4ConnectionTest": ds.setEnableJdbc4ConnectionTest(child.getValueAsBoolean()); break; case "preparedStatementCacheSize": ds.setPreparedStatementCacheSize(child.getValueAsInteger()); break; case "isolationLevel": ds.setIsolationLevel(child.getValue()); break; case "cursorHoldability": ds.setCursorHoldability(child.getValue()); break; case "localAutoCommit": ds.setLocalAutoCommit(child.getValue()); break; case "driverProperties": configureDriverProperties(ds.getDriverProperties(), child); break; default: if (!RESOURCE_BEAN_PROPERTIES.contains(child.getName())) { throw new ConfigurationException( "unsupported element " + child.getName(), child.getPath(), child.getLocation()); } } } if (config.getAttributeAsBoolean("eager", false)) { ds.init(); started.add(ds); } dataSources.put(uniqueName, ds); }
public static void configure( Map<String, PoolingDataSource> dataSources, String dsName, String dsClass, Properties dsProperties) { bitronix.tm.Configuration btm = TransactionManagerServices.getConfiguration(); setDefaults(btm); btm.setServerId("default"); btm.setLogPart1Filename("target/btm1.tlog"); btm.setLogPart2Filename("target/btm2.tlog"); btm.setDisableJmx(true); PoolingDataSource ds = new PoolingDataSource(); ds.setUniqueName(dsName); ds.setClassName(dsClass); ds.setAllowLocalTransactions(true); ds.setShareTransactionConnections(true); ds.setLocalAutoCommit("false"); ds.setMaxPoolSize(10); ds.getDriverProperties().putAll(dsProperties); dataSources.put(dsName, ds); }