|AOP and IoC
BEAN FACTORY supports two object modes.
Singleton mode provides a shared instance
of the object with a particular name, which can
be retrieved on lookup. Singleton is the default
and most often used object mode. It is ideal
for stateless service objects.
Prototype mode ensures that each retrieval
will result in the creation of an independent
object. Prototype mode would be best used in
a case where each user needed to have his or
her own object. The bean factory concept is
the foundation of Spring as an IOC container.
IOC moves the responsibility for making things
happen into the framework and away from application code. The
Spring framework uses JavaBean properties and
configuration data to figure out which dependencies
must be set.
There are several implementation of BeanFactory like
XmlBeanFactory” which loads its beans
based on the definition contained in an XML
The Application Context is spring’s more
advanced container. Like ‘BeanFactory’ it can
load bean definitions, wire beans together and
dispense beans upon request. Additonally, It
1. A means for resolving text messages, including
support for internationalization ie. i18n messages
2. A generic way to load file resources.
3. Events to notify beans that are registered
Because of additional functionality, ‘Application
Context’ is preferred over a BeanFactory.
BeanFactory is used for simple applications and
when the resource is scarce like mobile devices.
III Service Abstraction Layers
Spring provides consistent integration with
various standard and 3rd party APIs through
its various Service abstraction layers. Few of
||1. Transaction Management abstraction for
JTA, JDBC, others
2. Data Access abstraction for JDBC, Hibernate,
JDO, TopLink, iBatis
3. Abstraction for Emailing
4. Remoting abstraction layers for EJB, Web
Services, RMI, Hessian/Burlap
Benefits of the Service Abstraction Layers in
1. There is no implicit contract with JNDI, etc.
2. It separates the user from the underlying
3. It enhances the reusability to a great extent.
4. Spring abstractions always consist of inter
5. Testing is kept simpler than ever before.
6. For data access, Spring uses a generic transaction
infrastructure and DAO exception hierarchy that is
ommon across all sup ported platforms.
Nov 2007 | Java Jazz Up | 9
|View All Topics
|All Pages of this Issue
69 Download PDF