1

I'm new with AspectJ and I tried to do this:

public class MyDBDAO {
    public boolean update(MyObject myObject) {}
}

And Aspect:

@Aspect
@Component
public class AspectJClass {
   @Pointcut("execution(* com.myclass.MyDBDAO.update()) && args(myObject)")
    public void update(MyObject myObject) {}
 }

Should I only use Absoulute Type? Are there any ways to solve this problem?

ellen
  • 13
  • 4

1 Answers1

0

have you tried this ?

@Pointcut("execution(void com.myclass.MyDBDAO.update(MyObject)) && args(myObject)")
public void update(MyObject myObject) {}

if you want poincut to all of the methods in the class you can do this :

@Pointcut("this(com.myclass.MyDBDAO)")
public void isMyDBDAO() {}
Yair Harel
  • 441
  • 3
  • 10
  • Thnanks for answer! I tried the first one. But I got this message. Caused by: java.lang.IllegalArgumentException: warning no match for this type name: MyObject [Xlint:invalidAbsoluteTypeName] at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:195) at – ellen Feb 17 '16 at 13:59
  • I have just closely re-read your exception and you need to specify the full path of the class MyObject for example com.myclass.MyObject inside the pointcut. you didn't post your advice but note that an advice that advices this pointcut must also have MyObject as parameter – Yair Harel Feb 17 '16 at 20:37
  • Thanks!! I finally solved the problem. I wrote pointcut like this. @Pointcut("execution(void com.myclass.MyDBDAO.update(com.model.MyObject)) && args(myObject)") public void update(MyObject myObject) {} – ellen Feb 18 '16 at 01:59