Questions tagged [spring-aop]

Spring AOP is the Spring Framework's version of AOP, implemented in pure Java and using the @AspectJ annotations from the AspectJ project. Spring AOP works through dynamic JDK or CGLib Proxies.

Spring AOP is explained in the

Spring 3.0.x Online Reference > 7. Aspect Oriented Programming with Spring

Note that there is an increasing tendency to replace Spring AOP with static AspectJ compilation. This Approach is explained in Section: 7.8 Using AspectJ with Spring applications

AspectJ in Action is an excellent reference for both Spring AOP and AspectJ

The pre-3.0 XML-based Spring AOP approach is explained in Appendix B. Classic Spring AOP Usage

2584 questions
440
votes
6 answers

Spring - @Transactional - What happens in background?

I want to know what actually happens when you annotate a method with @Transactional? Of course, I know that Spring will wrap that method in a Transaction. But, I have the following doubts: I heard that Spring creates a proxy class? Can someone…
peakit
  • 28,597
  • 27
  • 63
  • 80
197
votes
9 answers

Spring @Transaction method call by the method within the same class, does not work?

I am new to Spring Transaction. Something that I found really odd, probably I did understand this properly. I wanted to have a transactional around method level and I have a caller method within the same class and it seems like it does not like…
Mike
  • 1,981
  • 2
  • 12
  • 4
192
votes
8 answers

Spring AOP vs AspectJ

I am under the impression that Spring AOP is best used for application specific tasks such as security, logging, transactions, etc. as it uses custom Java5 annotations as a framework. However, AspectJ seems to be more friendly design-patterns wise.…
zotherstupidguy
  • 2,976
  • 10
  • 39
  • 59
156
votes
10 answers

@AspectJ pointcut for all methods of a class with specific annotation

I want to monitor all public methods of all Classes with specified annotation (say @Monitor) (note: Annotation is at class level). What could be a possible pointcut for this? Note: I am using @AspectJ style Spring AOP.
Rejeev Divakaran
  • 4,384
  • 7
  • 36
  • 36
117
votes
6 answers

How to get a method's annotation value from a ProceedingJoinPoint?

I have below annotation. MyAnnotation.java @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation { } SomeAspect.java public class SomeAspect{ @Around("execution(public * *(..)) &&…
user755806
  • 6,565
  • 27
  • 106
  • 153
107
votes
18 answers

Spring AOP: What's the difference between JoinPoint and PointCut?

I'm learning Aspect Oriented Programming concepts and Spring AOP. I'm failing to understand the difference between a Pointcut and a Joinpoint - both of them seem to be the same for me. A Pointcut is where you apply your advice and a Joinpoint is…
Saurabh Patil
  • 4,170
  • 4
  • 32
  • 33
78
votes
16 answers

Spring AOP not working for method call inside another method

There are two methods defined in ABC.java public void method1(){ ......... method2(); ........... } public void method2(){ ............... ............... } I want to have AOP on call of method2.So, I created one…
Anand
  • 20,708
  • 48
  • 131
  • 198
59
votes
2 answers

Getting the java.lang.reflect.Method from a ProceedingJoinPoint?

The question is short and simple: Is there a way to get the Method object from an apsectj ProceedingJoinPoint? Currently I am doing Class[] parameterTypes = new Class[joinPoint.getArgs().length]; Object[] args = joinPoint.getArgs(); for(int i=0;…
Erik
  • 11,944
  • 18
  • 87
  • 126
48
votes
9 answers

Performance impact of using aop

We have started to use spring aop for cross cutting aspects of our application (security & caching at the moment). My manager worries about the performance impact of this technology although he fully understands the benefits. My question, did you…
LiorH
  • 18,524
  • 17
  • 70
  • 98
45
votes
3 answers

annotation equivalent of

I am moving from an xml config to annoations. i want to convert a session scoped bean that is can this be done with annotations, and if not, what can i do to still keep that declaration working? edit: I am interested in doing…
mkoryak
  • 57,086
  • 61
  • 201
  • 257
39
votes
2 answers

How to enable with java-based annotations

I am trying to set up Spring AOP without any XML. I'd like to enable in a class which is annotated with @Configuration. This is the way it would be defined in an XML-file:
user1374907
  • 391
  • 1
  • 3
  • 3
38
votes
10 answers

Spring autowired bean for @Aspect aspect is null

I have the following spring configuration:
mogronalol
  • 2,946
  • 8
  • 38
  • 56
38
votes
5 answers

Spring AOP - why do i need aspectjweaver?

i wrote a very simple Aspect with Spring AOP. It works, but i have some problems understanding what is really going on. I don't understand why i have to add the aspectjweaver.jar? The Spring-AOP documentation clearly states that i don't need aspectj…
Mario B
  • 2,102
  • 2
  • 29
  • 41
37
votes
10 answers

Spring autowiring using @Configurable

I'm playing with the idea of using Spring @Configurable and @Autowire to inject DAOs into domain objects so that they do not need direct knowledge of the persistence layer. I'm trying to follow…
optilude
  • 3,538
  • 3
  • 22
  • 25
35
votes
5 answers

Using a request scoped bean outside of an actual web request

I have a web application that has a Spring Integration logic running with it in a separated thread. The problem is that at some point my Spring Integration logic tries to use a request scoped bean and then i get the following errors: Caused by:…
Diego Urenia
  • 1,620
  • 2
  • 21
  • 28
1
2 3
99 100