Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] pointcut does not match private static method

The pointcut doesn't match the static method execution because of this component:

        && this(DAOCenterContainer);    

which matches a join point if (there is an object bound to 'this' and) the object bound to 'this' is an instance of DAOCenterContainer.
For a static method execution join point, there is no object bound to this and so the pointcut does not match. 

Try using this variation instead:

    pointcut TRANSACTIONAL(Transactional transactionalAnnotation):
        execution(@Transactional * DAOCenterContainer+.*(..))
        && @annotation(transactionalAnnotation);

which will match based on the types in which the executing operations are defined (DAOCenterContainer or any subtype thereof) rather than on runtime types.


On 3 Nov 2006, at 09:57, Jimisola Laursen wrote:


(this might trivial, but I am not AspectJ guru - yet)

Hi!

I have a problem with the following pointcut 


    pointcut TRANSACTIONAL(Transactional transactionalAnnotation):
        execution(@Transactional *
se.stickybit.licensetracker.server..*(..))
        && @annotation(transactionalAnnotation)
        && this(DAOCenterContainer);    

only matching public non-static methods under
"se.stickybit.licensetracker.server..*".

The following method e.g. is not matched when it is private static

    @Transactional(level = TRANSACTION_LEVEL.READ_COMMITTED)
    private static void checkLicense(final DAOCenter daoCenter) throws
InvalidLicenseException


if I change it to public void checkLicense then it matches.

Doesn't pointcut match non-static methods per default?

I want my around advice to handle all methods regardless of "member" access
and static/non-static.
Do I need to have two pointcuts? And apply the advice on both?

I tried:

    pointcut TRANSACTIONAL(Transactional transactionalAnnotation):
        execution(@Transactional private static *
se.stickybit.licensetracker.server..*(..))
        && @annotation(transactionalAnnotation)
        && this(DAOCenterContainer);    

without any luck.


Regards,
Jimisola

PS. Is there a IRC channel for aspectj? I looked around and couldn't find
one. I think it would be very useful for the community.  DS.

-- 
Sent from the AspectJ - users mailing list archive at Nabble.com.

_______________________________________________
aspectj-users mailing list


Back to the top