Hi to everybody,
I am new to Spring. Right now I am trying to determine the best way to use it.
What I want to achive is the following:
1. Every class I have will have a bean factory (ApplicationContext or BeanFactory, doesn't matter, let's keep the discussion abstract). I am not saying that I will create a new factory for each class – I may have one factory for all, layers or indeed a factory for each class.
When each class tries to get its own factory I need to determine if I should create a new factory or use a parent one. The parent may contain the beans that are used by most of the classes (for example logger definition, some common text resources, like YES/NO button text) and each class may have some special bean which may be needed only by such class or by its children.
I see that ApplicationContext and BeanFactory have definition for parent, but in order to use the parent I have to know the parent. I need to supply it in the configuration somehow. And somehow I need to know if I have the configuration for the given class. If I have no configuration file the parent must be used (which in turn also may not have the configuration), if I do have a file it must be used.
The second problem with the ApplicationContext and BeanFactory that if I possibly have one of those for each class I have they will use too much resource. Will they??
2. When I create a bean from bean factory I will need to provide certain dynamic information (example getLogger(<class name>) factory method has to receive a name of the class that calls it, I can’t configure it for each class – I will need to create a bean definition for each class this way). I need something like getBean(id, Object <constructor pareameters>)
Thank you for your thoughts,
I hope that I didn't ask stupid questions