什么是“编织”?

发布于 2024-09-12 03:31:50 字数 422 浏览 3 评论 0原文

我在阅读有关 Spring 如何工作的文章时看到了这个术语,并且刚刚阅读了有关 JPA 实现性能的文章,它有以下统计数据:

EclipseLink                                                           3215 ms
(Run-time weaver - Spring ReflectiveLoadTimeWeaver weaver  )
EclipseLink (Build-time weaving)                                      3571 ms
EclipseLink (No weaving)                                              3996 ms

那么,有人可以用简单的英语解释一下什么是编织吗? ?

谢谢!

I've seen this term when read about how Spring works and I've just read the article about JPA implementation performance and it has the next statistics:

EclipseLink                                                           3215 ms
(Run-time weaver - Spring ReflectiveLoadTimeWeaver weaver  )
EclipseLink (Build-time weaving)                                      3571 ms
EclipseLink (No weaving)                                              3996 ms

So, could someone explain in plain English, what is weaving?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

箜明 2024-09-19 03:31:50

编织是通过直接修改现有的 .class(字节码)文件来生成或编辑代码。
这可能发生在应用程序生命周期的不同点。

  1. JVM 之外
    在编译时
    打包时
  2. 在 JVM 内
    在类加载时。
    加载一个类后。

Spring 框架使用它来实现 AOP 功能。 Eclipselink 使用编织进行延迟加载或更改跟踪。

编织在 AOP 概念< Spring 文档的 /a> 部分

Weaving is generating or editing code by directly modifying existing .class (byte-code) files.
This can occur at different points in the application life cycle.

  1. Outside of JVM
    at compile time
    at packaging time
  2. Inside a JVM
    at class load time.
    after a class has been loaded.

Spring Framework uses this for AOP functionality. Eclipselink uses weaving for lazy loading or change tracking.

Weaving described in AOP Concepts section of Spring Documentation

╰ゝ天使的微笑 2024-09-19 03:31:50

此处

在 Spring AOP 中,可以模块化和分离日志记录、事务等服务,并将它们以声明方式应用于组件,因此程序员可以专注于特定的关注点。方面以 JavaBean 的方式连接到 Spring XML 文件中的对象中。这个过程称为“编织”。

From here:

In Spring AOP makes it possible to modularize and separate logging, transaction like services and apply them declaratively to the components Hence programmer can focus on specific concerns. Aspects are wired into objects in the spring XML file in the way as JavaBean. This process is known as 'Weaving'.

迷途知返 2024-09-19 03:31:50

简而言之,我们可以说

编织是将建议应用到目标对象的过程
在给定的切入点处获取代理对象。

In nutshell, we could say

Weaving is the process of applying the Advices to the Target objects
at given pointcuts to get the Proxy Objects.

年少掌心 2024-09-19 03:31:50

我发现这个描述很有用:

Weaving:这是将方面插入应用程序代码的过程
适当的点。对于编译时AOP解决方案,通常会完成这种编织
在构建时。同样,对于运行时AOP解决方案,执行编织过程
在运行时动态地[使用 JDK 动态代理和 CGLIB 代理]。 AspectJ 支持另一种称为 load- 的编织机制
时间编织(LTW),它拦截底层 JVM 类加载器并
当类加载器加载字节码时,提供对字节码的编织。

参考:Pro Spring 5:Spring 框架及其工具的深入指南

I‌ found this description useful:

Weaving: This is the process of inserting aspects into the application code at the
appropriate point. For compile-time AOP solutions, this weaving is generally done
at build time. Likewise, for runtime AOP solutions, the weaving process is executed
dynamically at runtime [using JDK‌ dynamic proxy and CGLIB proxy]. AspectJ supports another weaving mechanism called load-
time weaving (LTW), in which it intercepts the underlying JVM class loader and
provides weaving to the bytecode when it is being loaded by the class loader.

reference: Pro Spring 5: An In-Depth Guide to the Spring Framework and Its Tools

梦幻之岛 2024-09-19 03:31:50

开发的面向对象的软件系统
使用面向方面的编程技术
由类和方面组成。类实现
应用程序的主要功能,
例如,管理库存或计算
保险费率。另一方面,方面则捕捉
技术问题,例如持久性、故障处理、
通信,或进程同步。

类和方面有两种方式
可以编织:静态或动态。

静态编织意味着通过在以下位置插入特定于方面的语句来修改类的源代码:
加入点。在其他
单词:方面代码内联到类中。这
结果是高度优化的编织代码,其执行
速度与编写的代码相当
不使用方面。

Object-oriented software systems that are developed
using aspect-oriented programming techniques
consist of classes and aspects. Classes implement
the primary functionality of an application,
for example, managing stocks or calculating
insurance rates. Aspects, on the other hand, capture
technical concerns like persistence, failure handling,
communication, or process synchronization.

There are two ways in which classes and aspects
can be woven: static or dynamic.

Static weaving means to modify the source code of a class by inserting aspect-speci c statements at
join points.In other
words: aspect code is inlined into classes. The
result is highly optimized woven code, whose execution
speed is comparable to that of code written
without using aspects.

冷情 2024-09-19 03:31:50

编织是一种操作已编译 Java 类的字节码的技术。

参考: http://www.eclipse.org/eclipselink/documentation/ 2.5/concepts/app_dev007.htm

干杯!

Weaving is a technique of manipulating the byte-code of compiled Java classes.

Ref: http://www.eclipse.org/eclipselink/documentation/2.5/concepts/app_dev007.htm

Cheers!

云柯 2024-09-19 03:31:50

编织是将方面与其他应用程序类型或对象链接起来以创建建议对象的过程。编织可以在编译时、加载时或运行时完成。 Spring AOP 在运行时执行编织。

Weaving is the process of linking aspect with other application types or objects to create an advised object. Weaving can be done at compile time, load time or runtime. Spring AOP performs weaving at runtime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文