Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Method pattern to match method execution in super class

Hello Andy

I'll try to give a full example after my vacation... ;-)


Best regards,
James

2011/11/3 Andy Clement <andrew.clement@xxxxxxxxx>
Hi,

I had a little trouble with your program as the types aren't quite complete:

> public abstract class AbstractBaseRepository<T> {
>   Iterable<T> findAll();
> }

findAll needs to be abstract there I presume? I then had to implement
it in FooRepository to keep things happy:

       public Iterable<Foo> findAll() {
               return null;
       }

As soon as I added this method I found the pointcut matched on it.

Can you maybe give me a complete project that exhibits the problem?

> I now want to match calls to findAll of IFooRepository and use this
> _expression_:
> execution(* com.example.IFooRepository.findAll(..))

Do you mean you want to match calls? or do you mean you want to match that
method executing?  That is an execution() pointcut.  If you really wanted to
match calls you'd use call().

Anyway, as I say, seeing a complete example that doesn't work would help me.

Are you in AJDT with those types? did you try a full clean build, did that make
a difference?

When i track the join point signatures used for matching, I see this:

actual joinpoint: java.lang.Iterable com.example.FooRepository.findAll()
computed joinpoint signatures for that joinpoint:
 java.lang.Iterable com.example.FooRepository.findAll()
 java.lang.Iterable<com.example.Foo> com.example.IFooRepository.findAll()

The second one matches so we stop immediately.

cheers
Andy

On 3 November 2011 06:47, Jean-Pierre Bergamin <jpbergamin@xxxxxxxxx> wrote:
> Hello everyone
> I'm fighting with spring security and aspectj joinpoints and have no idea
> why our joinpoint declaration does not match.
> We have the following class and interface structure:
> 8<-----------------------------
> public interface ILookupRepository<T> {
>    Iterable<T> findAll();
> }
> public interface IBaseRepository<T> extends ILookupRepository<T> { }
> public abstract class AbstractBaseRepository<T> {
>   Iterable<T> findAll();
> }
> public interface IFooRepository extends IBaseRepository<Foo> { }
> public class FooRepository extends AbstractBaseRepository<Foo> implements
> IFooRepository { }
> 8<-----------------------------
> I now want to match calls to findAll of IFooRepository and use this
> _expression_:
> execution(* com.example.IFooRepository.findAll(..))
> This pattern does not match when calling
> IFooRepository repo = ...
> repo.findAll();
> The signatures that are found and compared against in
> SignaturePattern.matches are the following:
> Iterable
> net.junisphere.eranger.domain.internal.neo4j.repositories.AbstractBaseRepository.findAll()
> Iterable<IBaseEntity> com.example.IBaseRepository<IBaseEntity>.findAll()
> Iterable<IBaseEntity> com.example.ILookupRepository<IBaseEntity>.findAll()
> Iterable com.example.ILookupRepository<IBaseEntity>.findAll()
> Iterable<net.junisphere.eranger.domain.model.IBaseEntity>
> com.example.ILookupRepository<IBaseEntity>.findAll()
> Iterable com.example.ILookupRepository<IBaseEntity>.findAll()
>
> Any ideas why the IFooRepository is not taken into account, but only
> IBaseRepository and ILookupRepository?
>
> Best regards,
> James
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top