I’m developing an Advice and I want to make it advise only on field sets in specific methods. I tried cflow(pointcutForSpecificMethod()) && set(* *) pointcut expression but it picks field sets in other methods under control flow of specific methods. Any idea? Answer This is not possible directly…
Tag: aspectj
Implementation of AspectJ example not working
I’m try to implement a simple AspectJ annotation example from https://www.baeldung.com/aspectj. The difference is, that I want to use the annotation at a JUnit TestClass. I googled a while for the solution but don’t find the right hint. Part of my pom.xml My Annotation: My Aspect: The Advice is me…
How does the double-dot “..” syntax work in AspectJ?
i need to put this aop aspect to work, but i always get error 404, i need to know if this dots, after controller is right. idk how these dots works, to acess the controller. if can explain how the dots works. Answer would mean – the execution of any method defined in the com.teste1.teste2.web.controller…
Spring is trying to subclass a record component when aop is present
I have a spring boot application in which I make use of aspects. Recently, I tried converting my @ConfigurationProperties classes to java records, but it fails with “Cannot subclass final class {..}Properties”. It seems spring is trying to make cglib proxies for my records, which obviously fail. I…
Spring AOP and AspectJ on same method
I have a question about using aspectJ and spring aop method intercepting. I created 2 annotations: @AJTest and @SAOPTest. registered it and other and register it and added it to my method in controller Application class but when i call it by http://localhost:8080/test?firstParam=test&secondParam=2 i can&#…
How to force AspectJ search from test directory in src directory of project using compile weaving?
Actually, it will be more complex question. I want use AspectJ only in test purpose. Have found suggestion to use if() JointPoint and some static boolean field. Also, first I start using aspect as inner static class of my base test method. After some experiments I replaced it to own class, but actually don’t …
Not able to rollback DB changes in Aspect in Spring boot application
I have written one aspect around a service class. In the aspect, I am doing some operation in the before section, which I would like to be rolled back if some exception occurs in the enclosed service method. The service class is as follows: The aspect is as follows: I am seeing an exception in the service met…
Spring AOP @Pointcut and @Before yields IllegalArgumentException: error at ::0 formal unbound in pointcut
I am doing a springboot project that includes login and accounts. I am trying to @Pointcut all controller method calls and validate the login information, and @Before the pointcut to make sure the session exists. Hence the code: However, this yields org.springframework.beans.factory.BeanCreationException: Err…
How to extract telemetry code from different methods? Decorator pattern? AOP?
We are using Application Insights to monitor different service calls in our applications. Data for Application Insights is provided by many different methods and classes but always in an identical way/by identical code fragments: How am I able to extract those wrapping try catch fragments to one point of resp…
Issues in serializing API request argument in Spring boot application
I have written one aspect to serialize the request arguments for APIs in Spring boot application, in DB as follows: The above code snippet is failing if we get HttpServletRequest/ByteStream as a request argument. For example, for byte stream I am getting following exceptions: For the request type of HttpServl…