Announcement Announcement Module
Collapse
No announcement yet.
Using my own @Transactional annotations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using my own @Transactional annotations

    Hi-

    I'm looking for the simplest means to use Spring's transaction management with annotations, but I need to use my own annotations. (I don't want to import Spring anntotations into my business classes).

    I see that I implement TransactionAnnotationParser, but I don't see where I can plug in my strategy so that it is used?

    Can anybody give me a tip?

    Thanks,
    Adam

  • #2
    Unless you have a Really good reason no to use spring annotations, my suggestion is simply to use @Transactional which will relieve you from much pain.

    If you have good reasons not to use @Transactional, please post the here.
    You can of course always use xml configuration.

    /johan

    Comment


    • #3
      I really prefer to keep my business classes separate from 3rd party dependencies. If I use @Transactional, then I won't be able to compile my code without Spring in the classpath. Also, if Spring ever chooses to deprecate or change @Transactional, my code will break. Finally, I might want to add some additional attributes to my @Transactional annotation.

      But you are probably correct, it might not be worth the effort of rolling my own annotation support.

      Comment


      • #4
        I do not think any one would disagree with those arguments, but the simplicity of @Transactional comes with this cost.

        Comment


        • #5
          I looked into this a while ago, but never did it. From what I learned, it looked like you would have to create your own aspect, which specifies the annotation being used. The aspect source is available, so you can check it out if you want. Depending on how much functionality you need, you might have to copy several aspects and support classes.

          I arrived at the same conclusion others did -- having the annotation isn't a big deal. I don't even think you need to distribute Spring with your classes if the annotation isn't being used. And since it's only an annotation, it doesn't affect the testability of your code.

          Comment


          • #6
            Use XML. No coupling. No new code need be written.

            Comment

            Working...
            X