|
AOP and IoC |
|
the client.
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
“org.springframework.beans.factory.xml.
XmlBeanFactory” which loads its beans
based on the definition contained in an XML
file.
APPLICATION CONTEXT:
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
also provides:
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
as listeners.
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
them are:
|
|
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
spring framework:
1. There is no implicit contract with JNDI, etc.
2. It separates the user from the underlying
APIs.
3. It enhances the reusability to a great extent.
4. Spring abstractions always consist of inter
faces.
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 |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 Download PDF |
|
|
|
|
|
|
|
|
|