java - spring 如何管理原型(prototype) bean 的完整生命周期?

标签 java spring prototype javabeans lifecycle

spring如何管理原型(prototype)bean的生命周期?如果不是调用原型(prototype)bean的destroy方法?

最佳答案

原型(prototype) bean 在后台使用原型(prototype)模式:

Prototype pattern allows us to hide the complexity of making new instances from the client. The concept is to copy an existing object rather than creating a new instance from scratch, something that may include costly operations. The existing object acts as a prototype and contains the state of the object. The newly copied object may change same properties only if required. This approach saves costly resources and time, especially when the object creation is a heavy process.

除了应用程序管理的上下文对象使用 AOP 之外,它们还包装在代理对象中。在原型(prototype)作用域 bean 的情况下,底层方面将 bean 的创建委托(delegate)给此模式的基于 spring 的实现。

关于java - spring 如何管理原型(prototype) bean 的完整生命周期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56806600/

相关文章:

java - 遍历 hastable 键的枚举会引发 NoSuchElementException 错误

java - 在这种情况下,中间流和终端流方法如何工作

Java线程内存计算

perl - 如何在没有 "called too early to check prototype"的情况下声明函数并递归使用它

java - 动态添加 Primefaces 组件

spring boot 2.7.0 不公开 http.server.request 指标

java - PayPal - Spring - 无效的 HTTP 方法 : PATCH

java - 如何使用java在mysql的枚举类型列中插入两个以上的值?

javascript - 什么时候使用 "prototype"这个词来为 javascript 中的对象添加新属性?

javascript - Object.create 设置 __proto__ 但不是原型(prototype)