Journal FortKnox's Journal: [Java] Pointcuts and Advisors... 5
The project I'm architecting is using EJB3 with Hibernate3 and spring2. Been loads of fun, as I was permitted to use Java5[1], so I'm annotating the crap out of stuff (Adding "@Transactional" above a method with all the params instead of in the app-context.xml is not only convient, but makes for easier reading of code!).
Today I needed an interceptor, but you can't have an annotated driven transaction manager with interceptors, so I had to do a quick AOP learning session, and made a pointcut and advisor to do my dirty work.
The interceptor will intercept any service call and catches the hibernate exceptions, wrapping them into a nice version of the exception. Unfortunately, due to all the if-then-else, I'm tempted to make a visitor pattern, but it'll be a pain in the rear to have to imp each type of exception visit for every service.... I'll have to figure out a better way...
Anyway, the whole aspect thang I can see as extremely powerful. Being able to register in interceptors to deal with the before and after happenings of methods. But I also can see a lot of developers seriously shooting themselves in the foot with that type of behavior. Anyone else done any type of AOP?
[1]: As for the other features of 5 that I've used? Generics are essential and make life so easy. For-each loops, though, I've not had much success with. There are too many times you want to check a 'iterator.hasNext()' which isn't available with for-each loops...
Today I needed an interceptor, but you can't have an annotated driven transaction manager with interceptors, so I had to do a quick AOP learning session, and made a pointcut and advisor to do my dirty work.
The interceptor will intercept any service call and catches the hibernate exceptions, wrapping them into a nice version of the exception. Unfortunately, due to all the if-then-else, I'm tempted to make a visitor pattern, but it'll be a pain in the rear to have to imp each type of exception visit for every service.... I'll have to figure out a better way...
Anyway, the whole aspect thang I can see as extremely powerful. Being able to register in interceptors to deal with the before and after happenings of methods. But I also can see a lot of developers seriously shooting themselves in the foot with that type of behavior. Anyone else done any type of AOP?
[1]: As for the other features of 5 that I've used? Generics are essential and make life so easy. For-each loops, though, I've not had much success with. There are too many times you want to check a 'iterator.hasNext()' which isn't available with for-each loops...
I have no idea what you just wrote (Score:1)
/Can't believe it took java this long to get enumerations
Re: (Score:2)
Re: (Score:1)
'cept that I don't understand ; )
/If you want, I could rattle on about abstract tagged limited private types
//But that's no fun for anyone
You speak my language (Score:2)
jason
Two points (Score:1)
Second: I need your email address! You led me onto this linkedin thingy but it won't let me bug you without an email address, apparently AIM addresses don't do! Drop me a line at devlin.bentley@gmail.com or com2kid@gmail.com or com2kid on any IM network or com2kid at just about anything else