Transactional OSGi applications done right<br />				    & Karl Pauls<br />Clement Escoffier      		, akquinet<br />
Outline<br />Transactions ???<br />OSGi Transaction Service (RFC-98)<br />Transaction & Dynamism …<br />From “Hell” to the...
Transactions ???<br />Transactions are a mechanism that allows endowing a sequence of actions with the properties of a sin...
Transactions ???<br />Properties<br />(Failure) Atomicity : the action is performed either entirely or not at all<br />Con...
Transactions ??<br />Transaction Engine<br />commit<br />begin<br />Sequence of actions<br />rollback<br />5<br />Transact...
Why an OSGi Transaction Service ?<br />A lot of OSGi applications deals with<br />Devices<br />Database<br />Remote resour...
OSGi Transaction Service<br />Based on Java Transaction API<br />XA resources<br />Transaction-aware “critical” resources<...
OSGi Transaction Service<br />ServiceReferencetxRef =      bundleContext.getServiceReference(&quot;javax.transaction.UserT...
Great … but<br />9<br />Transactional OSGi applications done right<br />
Dynamism impact …<br />How to automate transaction management ?<br />What happens when a transaction “thread” accesses a s...
The “EJB dream”<br />Avoid the developer to manage transactions manually<br />Transaction demarcation:method<br />Transact...
iPOJO Transaction Supports<br />iPOJO Transaction handler<br />Automates transaction management<br />Allows using transact...
iPOJO Transaction and dynamism<br />How to automate transaction management ?<br />The transaction management is made by th...
Conclusion<br />Transactions are becoming more and more important inside OSGi applications<br />The Transaction Service is...
Questions ?<br />Transactional OSGi applications done right<br />15<br />Karl Paulskarl.pauls@akquinet.de<br />Bülowstraße...
Upcoming SlideShare
Loading in …5
×

Transactional OSGi Applications Done Right

8,175 views
7,956 views

Published on

The new OSGi R4.2 specification introduces a transaction service. This paves the road to new types of applications dealing with critical resources in a transactional manner. However, despite useful or even required, transactions are often difficult to handle manually, especially in a dynamic environment like OSGi.

This talk presents the new transaction service and how to use it in dynamic environments. To help developers using transactions in a good way, iPOJO hides the most part of transaction management allowing the developer to focus on his business code without worrying about transactions. This talk presents iPOJO transaction support and more specifically:
* How developers can declare transactions as simple as with EJB and
* How the dynamism impact on transactions can be made transparent.

Attendees will learn how to use the new transaction service through a simple example and see how iPOJO transaction support can be used to integrate transactions into business logic in a transparent way.

Published in: Technology, Business
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
8,175
On SlideShare
0
From Embeds
0
Number of Embeds
2,137
Actions
Shares
0
Downloads
2
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide
  • Pretty important for all concurrent system dealing with critical and shared resources (database, devices … )
  • Atomicity : all or nothingConsistency : the system goes from a consistent state to another consistent stateIsolation : the transaction execution is not impacted by any other “Threads”Durability: once completed, can no more be altered
  • Transaction are generally attached to a Thread
  • Transactional OSGi Applications Done Right

    1. 1. Transactional OSGi applications done right<br /> & Karl Pauls<br />Clement Escoffier , akquinet<br />
    2. 2. Outline<br />Transactions ???<br />OSGi Transaction Service (RFC-98)<br />Transaction & Dynamism …<br />From “Hell” to the “EJB3-paradise”<br />2<br />Transactional OSGi applications done right<br />
    3. 3. Transactions ???<br />Transactions are a mechanism that allows endowing a sequence of actions with the properties of a single atomic (indivisible) action.<br />3<br />Transactional OSGi applications done right<br />
    4. 4. Transactions ???<br />Properties<br />(Failure) Atomicity : the action is performed either entirely or not at all<br />Consistency : from a consistent state to another consistent state<br />Isolation: no intermediate states are visible to any concurrently executing action.<br />Durability: after a transaction has committed, the changes that it made are immune to failures (catastrophes excluded).<br />Transactions are a mechanism that allows endowing a sequence of actions with the properties of a single atomic (indivisible) action.<br />4<br />Transactional OSGi applications done right<br />
    5. 5. Transactions ??<br />Transaction Engine<br />commit<br />begin<br />Sequence of actions<br />rollback<br />5<br />Transactional OSGi applications done right<br />Uses<br />Resources<br />
    6. 6. Why an OSGi Transaction Service ?<br />A lot of OSGi applications deals with<br />Devices<br />Database<br />Remote resources and services<br />=&gt; Need transactions to ensure the system consistency<br />6<br />Transactional OSGi applications done right<br />
    7. 7. OSGi Transaction Service<br />Based on Java Transaction API<br />XA resources<br />Transaction-aware “critical” resources<br />JTA common interfaces are provided as OSGi services<br />User Transaction: programmatic transactions<br />Transaction Synchronization Registry: used by server components such as persistence managers to register synchronization object<br />Transaction Manager: allows the server to control transaction boundaries on behalf of the application being managed. <br />7<br />Transactional OSGi applications done right<br />
    8. 8. OSGi Transaction Service<br />ServiceReferencetxRef = bundleContext.getServiceReference(&quot;javax.transaction.UserTransaction&quot;); <br />UserTransactiontx = (UserTransaction)bundleContext.getService(txRef); <br /> // begin transaction <br />tx.begin(); <br /> // perform some operations in the context of the transaction <br /> try { <br /> // Create a transactional resource <br />ConfigResourceconfig = ...; <br /> // Perform some transactional work <br /> Configuration x = config.createConfiguration(&quot;abc&quot;); <br />tx.commit(); // make changes persistent <br /> } catch (Throwableth) { <br />tx.rollback(); // rollback changes. <br /> } <br />8<br />Transactional OSGi applications done right<br />
    9. 9. Great … but<br />9<br />Transactional OSGi applications done right<br />
    10. 10. Dynamism impact …<br />How to automate transaction management ?<br />What happens when a transaction “thread” accesses a service leaving before the end of the transaction ?<br />How to support dynamism with XA resources and volatile resources ?<br />The OSGi Transaction service provides everything to go further ! <br />10<br />Transactional OSGi applications done right<br />
    11. 11. The “EJB dream”<br />Avoid the developer to manage transactions manually<br />Transaction demarcation:method<br />Transactional method declares the transaction propagation<br />REQUIRED, REQUIRES_NEW, SUPPORTS, NOT_SUPPORTED, MANDATORY, NEVER<br />The transaction management is made by the container<br />@TransactionAttribute(REQUIRES_NEW)<br /> public void firstMethod() {...}<br /> @TransactionAttribute(REQUIRED)<br /> public void secondMethod() {...}<br />11<br />Transactional OSGi applications done right<br />
    12. 12. iPOJO Transaction Supports<br />iPOJO Transaction handler<br />Automates transaction management<br />Allows using transaction just like with EJB<br />@Transaction<br />public class MyClass {<br /> @Requires<br /> public FooServicefoo;<br /> @Transactionnal(propagation=&quot;requiresnew&quot;)<br /> public void firstMethod () {<br />// ...<br />foo.foo(); // Invoke a service<br />//...<br /> }<br /> @Transactionnal (propagation=“required”)<br /> public void secondMethod() {...}<br /> // …<br /> }<br />12<br />Transactional OSGi applications done right<br />
    13. 13. iPOJO Transaction and dynamism<br />How to automate transaction management ?<br />The transaction management is made by the container<br />Flexible <br />Allows injecting the current Transaction inside a field<br />Can notify the POJO of the current transaction progress<br />What happens when a transaction “thread” accesses a service leaving before the end of the transaction ?<br />The transaction is roll backed as soon as an instance becomes invalid<br />How to support dynamism inside XA resources and volatile resources ? <br />The Transactional Service Providing handler emulates XA Resources or Volatile resources<br />Experimental…<br />13<br />Transactional OSGi applications done right<br />
    14. 14. Conclusion<br />Transactions are becoming more and more important inside OSGi applications<br />The Transaction Service is definitely Welcome<br />THANKS !<br />However, we’ve to take care to avoid the Transaction Nightmare<br />iPOJO proposes EJB-like transaction management reducing the pain !<br />14<br />Transactional OSGi applications done right<br />
    15. 15. Questions ?<br />Transactional OSGi applications done right<br />15<br />Karl Paulskarl.pauls@akquinet.de<br />Bülowstraße 66, 10783 Berlin+49 151 226 49 845<br />Dr. Clement Escoffierclement.escoffier@akquinet.de<br />Bülowstraße 66, 10783 Berlin+49 175 246 77 17<br />

    ×