0

Currently I am reading some documentation about Quarkus in which they are constantly attacking a lot about DynamicProxy mechanism of Spring for Dependency Injection.

I am quoting

"Spring creates an implementation proxy for the interface and any additional method declarations a developer adds to the interface. The definition of additional methods within the interface, including the method name, return type, and method arguments, are extremely important: They influence the implementation of the proxy that dynamically creates. This runtime proxying contributes to longer startup times and increased memory usage".

I don't know Spring AOT with Spring Boot 3.x / Spring 6.x does anything against it, but if I remember correctly from old times, it was possible to do Dependency Injection in Spring with AspectJ Load Time Weaving.

Only documentations I can find about it at the moment, are using aspectj , Using AspectJ to dependency inject domain objects with Spring and aop, specially the second link is really old, from Spring 3.0.0-RC3 and the first link contains really similar information.

So my question is, 'is still possible with Spring Boot 3.x / Spring 6.x do dependency injection with the help of the AspectJ'?

I do the Bean configurations with '@Configuration' and '@Bean' annotation in Spring Boot so I never used the @Configurable and of course if I am looking for startup time improvement for Spring Boot application, Load Time Weaving is no go but if I can convert it to compile time weaving, I think I can close the performance gap to Quarkus little bit more while Spring's DynamicProxy / CGlib proxying will always happen in runtime and if Spring didn't change anything in the AOT for it, it will always be disadvantage for Spring.

So are these technics still usable in Spring Boot 3.x / Spring 6.x or those are obsolete.

posthumecaver
  • 1,584
  • 4
  • 16
  • 29
  • 1
    Dependency injection has nothing to do with proxies, proxies are only created to add dynamic behavior like transactions, logging, security. – M. Deinum Jun 23 '23 at 13:03

1 Answers1

-1

In current Spring versions, with or without Boot, you still have the same options as before. I.e., you can still use Spring AOP (proxy based) versus native AspectJ via load-time or compile-time weaving:

Spring AOP manual

I do not want to be unkind, but I cannot help but wonder how you can be a programmer if you cannot even navigate the well-arranged Spring manual you already posted as the first link. Maybe next time, just give it a minute to sink in and try to get your bearings when opening a manual.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Well insulting, instead of actually answering, really nice, as you so nicely commented, I already discovered that pages, as you can see from my post these pages are word by word same as the Spring 3.0.0-RC1 documentation, considering how much Spring changed from 3.x to 6.x, it would be surprising nothing changed for weaving, if nothing changed, you could just say nothing changed, instead of starting personal insults. Documentation feels like nobody cared about AspectJ weaving since Spring 3.x release. – posthumecaver Jun 27 '23 at 06:54
  • I did **not** insult you, and I did answer. I took the trouble to post all the up-to-date links corresponding to your outdated ones, described them and even posted a screenshot with highlights to help you navigate the manual, utilising table of contents and breadcrumb navigation. That I openly said how surprised I was that you did not see that, even though **all** the links you asked for are visible without even scrolling the page you found, is not an insult but a describing a fact. – kriegaex Jun 27 '23 at 10:19
  • Besides, revenge downvotes are not nice. Did you notice that, despite my criticism, I did **not** downvote your question but instead chose to criticise but simultansously answer it? If you cannot accept justified criticism, maybe don't post under-researched questions on a platform like this one. – kriegaex Jun 27 '23 at 10:20