I would like to introduce a small set of classes into our SPI to facilitate embedded usage and open it up to the community for discussion.
The requirement is coming from a request from the ceylon community to integrate transactions into their SDK so my initial focus is on satisfying that requirement only. The broader discussion of cleaning up our SPI is still ongoing. But first a caveat, the SPI needs to support JDBC DataSources: in the medium term we will be using JCA but for now there are still issues to resolve around embedded IJ on ceylon so my SPI changes rely on the transactional driver which ultimately we would prefer not to support. That said the interface is phrased in terms of javax.sql.DataSource so I would hope for minor changes only when we eventually switch to JCA but to protect ourselves I have annotated it with @Deprecated.
There is transaction service factory for obtaining:
- a transaction service (there can be only one with the current narayana implementation);
- an object for managing DataSources;
- the default configuration.
The transaction service contains a pair of methods:
- one for starting a transaction (returning javax.transaction.Transaction for controlling its' subsequent life cycle);
- the other for looking up the configuration used by this instance of the transaction service
The DataSource Manager also contains a pair of methods:
- one to register a resource (transactional driver relies on JNDI);
- the other to obtain a DataSource (that has already been registered).
Apart from a couple of Exception classes that's it.
You can take a look at the proposed interface via my private git branch
The unit tests should give you a clear idea of how to use the SPI.
And there is also an example of how to use it from ceylon
This article was generated from the following discussion: Additions to the transaction SPI