So I've just started using DI and spring4d since a few days ago.
And I learned that the consumer classes should not aware of the DI container. But what if the consumer class needs to create service instances dynamically? For example, to create new service instances for each new thread?
I figured out I should resort to the Factory pattern, on which the consumer classes can depend and ask it to create new service instances for them.
So I search all across the Internet for Spring4D related staff, using keywords such as 'IFactory', 'AsFacory', 'TFunc<...>', And so on, finally I land on the
DynamicAbstractFactory example. Bingo! That's exactly what I wanted and my initial experiment showed that it works.
After knowing how to do it I then trying to figure out why it works, but unfortunately that example has no comment and I couldn't find any info.
So I guess the Spring4D framework creates the so-called dynamic proxies for implementing the 'Abstract Factories'. Am I right? I guess so.
And here comes the real question - Is there any limit on the number of parameters the constructor of the class being made by the factory? Thanks.