Daniel Kulp wrote:
Can you just use the lazy-init="true" stuff built into spring?

<bean id="accountService" lazy-init="true"
   class="my.web.service.AccountService"
       factory-bean="accountProxyFactory" factory-method="create"/>

That would work if the application code gets the proxy from the spring context by name using getBean(), but if the proxy is injected into another bean by spring then it won't make much difference - it'll still have to be initialized before it can be injected. But this might help:

http://johnheintz.blogspot.com/2007/11/using-lazy-proxy-to-avoid-spring.html

The LazyProxyFactoryBean shown in this post basically allows you to wrap up another Spring bean with a proxy that shows the same interface, but delays asking for the "real" bean until the first method call. Using this in combination with the lazy-init=true trick above should do what you're after.

Ian

--
Ian Roberts               | Department of Computer Science
[EMAIL PROTECTED]  | University of Sheffield, UK

Reply via email to