1 2 Previous Next 23 Replies Latest reply on Dec 13, 2013 10:15 AM by Michael Musgrove

    Additions to the transaction SPI

    Michael Musgrove Master

      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) and a DataSource manager factory for obtaining a DataSource Manager.

      The interface to obtain a transaction service accepts a parameter to configure the environment that the transaction service will run it.


      The transaction service is for starting a transaction (returning javax.transaction.Transaction for controlling its' subsequent life cycle);


      The DataSource Manager instance returned by the DataSource manager factory contains a pair of methods:

      • one to register a resource (transactional driver relies on JNDI);
      • the other to obtain a DataSource (that has been previously 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


      Message was edited by: Michael Musgrove Updated to incorporate changes requested by Tom

        1 2 Previous Next