[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] RE: newbie: wildcards in pointcuts

Hi,

> I want to intercept all service-method invocations on my sessionbeans
> and insert some special handling. These service-method invocations
> have the following characteristics:
> - the argument type ends with the string 'RequestSDO'. So that's
> org.myorganization.MultiplyByTwoRequestSDO for instance.
> - the return type ends with the string 'ResponseSDO'. ->
> org.myorganization.MultiplyByTwoResponseSDO
> - the method name ends in 'Service'. I don't think that should be
> necessary but I added that to make it easier. -> multiplyByTwoService


Try something like :
=======================================================================
package tavant.aspect;

public aspect MyAspect {
       pointcut myPtCt() : 
       call (public *..*ResponseSDO *..*.*Service(*..*RequestSDO));

       before() :  myPtCt() {
		System.out.println("Going To Call a Service Method");
       }
}
=======================================================================


I wrote a service class :
=======================================================================
package tavant;

public class HelloService {
    public HelloResponseSDO myService(HelloRequestSDO arg) {
	return null;
    }

    public static void main(String[] args) {
	HelloService service = new HelloService();
	service.myService(null);
	System.out.println("Done!");
    }
}

class HelloResponseSDO {
}

class HelloRequestSDO {
}
=======================================================================
and compiling both files with ajc worked for me.

Cheerio,
-- 
Binil Thomas          | binil.thomas@xxxxxxxxxx |.*.
Tavant Technologies   | Tel: +91 80 51190451    |..*
http://www.tavant.com | Fax: +91 80 5630530     |***