OpenEJB/TomEE custom DataSource JTA integration

OpenEJB and TomEE provide default factories for datasources allowing to define easily by configuration JTA or not datasource pooled by a configurable pool implementation (dbcp, tomcat-jdbc, bonecp…).

But sometimes it is not enough. You want to take the control of the datasource (if you want to use native driver pooling, read the config from a custom source etc…).

For non jta datasource no issue, but for JTA you need to know some internals.

To avoid it we added in OpenEJB a new factory usable as resource to let you define custom JTA datasource.

First define your datasource as you want. For instance:

<Resource id="myDs"
   url = ...
   anotherAttribute = ...

Then wrap it using new JTADataSourceWrapperFacory:

<Resource id="myJTADataSource"
   Delegate = myDs 

Then simply use myJTADataSource instead of myDs in your application (jpa, @Resource…)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s