2

I have entity class like this:

package tr.com.example.model.porting
...//omitting imports

    @Configurable
    @Data
    @Entity
    public class PortOut{

      public void handleRequest(Long portingId) {
          processRequest(portingId);
           ...
        }
     }

And here is my aspect code in different class annotated with @Aspect and @Component:

 @Around("execution(* tr.com.example..PortOut.handleRequest(..))")
    public void handlePortingProcessAdvice(ProceedingJoinPoint joinPoint) throws Throwable {

        joinPoint.proceed();
        log.debug(log.debug("[POM]:{} is executed with parameters:{}", joinPoint.toShortString(), joinPoint.getArgs()))
    }

Normally, my aspect code works fine for other Spring managed classes such as using @Service, @Component annotation. I am using https://github.com/subes/invesdwin-instrument as a weaving agent and also using Lombok.

I tried this link(along with other so posts). But since I am using Lombok, I cannot directy compile with aspectj compiler for weaving @Configurable classes, it doesn't work with Lombok as I found out. https://groups.google.com/forum/#!topic/project-lombok/ZkLsTZVSgD4

Shortly, what I want is using aspectj for logging some methods's arguments, but I can't use it in any Hibernate entity class, other than that it works fine. How to get it working in entity classes?

sarah
  • 580
  • 1
  • 6
  • 24

1 Answers1

2

Here you find the explanation why Lombok and AspectJ do not like each other.

What is said to work though, is to delombok the Lombok-annotated source code and then normally compile the generated source code with the AspectJ compiler (e.g. via AspectJ Maven plugin, which is what I use all the time in Maven projects). Assuming you do use Maven, also the delombok step can be done with Lombok Maven plugin. If you assign the right phases to the respective plugins, it should be possible to fully automate the build process.

Disclaimer: I have never used Lombok in my whole life, but know a thing or two about AspectJ and Maven.

kriegaex
  • 63,017
  • 15
  • 111
  • 202