Hi,
Strictly speaking, this may not be a coldspring issue, but it seemed like the best place to ask.
I use CS to manage all my singleton objects, and it also manages a Reactor factory which creates most of my transient objects.
However, now I need to create other transient objects which will perform a form of validation. I'll call the objects AssignmentChecker, and each instance will need to be created and configured differently depending on the circumstances.
I reckon the best way to do this is to build a custom AssignmentCheckerFactory, however, I've never built a custom factory before.
Should it be as simple as a single function that creates the AssignmentChecker object, sets stuff according to the function arguments, and returns it? That sounds way too obvious J
If CS manages the factory, will CS be injected into the transient objects too? Or do I need to set this up? Or should I avoid injecting CS unless needed?
Any advice would be appreciated.
Thanks,
Gareth
Sent from my Verizon Wireless BlackBerry
Thanks folks.
I've just been getting my head around the beanInjector example in the coldspring utils. That's very clever how it works.
At the moment, I don't think my transient objects will need access to any other beans, so I'll keep it simple for now. If they need beans in the future, I'll either get the factory to set them or use the beanInjector.
What is likely to happen, is that I cache AssignmentChecker objects in the factory to improve performance. I suppose by keeping their creation within the factory, caching should be easier to implement
What you would do well to avoid is to have your factory talk to coldspring. The factory should not know coldspring exists at all. Any design that has a transient factory with knowledge of the coldspring bean factory is upside down and needs to be rethought on the aspects of encapsulation and information hiding.
Sent from my Verizon Wireless BlackBerry