在此日志中捕获了默认的 bean 初始化策略:
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.Instance> setBeanName() asda
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsa, message: create()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsa, message: start()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: create()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: start()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: stop()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: destroy()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsa, message: stop()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsa, message: destroy()
在调用它的 start() 方法之后,Bean 被认为是完全初始化的。现在我想做的是同步初始化所有的bean。在所有其他 bean 完成其步骤之前,没有 bean 会继续下一个初始化步骤。生成的日志看起来像这样:
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.Instance> setBeanName() asda
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsa, message: create()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: create()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsa, message: start()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread main, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: start()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsa, message: stop()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: stop()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsa, message: destroy()
[Wed Sep 26 13:10:35 CEST 2012]: <Thread Thread-1, Class is.test.spring.ExecutableImpl> ID: fdsaa, message: destroy()
关于如何实现这一目标的任何想法?
此外,是否可以在后台线程中处理所有初始化(每个 bean 的每个生命周期步骤)?我预计初始化将非常耗时......