Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

[Java] Pointcuts and Advisors...

FortKnox (169099) writes | more than 7 years ago

User Journal 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 pointcuThe 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...

cancel ×

5 comments

I have no idea what you just wrote (1)

mekkab (133181) | more than 7 years ago | (#17300772)

And what's sad is that just 3 years ago I was migrating from our proprietary middle ware to using JMS queues and publishes, and fitting in some database ejbs to handle transactions with our computational software.

/Can't believe it took java this long to get enumerations

Re:I have no idea what you just wrote (1)

FortKnox (169099) | more than 7 years ago | (#17301474)

Sorry... working so much that its tough to get my mind out into a JE and for it to be coherent. I'll probably try again on my vacation. Was just happy to get AOP advisors working in spring... just made my own annotation (which was mindlessly easy to do). Its rare for me to be in charge of the new tech and getting things working, and, I have to say, its incredibly fun!

Re:I have no idea what you just wrote (1)

mekkab (133181) | more than 7 years ago | (#17301608)

And that's absolutely fine... infact, this SHOULD be an apropriate place where you can brain dump things you've figured out and share those "eureka!" moments with people who understand...

'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 (1)

robi2106 (464558) | more than 7 years ago | (#17317876)

I am in the process of an almost identical development environment. Been learning about annotations this week. I'm workign on adding javadocs to all our new java5 goodness. Fun stuff. Confusing, but fun.

jason

Two points (1)

Com2Kid (142006) | more than 7 years ago | (#17333090)

Java5 rocks, sorry you didn't get to use it sooner. Now that I am used to Generics, using previous versions of Java is painful.

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 .com :) (Actually I no longer check my 4 or 5 other com2kid@yyyyy.com addresses, so use gmail! :) )
Check for New Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...