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

@target() advices beans it should not [SPR-2168] #6859

Closed
spring-projects-issues opened this issue Jun 21, 2006 · 3 comments
Closed

@target() advices beans it should not [SPR-2168] #6859

spring-projects-issues opened this issue Jun 21, 2006 · 3 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 21, 2006

Mike Youngstrom opened SPR-2168 and commented

I have an aspect with a pointcut:

@Around("@target(org.lds.stack.spring.serviceproxy.ServiceProxy)")

I'm using aop:aspectj-autoproxy/ and a bean with the target class org.springframework.orm.jpa.JpaTemplate is getting proxied.

If I remove the pointcut then my JpaTemplate not longer gets proxied.

Mike


Affects: 2.0 M5

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Adrian Colyer commented

Consider a class C, the pointcut target(org.xyz.SomeInterface), and the execution join point for some method in C.

When AspectJ evaluates whether or not the pointcut can match such a join point, it says "maybe". The reason is that someone may later introduce a new type

class D extends C implements SomeInterface { ... }

and if the method declared in C executes for an instance of D, then the join point should be matched.

However... in Spring, we know the exact type of the bean, and there is no chance that a subtype will be introduced later on. Therefore, we should optimize matching in this case, so that we don't create proxies that will never actually have any work to do at runtime.

The one caveat to this is the declare parents construct, which can introduce additional interfaces to a bean. We need to ensure that this() and target() pcds still continue to match on interfaces that are introduced via a declare parents construct.

@spring-projects-issues
Copy link
Collaborator Author

Adrian Colyer commented

Fix committed to head. I had to add an "IntroductionAwareMethodMatcher" to take into account declare parents constructs. The solution is somewhat ugly because it needs some information not available in the public AspectJ tools API. AspectJ enhancement request 151593 has been raised to cover this, and the Spring solution can be improved once AspectJ provides the needed public API.

@spring-projects-issues
Copy link
Collaborator Author

Andres Rodriguez commented

Hi,

This issue is marked as resolved but I still find it in 2.5.6SEC01
Thanks,

Andres

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant