Class DataSourceResource

java.lang.Object
com.zfabrik.resources.provider.Resource
com.zfabrik.impl.db.data.DataSourceResource

public class DataSourceResource extends Resource
Implementation of component type javax.sql.DataSource. This implementation supports a pooled data source implementation that integrates with Z2's unit of work mechanism (see WorkUnit).

A component of type javax.sql.DataSource can be configured in various ways, controlled by the following parameters:

ds.type
This can be either ZFabrikPoolingDataSource or NativeDataSource. In the first case, the data source will be pooled using PoolingDataSource. In that case the pool configuration parameters in PoolingDataSource should be applied
ds.dataSourceClass
If set, the specified data source class will be loaded as data source implementation using the private class loader of the Java module of the component holding the data source definition. When specifying this class in conjunction with the ds.type=ZFabrikPoolingDataSource configuration properties will be applied to both and the pool will request new connections from the specified data source. Alternatively, the pool may be configured to use a driver class. See PoolingDataSource for more details.
ds.dataSourceJNDIName
If ds.dataSourceClass is not set, this JNDI name will be tried to lookup a data source that will serve as connection provider. During lookup the thread context class loader will be set to the private class loader of the Java module of the component holding the data source definition. When specifying this class in conjunction with the ds.type=ZFabrikPoolingDataSource configuration properties will be applied to both and the pool will request new connections from the specified data source. Alternatively, the pool may be configured to use a driver class. See PoolingDataSource for more details.
ds.enlist
This can be either workUnit, jta, or none.

If set to workUnit, connections will be enlisted with the WorkUnit and only committed, rolled back, or closed when the unit of work was completed. Transparently this integrates with Z2's pseudo-distributed JTA implementation. Please check the Wiki at for more information. If no WorkUnit is currently active, a non-enlisted connection will be returned.

If set to jta connections will be enlisted with the WorkUnit as above but removed after commit or rollback. This prevents, that a connection will be visible for longer than a transaction and it will instead be reinitialized with the pool before it is provided again. If no JTA transaction is currently active, a non-enlisted connection will be returned. This prevents that any non-transactional code may effect connection state (in particular such as auto commit settings) for transactional connections.

If set to none connections will not be enlisted but simply handed out from the data source.

It is recommended to use jta.

ds.prop.abc
Attempts to set the bean property abc on the data source (and on PoolingDataSource, if used). A setter method setAbc will be used for that. The property ds.propType.abc defines the signature required.
ds.propType.abc
Defines the type of a configuration property as in ds.prop.abc. Can be any of int,string, or boolean. Defaults to string.