[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: RES: [aspectj-users] AspectJ with Servlets on Tomcat 5.x

I've copied aspectjrt.jar inside WEB-INF/lib directory but, it doesn't work. Mmm, There is something that I don't unserstand. If I implement an aspect with an pointcut that captures all methods sets*(int) of a class and I introduce an before type advise, AspectJ introduces my /before advise code/ before of all sets*(int) methods of my class. So, that is, if I have main method in my project -->

public static void main (String[] args) {
 MyClass o = new MyClass();
 o.setName("hello");
}

public aspect LogAspect {
 pointcut sets (MyClass c) : call(* MyClass.set*(int)) && target(c);

 before (MyClass c) : sets(c) {
   System.out.println("byby");
 }
}

So, AspectJ weaver introduces -->

public static void main (String[] args) {
 MyClass o = new MyClass();
 *LogAspect.aspectOf().ajc$before$LogAspect ....*
 o.setName("hello");
}

So, AspectJ introduces a call of my /before advice/.
but, How on earth AspectJ can introduce this code in a web application? Web applications have not main procedures. I don't know, I unserstand nothing.