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

AspectJ @Transactional aspect uses runtime checks [SPR-8890] #13531

Closed
spring-projects-issues opened this issue Dec 1, 2011 · 2 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Dale Peakall opened SPR-8890 and commented

The AspectJ support for the @Transactional annotation uses pointcuts that include "runtime" conditions. These conditions mean that every method on every object processed by AspectJ will be weaved with code that checks for the presence of the annotation at runtime. This is hugely inefficient. The pointcuts can be rewritten so AspectJ only weaves code into the classes that have actually been annotated.

private pointcut executionOfAnyPublicMethodInAtTransactionalType() :
  execution(public * ((@Transactional *)+).*(..)) && @this(Transactional);

private pointcut executionOfTransactionalMethod() :
  execution(* *(..)) && @annotation(Transactional);
private pointcut executionOfAnyPublicMethodInAtTransactionalType() :
  execution(public * ((@Transactional *)+).*(..)) && within(Transactional);

private pointcut executionOfTransactionalMethod() :
  execution(@Transactional * *(..));

Affects: 3.1 RC2

Referenced from: commits f74789f, 5ab2bf1, 3a62aa0, a347e4d

@spring-projects-issues
Copy link
Collaborator Author

Dale Peakall commented

The Fixed version for the first pointcut should be ... && within(@Transactional)

@spring-projects-issues
Copy link
Collaborator Author

Dale Peakall commented

Even simpler: execution(* *(..)) && within(@Validate *);

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.1 GA milestone Jan 11, 2019
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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants