-
Dec 18th, 2008, 03:55 PM
#1
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
-
Dec 19th, 2008, 01:17 AM
#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
-
Dec 19th, 2008, 08:39 AM
#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.
-
Dec 19th, 2008, 10:41 AM
#4
I do not think any one would disagree with those arguments, but the simplicity of @Transactional comes with this cost.
-
Dec 19th, 2008, 12:03 PM
#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.
-
Dec 19th, 2008, 12:15 PM
#6
Use XML. No coupling. No new code need be written.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules