Is there a spring lazy proxy factory in Spring?

At Wicket, this device is called the lazy proxy factory. Given:

<property name="foo" ref="beanx"/> 

the idea is to automatically generate proxies instead of "beanx", and then initialize beanx only when and when something actually calls a method on it.

It seems like it could be the core of Spring. Is it somewhere out there?

+3
source share
3 answers

See LazyInitTargetSource ; what can do what you want. It also requires the use of lazy-init = "true" in the target bean.

+3
source

Spring singleton beans that are closest to what you want are created when the spring context is initialized: http://static.springsource.org/spring/docs/2.0.x/reference/beans.html#beans-factory-scopes . Therefore, I think the short answer is no. You can implement your own scope to do this by extending the spring classes quite easily.

0
source

Spring session / request scope is implemented using the method you described, but is intended only to handle transitions between power capacities, rather than creating an instance. So spring uses the same concepts, but you probably have to create your own implementation.

0
source

Source: https://habr.com/ru/post/901431/


All Articles