RE: [coldbox:11230] Wirebox : how to have beans lazy loaded

There’s no magic to it really. Just create a getter for the motor bean, and have the getter first check if the motor exists, if not create it and return it, if so just return it.

Of course, that means you won’t be autowiring in the motor when the car is created, instead inject an instance of the beanFactory plugin (a facade to WireBox). You’ll ask WireBox for it the first time the getter is called and store it in somewhere.




Is there a downside to injecting WireBox and doing WireBox.getInstance() instead of using the BeanFactory?