Roberto Perillo wrote:Howdy, Kurt!
My confusion is there're many logic to select a proper concrete factory method , whose parameters are different from other's. In this case , do I still need write such factory?
Well champ, it's sort of hard to say, but, since you are using Spring, have you considered using dependency injection? You can provide the class that implements the SuccessChecker in an XML file and arrange the objects there... this way, you wouldn't have to write the factory.
Mark Spritzler wrote:If your classes have interfaces and implement them. Them Spring will create DynamicProxies. No need for cglib in that scenario.
Mark Spritzler wrote:Here is your best solution.
1) Create your own Annotations and then annotate all the methods you want advised.
then write your pointcut expression to match the annotation.
"execution(@com.myapp.annotations.MyAnnotation * *(..))"
Now any method that is annotated with @MyAnnotation will match that pointcut expression. No more need of 100 pointcut expressions.
Here is my definition of that annotation
Bang Nguyen wrote:
Kurt Xu wrote:Hi, I think you should change greetingServiceTarget's singleton to true, or just not set the attribute ,cause it is true by default.
Hi, it will not work. Moreover, this is not what we intended to do. Because just imagine the greetingServiceTarget is some JavaBean in our domain such as Student, Class, Course. From that, we can see that those objects must not be singleton. Otherwise, they will store dirty data from the same object type.
When we imagine this greetingServiceTarget as Student, Class Objects; we can see that sometimes we want to lock some specific services of these objects. That's the intention of this example.
Anyway, thanks for your contribution! Please give more suggestions so we can study!
Mark Spritzler wrote:That's what AOP is all about adding code to your code through Aspects and Advices.
Shashank Ag wrote:Well some byte code manuplation apis are availble like Javassist.
But, I am still interested why AOP will not work in your case.
Have you really read the concept? Don't mind its just I am big fan of spring AOP.
Mark Spritzler wrote:Actually, you can with Spring AOP.
It is called Introductions, and here is a link to the docs that shows how to do this