Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is load-time weaving?

Tags:

java

spring

aop

I am using load-time weaving for a spring (2.5.x) project but I don't know what it is the purpose of it in general. I tried little googling but didn't find the upcoming pages useful. The only thing I understood is that it is something about AOP.

I noticed that it is used for older spring versions also wondering why is that?

like image 962
hevi Avatar asked Jun 24 '14 12:06

hevi


People also ask

What is run time weaving?

Run-time weaving At run-time, an aspect weaver could translate aspects in a more efficient manner than traditional, static weaving approaches. Using AspectJ on a Java Virtual Machine, dynamic weaving of aspects at run-time has been shown to improve code performance by 26%.

What is compile time weaving?

Compile-time weaving is the simplest approach. When you have the source code for an application, ajc will compile from source and produce woven class files as output. The invocation of the weaver is integral to the ajc compilation process. The aspects themselves may be in source or binary form.

What is Aspectjrt?

AspectJ is an aspect-oriented programming (AOP) extension created at PARC for the Java programming language. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated into Eclipse.

What is weaving in spring?

Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.


1 Answers

Weaving is an AOP concept and it is the phase of integrating the aspects with the targeted code. After weaving, aspects are applied to the original code.

This process can take place in different times like compile and load. This article explains the different weaving times and LTW of AspectJ.

It says about LTW:

Load-time weaving (LTW) is simply binary weaving defered until the point that a class loader loads a class file and defines the class to the JVM.

like image 130
ovunccetin Avatar answered Oct 26 '22 10:10

ovunccetin