Aries JPA supports two ways of defining data sources in persistence.xml files. One is to define a jndi name. Here aries jndi is used to retrieve a DataSource that is defined as an OSGi service. In this case we currently check if the DataSource is an XADataSource. If yes then we wrap it into a DataSource that auto enlists itself as an XA resource. The other way is to define the javax.persistence.jdbc.driver property. In this case we search for a suitable DataSourceFactory. The we use createXADataSource if jta is supported and wrap it like above.

I think this wrapping should not be part of aries jpa. Instead people should either already publish a DataSource that does the XA handing internally or use a DataSourceFactory that does that same.
Both cases are now nicely supported by pax jdbc.
See https://ops4j1.jira.com/wiki/display/PAXJDBC/Pooling+and+XA+support+for+DataSourceFactory

Another reason to remove the wrapping is that we only cover the enlisting of the XAResource. Our code explicitly states that we do not support pooling or error handling in our XADataSource wrapping. So out approach probably can not be used in production anyway.

So I propose we remove the wrapping code in aries jpa. If someone supplies an XADataSource via jndi we can simply throw an exception and explain that we expect an already wrapped DataSource. For the DataSourceFactory case we can simply always call the createDataSource method instead of the XA one and again expect that people supply a DataSourceFactory that does the wrapping.

I would be interested in your feedback about this. Especially if I overlooked something and we should keep the wrapping.

Christian




--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to