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
0
votes
0 answers

AspectJ pointcut expression to target service methods invoked from a specific class

I'm using AspectJ with Spring to add logging to my application. I have an @Aspect class with an advice method that I want to trigger only for service methods invoked from a specific class. However, I'm having trouble constructing the correct…
0
votes
2 answers

Is it possible to auto-detect an aspect from a custom lib/dependency without @Import and/or @ComponentScan?

I have the following scenario: A lib project made with Spring Boot and Spring AOP, aspect code goes here; A main project that will import my lib as a dependency, it's also a Spring Boot project. I'll like to know if it's possible for my main…
HienaKill
  • 101
  • 2
  • 10
0
votes
1 answer

Duplicate check for spring cloud stream consumers

I want to check for duplicate messages in my Spring Cloud Stream Kafka consumers. This is what I have now: @Component public class MessageSubscriber { @Autowired MessageConsumer messageConsumer; public Consumer>…
0
votes
0 answers

How to implement this logic

Implement Before advice ONLY for addMoneyToWallet() method of Service Impl class. Log the current date and time in the console at INFO level using logger variable. Add annotations to make bean for Aspect class and write pointcut expression.…
0
votes
1 answer

Spring jdbc with aop transaction configuration not committing

I am using Spring 3.0.6 in Tomcat 6 with JDK 1.6. I have configured Spring JDBC with declarative transaction using the Spring reference. I see following in the log for my delete query but after the execution the record does not get deleted. Any idea…
Sharad Yadav
  • 2,951
  • 5
  • 20
  • 18
0
votes
1 answer

AOP Pointcut expression for methods belonging to classes in various subpackages

Context: I am running a Spring service that deals with interaction with external partners and vendors. I'm implementing a monitoring aspect to keep track of the QPS as well as other performance metrics for each of these external APIs. They are…
jun
  • 192
  • 15
0
votes
1 answer

How to intercept nested method call with same annotation configured using Spring AOP or AspectJ?

I have configured multiple database following this link https://fable.sh/blog/splitting-read-and-write-operations-in-spring-boot/. DB call is routed based on the Transactional annotation value. Call to DB is happening correctly till we try to make a…
Harsh Kanakhara
  • 909
  • 4
  • 13
  • 38
0
votes
1 answer

Spring AOP with Spring Webflux after authentication

I have a Enabled Spring AOP for my logging purpose and use webflux for the API entrypoint, things work fine if the api does not go through ReactiveAuthenticationManager like my login api but the moment It has to go through…
Akash Jain
  • 684
  • 9
  • 23
0
votes
0 answers

Configuring Hibernate session methods with Spring AOP

I have a java EE , spring application that uses Hibernate 3. I want to calculate the execution time of queries, so I am trying to intercept hibernation session and query methods to calculate the execution time. I have added spring-aop and…
0
votes
1 answer

How to intercept meta annotations (annotated annotations) in Spring AOP.In other words, how to use aspectj syntax to match meta-annotation on method

This problem has been solved partly before,The question I asked builds on the answer to this question reference: How to intercept meta annotations (annotated annotations) in Spring AOP related codes above package de.scrum_master.app; import static…
White
  • 1
  • 2
0
votes
0 answers

how to record the actual api response body after exception handling

Say I have a Spring RestController with several endpoints. Also I place a @RestControllerAdvice with some @ExceptionHandler to management all the exceptions to return in a uniform error message formate: ``` { "code": 1234567, "errMsg":…
rellocs wood
  • 1,381
  • 4
  • 21
  • 36
0
votes
1 answer

spring Aspect return and Controller method return, i don't understand

1. Controller @Controller public class myViewController{ @RequestMapping("myMainPage") public void myMainPage(Model model){ model.addAttribute("logoImg", "site_logo.png"); } } 2. Aspect @Around("execution(*…
gf160
  • 21
  • 1
  • 2
0
votes
1 answer

Custom Method Security Expression Evaluator for Spring Boot 3 Webflux Application

I'd like to use method security annotations and a custom expression evaluator in my Spring Boot 3 Webflux application, and I'm not sure how to do it. My endpoint with its method security annotation looks like…
0
votes
0 answers

Spring data mongodb and lazy loading proxy

With Spring data mongodb I have a couple of entities Person and Dog. Linked with DBRef, but pet property in Person can have multiple implementations and can be linked to different collections. @Document public class Person { @Id private String…
0
votes
1 answer

@within did not execute in spring-aop

As per my understanding, @within would execute if an annotation is at the class level so as per that understanding below snippet should run the @within block. example6 but my output did not print @within advice values. why?
LowCool
  • 1,187
  • 5
  • 25
  • 51