would you use springs AOP (aspects) if you had to track user points throughout your application?
it seems like a potential fit, since points are awarded etc. throughout the application, kind of like security checks.
(just reading on AOP, trying to grasp its potential and usage other than say security or loggi开发者_Go百科ng).
when you wire up your joinpoints, are they "setup" on the fly or once? I'm just concerned as to how this effects performance, or is it a non-issue really?
Yes, this sounds like a good use of AOP.
As to the specifics of how it works, that depends which AOP framework you're using. Some do the aspect weaving at compile time (e.g. AspectJ CTW), some do it when the lasses are loaded (e.g. AspectJ LTW), some do it dynamically at runtime (e.g. Spring AOP).
There is an inevitable performance impact, but don't let that stop you from giving it a go.
It might be a cross-cutting concern. It's hard to tell without knowing more about your app.
Spring AOP sets them up at runtime after the application context is established.
I think that you could use aspects to track the user points. This 'requirement' is a crosscutting concern, because it cuts your code in many points.
If you want to use aspects with Java you should use AspectJ that is the most evolved aspect extension to Java. If you want to get an introduction about aspects read the AspectJ Programming Guide
And about the join points, they usually are wired up on compilation. So, after the weaving (composition of your new behavior with the old behavior) you will have new Java code with the new behavior injected. Another good book about aspects is Eclipse-AspectJ-Aspect-Oriented-Programming-Development
i dont think I would use AOP for this. I would model the user and point, and implement the point awarding in some sort of business class. I am new to AOP as well, but how I understand it, an aspect is really something that crosscuts your program.
精彩评论