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
18
votes
2 answers

AspectJ pointcut expression match parameter annotations at any position

I'm trying to define a pointcut expression to match methods which contain a parameter annotated with a specific annotation, regardless of what position the parameter is in. In my case I'm looking for the @Constraint annotation. For example: Matching…
driangle
  • 11,601
  • 5
  • 47
  • 54
17
votes
1 answer

Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource

PROBLEM : I am creating a pointcut for execution of a method in a class . This class is a controller class and denoted by annotation @Controller and hence no bean is needed for the same which is required by the aspect. I am attaching the dispathcher…
user548656
  • 173
  • 1
  • 1
  • 5
17
votes
2 answers

Can not set field to com.sun.proxy.$Proxy

For file upload I am trying to inject and use a Validator in my Spring Controller like this: @RestController @RequestMapping("/api") public class FileController{ @Autowired private MessageSource messageSource; @Autowired …
FunnyJava
  • 446
  • 1
  • 6
  • 17
17
votes
4 answers

Is Spring @autowired not meant for non-singleton containers?

I have a MyTask class which implements Runnable and there can be many such objects instantiated at any given moment. There are certain properties that I would like to autowire into MyTask class. But I think that if I mark MyTask with @Component then…
pulkitsinghal
  • 3,855
  • 13
  • 45
  • 84
17
votes
4 answers

Spring application has Cglib2AopProxy warnings

Upon starting my application, I get numerous warnings along the lines of o.s.aop.framework.Cglib2AopProxy 'Unable to proxy method [public final void org.springframework.jdbc.core.support.JdbcDaoSupport.setDataSource(javax.sql.DataSource)] because it…
Michael Piefel
  • 18,660
  • 9
  • 81
  • 112
16
votes
4 answers

Spring 4 Join point to get method argument names and values

I am using Spring 4.3. Is it possible to get method parameter names and values passed to it? I believe this can be done using AOP (before advice) if possible could you please give me a source code.
Debopam
  • 3,198
  • 6
  • 41
  • 72
16
votes
1 answer

Spring AOP CGLIB proxy's field is null

Description Using the vlcj component, the custom component appears as a result of the AOP proxy object null. MediaList Class public class MediaList { private libvlc_media_list_t mediaListInstance; public MediaList(LibVlc libvlc,…
forDream
  • 386
  • 1
  • 6
  • 17
16
votes
2 answers

How Spring aspects work internally?

Say Service calls Dao class on which logging aspect(annotational) needs to be applied. I am wondering how aspects actually gets applied. As per my understanding at the time of DAO injection under Service object, spring finds out that there is some…
M Sach
  • 33,416
  • 76
  • 221
  • 314
16
votes
3 answers

Spring pointcut designators differences (within vs execution)

Please... can anybody explain me what are the differences between using the following spring pointcut designators? Using "within pointcut designator": Using "execution…
glazaror
  • 171
  • 1
  • 1
  • 3
16
votes
4 answers

Spring - Intercepting bean creation and injecting custom proxy

I have a @Controller with @Autowired fields and handler methods that I want to annotate with custom annotations. For example, @Controller public class MyController{ @Autowired public MyDao myDao; @RequestMapping("/home") …
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
15
votes
2 answers

Difference between @target and @within (Spring AOP)

Spring manual says: any join point (method execution only in Spring AOP) where the target object has an @Transactional annotation: @target(org.springframework.transaction.annotation .Transactional) any join point (method execution only in…
Steve Romanchuk
  • 153
  • 1
  • 1
  • 4
14
votes
1 answer

Ordering aspects with Spring AOP && MVC

I am trying to use Spring AOP with Spring MVC Controller. I have 3 aspects, and want the to be in specific order. In order to do this, I use Ordered interface and implement getOrder method: @Aspect @Component public class LoggingAspect implements…
Marat Asadurian
  • 593
  • 1
  • 6
  • 18
14
votes
6 answers

Implementing Audit Trail- Spring AOP vs.Hibernate Interceptor vs DB Trigger

I found couple of discussion threads on this- but nothing which brought a comparison of all three mechanism under one thread. So here is my question... I need to audit DB changes- insert\updates\deletes to business objects. I can think of three ways…
RN.
  • 997
  • 4
  • 14
  • 31
14
votes
8 answers

What is a good design to execute the methods based on boolean values in Database in Java?

We have few rules, which are Implemented as methods in Java. But sometimes we need to bypass the rules. So for each rule, we have a boolean Indicator to indicate whether to execute or not. What can be a good design to map the methods to boolean…
14
votes
3 answers

Transaction configuration for Spring Java configured context

I've been struggling with this for a few hours now. I'm trying to migrate my Spring XML configuration to a full Java based configuration. I'm using AnnotationConfigApplicationContext as a context implementation. I'm having trouble finding an Java…
Eugen
  • 8,523
  • 8
  • 52
  • 74