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-issuemaster opened this Issue Jun 21, 2006 · 3 comments

Comments

Projects
None yet
1 participant
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster 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:

  • #20092 @target PointCut causes unrelated beans to be proxied
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jul 24, 2006

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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jul 24, 2006

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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jun 26, 2009

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