tags:

views:

756

answers:

1

I'm using Spring framework (2.5) and it's AOP features. I've a pointcut expression, like

@Pointcut("execution(public * org.springframework.batch.item.ItemReader+.read(..))")
public void itemReaderMethods() {}

Where the ItemReader interface is a Spring interface and it's signature is:

org.springframework.batch.item.ItemReader<T>

The interface has a method named as 'read' for which I want to apply the advise: the method signature is:

org.springframework.batch.item.ItemReader.read()

But, when I run my application with the above pointcut expression, I'm getting the below exception:

java.lang.IllegalArgumentException: warning no match for this type name: org.springframework.batch.item.ItemReader [Xlint:invalidAbsoluteTypeName]

My guess is that, since ItemReader is a generic interface, the pointcut is not matching properly. If that is the case, how can I write my pointcut expression to match the generic interfaces also?

+1  A: 

Generics don't seem to be a problem for me - I can create a test pointcut on Map operations:

@Around(value="execution(* java.util.Map.size(..))")

I didn't need to use Map+ either (I assume that is because we're using interfaces), and the generic nature of Map didn't matter either.

Are you sure that the ItemReader interface class is available and that you have implementations available? That's what the error message suggests (and which I can get if I put a dummy class name in my test pointcut). Maybe try logging/printing

Class.forName("org.springframework.batch.item.ItemReader")

and similarly for your expected implementation class?

paulcm