What is BeanFactory?
In core packages of Spring org.springframework.beans.factory there is an interface named BeanFactory that can be implemented in various ways.It represents a generic factory that enables objects to be retrieved by name and which can manage relationships between objects.A BeanFactory contains different beans definitions which can be instantiated whenever a client wishes to do so , it is, hence, associated with life cycle of bean instances.
Bean factories support two modes of object:
-Singleton : a single,uniquely named, shared instance of an object which will be retrieved on lookup. It is the default, and most often used. It's ideal for stateless service objects.
-Prototype or non-singleton: each retrieval results in an independent object creation.It could be used in stateful service objects scenarios where each caller has its own independent object.
The most commonly used bean factory objects are:
-XmlBeanFactory which parses a simple XML structure defining classes and properties of named objects.The DTD is provided to make authoring easier.
-DefaultListableBeanFactory parses bean definitions in properties files, and create BeanFactories programmatically.
Bean factories support two modes of object:
-Singleton : a single,uniquely named, shared instance of an object which will be retrieved on lookup. It is the default, and most often used. It's ideal for stateless service objects.
-Prototype or non-singleton: each retrieval results in an independent object creation.It could be used in stateful service objects scenarios where each caller has its own independent object.
The most commonly used bean factory objects are:
-XmlBeanFactory which parses a simple XML structure defining classes and properties of named objects.The DTD is provided to make authoring easier.
-DefaultListableBeanFactory parses bean definitions in properties files, and create BeanFactories programmatically.