Search code examples
javaspringaspectjargspointcut

Can I use my own object in args when using Aspectj?


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?


Solution

  • 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() {}