[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ews.eclipse.technology.aspectj] Re: AspectJ: around() advice for setName() in derived class

The execution() pointcut designator takes a *declared* signature. You have no method declared in B called setName(). Change the pointcut to:

pointcut setter (B b): execution(public void setName(*)) &&
  target (b);

Andy.


Aaron Digulla wrote:
Hello,

I have two classes:

class A {
 private String name;
 public void setName (String name) { this.name = name; }
}

class B extends A;

I want to create an advice which allows me to "fix" the name before it
is passed into setName() by calling a method validateName() (this is
defined in the advice).

This works.

Now, I want to create a second advice which does the same with a
*different* validateName() method for B.

I tried

	pointcut setter (B b): execution(public void B.setName(*)) && target (b);
	
	void around(B obj, String newValue) :
		setter (obj) && args (newValue) { ... }

but the around advice is not applied to anything. What's wrong?

Regards,