Search in sources :

Example 1 with RecoverableDataSource

use of org.apache.aries.transaction.jdbc.RecoverableDataSource in project aries by apache.

the class ManagedDataSourceFactory method register.

public void register() throws Exception {
    boolean isXaDataSource = (dataSource instanceof XADataSource);
    Hashtable<String, Object> props = new Hashtable<String, Object>(this.properties);
    props.put("aries.managed", "true");
    if (isXaDataSource) {
        props.put("aries.xa.aware", "true");
    }
    props.put("jmx.objectname", "org.apache.aries.transaction:type=jdbc,name=" + getResourceName());
    props.put(Constants.SERVICE_RANKING, getInt(Constants.SERVICE_RANKING, 0) + 1000);
    ds = new RecoverableDataSource();
    ds.setDataSource(dataSource);
    ds.setExceptionSorter(getString("aries.xa.exceptionSorter", "all"));
    ds.setUsername(getString("aries.xa.username", null));
    ds.setPassword(getString("aries.xa.password", null));
    ds.setTransactionManager(transactionManager);
    ds.setAllConnectionsEquals(getBool("aries.xa.allConnectionsEquals", true));
    ds.setConnectionMaxIdleMinutes(getInt("aries.xa.connectionMadIdleMinutes", 15));
    ds.setConnectionMaxWaitMilliseconds(getInt("aries.xa.connectionMaxWaitMilliseconds", 5000));
    ds.setPartitionStrategy(getString("aries.xa.partitionStrategy", null));
    ds.setPooling(getBool("aries.xa.pooling", true));
    ds.setPoolMaxSize(getInt("aries.xa.poolMaxSize", 10));
    ds.setPoolMinSize(getInt("aries.xa.poolMinSize", 0));
    ds.setValidateOnMatch(getBool("aries.xa.validateOnMatch", true));
    ds.setBackgroundValidation(getBool("aries.xa.backgroundValidation", false));
    ds.setBackgroundValidationMilliseconds(getInt("aries.xa.backgroundValidationMilliseconds", 600000));
    ds.setTransaction(getString("aries.xa.transaction", isXaDataSource ? "xa" : "local"));
    ds.setName(getResourceName());
    ds.start();
    BundleContext context = reference.getBundle().getBundleContext();
    registration = context.registerService(DataSource.class, ds, props);
}
Also used : RecoverableDataSource(org.apache.aries.transaction.jdbc.RecoverableDataSource) XADataSource(javax.sql.XADataSource) Hashtable(java.util.Hashtable) BundleContext(org.osgi.framework.BundleContext) RecoverableDataSource(org.apache.aries.transaction.jdbc.RecoverableDataSource) CommonDataSource(javax.sql.CommonDataSource) DataSource(javax.sql.DataSource) XADataSource(javax.sql.XADataSource)

Aggregations

Hashtable (java.util.Hashtable)1 CommonDataSource (javax.sql.CommonDataSource)1 DataSource (javax.sql.DataSource)1 XADataSource (javax.sql.XADataSource)1 RecoverableDataSource (org.apache.aries.transaction.jdbc.RecoverableDataSource)1 BundleContext (org.osgi.framework.BundleContext)1