3

Currently i am using cache abstraction using proxy. Problem with proxy is that internal method calls don't work . Now, I want to use the compile time weaving instead of proxy as internal method calls works it. I have searched on google, but i didn't find any substantial link which explains how to use compile time weaving. There are many links for load time weaving. Can anyone give any example for compile time weaving with cache abstraction or some relevant link ??

Thanks in Advance.

cooldude
  • 935
  • 2
  • 9
  • 18

1 Answers1

1

You could add the spring aspect for caching using the maven aspectj plugin, by identifying the aspect class and applying it manually to the classes you want (check inside spring-aspects and spring-cache jars for the aspect).

This mechanism is not directly linked to spring, it could be done with any aspect, not only spring aspects.

The reason why it's not used is that it's not very convenient, because we need to know the classes we want to advise at compile time and cannot rely on spring annotation scanning mechanism.

Load time weaving solves the problem you mention of making reentrant calls work in a more transparent way, without the inconveniences of compile time weaving. Load time weaving is the recommended way spring has put in place for using aspectJ weaving, enabled by annotation @EnableLoadTimeWeaving.

For the concrete use case that you mentioned, there does not seem to be a good case to introduce compile-time weaving, in general there is no good use case for compile time weaving, which explains the lack of documentation available online.

I believe your best option for the use case you mention would be to use load time weaving instead.

Angular University
  • 42,341
  • 15
  • 74
  • 81
  • I am building an API. It has lots of data to returned in response. On average about 200KB. will the load time weaving affect the performance of the API?? – cooldude Apr 13 '14 at 18:32
  • no I don't think it will affect performance, the Load time weaving mechanism will selectively advise only the spring classes that need certain aspects, most of the time the `@Service` and `@Repository` classes only. This will happen only once per service/repository class at server startup time , and then the aspects will be in place and you won't notice any difference in performance – Angular University Apr 13 '14 at 18:36