Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@within not working Spring AOP [SPR-17285] #21818

Open
spring-issuemaster opened this issue Sep 18, 2018 · 4 comments
Open

@within not working Spring AOP [SPR-17285] #21818

spring-issuemaster opened this issue Sep 18, 2018 · 4 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 18, 2018

sahil-ag opened SPR-17285 and commented

@within point-cut doesn't seem to be working when we extend a class and annotate the extended class.
This also doesn't seem to take into account the @inherited annotation

Sample project:
https://github.com/sahil-ag/Spring-AOP-Sample

Project works when we use @target but should also be working for @within


No further details from SPR-17285

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 13, 2018

sahil-ag commented

Hi
Is there any update here?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 15, 2018

Andy Clement commented

Sorry, haven't had a chance, but I will take a look at the project you attached (thanks for that!) as soon as I can.

@aclement

This comment has been minimized.

Copy link
Contributor

@aclement aclement commented Jan 15, 2019

Ok, @within, like within, is about lexical scope and what is declared at compile/weave time. @target, like target, is about dynamic scope and what is happening at runtime.

For the 3 testcases:
If the pointcuts are
( A ): @within(SampleAnnotation) || @annotation(SampleAnnotation)
( B ): @target(SampleAnnotation) || @annotation(SampleAnnotation)

  • testAnnotedMethod - Both A and B match because @annotation(SampleAnnotation) matches on the method in BaseMethod class.
  • testAnnotatedBeanExtended - B matches, A does not match. The method getTestName() is declared in BaseClass and neither that method or that type is annotated, so if that is the static state 'as declared' and so neither of these pointcut components are true in A. Now B matches dynamically because the runtime type on which the getTestName() is being called is a BaseClassExtended which is annotated.
  • testAnnotatedBean - Neither A nor B match. BaseClass nor getTestName() are annotated.

So I am saying it is working as designed. Does that help?

@sahil-ag

This comment has been minimized.

Copy link

@sahil-ag sahil-ag commented Mar 8, 2019

Correct me if I am wrong but shouldn't @within consider all the functions which are available to the class at compile time and based on how inheritance works, that function will hence be available in the lexical scope?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.