[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Pointcut not being executed...

the call (and execute) pointcuts take a declared method signature.

call(* javax.persistence.EntityManager.persist(trc.suivi.domain.Pli))

doesn't look right to me.  I'm sure the EntityManager.persist() method
is not declared to take a 'trc.suivi.domain.Pli' (although that is
what might be getting passed at runtime).

You want something more like:

call(* javax.persistence.EntityManager.persist(*) && args(trc.suivi.domain.Pli)

args() is a runtime check on the argument to confirm what type it is.
(I only used '*' in the persist() signature as I don't know what
persist() really takes)

and if you want to bind it in the pointcut declaration, you want
something more like this:

pointcut catchIt(Pli pli): call(*
javax.persistence.EntityManager.persist(*) && args(pli);

cheers,
Andy


On 2 August 2012 08:44, Julien Martin <balteo@xxxxxxxxx> wrote:
> Hello,
>
> I mean to intercept only calls of EntityManager.persist when the argument is
> of type trc.suivi.domain.Pli
>
> I have tried the following code:
>
> pointcut catchIt(Pli pli) : (call(*
> javax.persistence.EntityManager.persist(trc.suivi.domain.Pli)));
> after(Pli pli) returning: catchIt(pli) {
> log.debug("catchIt");
> Evenement ev = new Evenement();
> ev.setDateCreation(new Date());
> ev.setIdObjetProprietaire(pli.getId());
> evenementRepository.save(ev);
> }
>
> and nothing happens.
>
> Can anyone please help?
>
> Regards,
>
> J.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>