Transactional File System in Java – commons transaction

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Transactional File System in Java – commons transaction - Presentation Transcript

    1. Transactional File System in Java – commons transaction Albert Guo [email_address]
    2. Agenda
      • Use Case
      • Commons Transaction
      • Commons Transaction Implementation
      • Conclusion
      • Appendix
      Commons IO Commons Lang Commons Transaction
    3. Use Case
    4. Use Case Commons IO Commons Lang Commons Transaction
    5. Commons Transaction
    6. Commons Transaction
      • http://commons.apache.org/transaction/
    7. What is Commons Transaction
      • Whenever you have concurrent access to resources and want to protect them with locks, Commons Transaction can be right for you.
      • Providing lightweight, standardized, well tested and efficient implementations of utility classes commonly used in transactional Java programming.
      • The 1.x component is compatible to JDK1.2 .
    8. Commons Transaction Features
      • Commons Transaction might be useful for you when you
      • need transactional file access (i.e. ACID transactions on a set of files)
      • have resources that need locking - lock managers can do that for you:
        • be sure you never forget to release a lock again
        • let your code have a timer for a whole block of locks
        • have an out-of-the-box solution for hierarchical locks
        • plug in your own custom or advanced solutions
    9. Commons Transaction Implementation
    10. Implementation Steps
    11. 1. Initialize FileResourceManager
      • storeDir String - JavaDoc says: "directory where main data should go after commit".
      • workDir String - JavaDoc says: directory where transactions store temporary data.
      • next parameter is a boolean that indicates if the path should be URL encoded.
      • In our example it is false, indicating that we have simple path with no spaces or i18n characters in it.
      • sLogger LoggerFacade - JavaDoc says: the logger to be used by this store.
      1
    12. 2. Start FileResourceManager / 3. Start Transaction 2 3
    13. 4. Modify Resources
      • With the transaction started, you can begin file manipulation. You can perform following operations:
        • copyResource
        • createResource
        • deleteResource
        • moveResource
        • writeResource
      • In our example, we’ll demo createResource and writeResource
    14. 4. Modify Resources
    15. 5. Transaction Management
    16. Conclusion
    17. Conclusion
      • If you have to operate on files and cannot afford to loose data, seriously consider using commons-transactions package.
      • It is probably better then any custom mechanism you can come up with. It supports 2 phase commit.
      • With a little work, you could probably make it into an XA compliant resource.
    18. Appendix
    19. Appendix
        • Commons Transaction
          • Aimed at providing lightweight, standardized, well tested and efficient implementations of utility classes commonly used in transactional Java programming. Initially there were implementations for multi level locks, transactional collections and transactional file access. The 1.x component is compatible to JDK1.2.
        • Commons IO
          • Commons IO is a library of utilities to assist with developing IO functionality.
        • Commons Lang
          • The Lang Component provides a host of helper utilities for the java.lang API, notably String manipulation methods, basic numerical methods, object reflection, creation and serialization, and System properties.
        • Log4j
          • log4j is a Java-based logging utility. It was originally written by Ceki Gülcü and is now a project of the Apache Software Foundation. It is used primarily as a debugging tool.

    + Guo AlbertGuo Albert, 2 years ago

    custom

    633 views, 1 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 633
      • 633 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 15
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories