Java Reference
In-Depth Information
• As you will see later with push DI supported by Spring IOC, there is no need for
applications to look up objects like EJB remote interfaces.
• DI promotes good object-oriented design and reuse—object composition rather
than reuse by inheritance.
Drawbacks of DI
These are the drawbacks of DI:
• The dependencies are generally hard-coded in XML configuration files that are
proprietary and nonstandard.
• Wiring instances together can become a hazard if there are too many instances
and many dependencies that need to be addressed.
• Dependency on XML-based metadata and excessive use of reflection and bytecode
manipulation may impact application performance.
Bean Factory
The org.springframework.beans.factory.BeanFactory interface provides the basis for
Spring's IOC container or bean factory. It is a sophisticated implementation of the GOF
factory method design pattern and creates, caches, wires together, and manages applica-
tion objects. These objects are affectionately called beans because Spring promotes the
POJO programming model. Spring provides several out-of-the-box implementations of
the bean factory. One such implementation is the XmlBeanFactory class. This class allows
you to configure the various application classes and their dependencies in XML files. In
short, a bean factory like JNDI is a registry of application objects. Listing 2-5 shows a
simple Spring bean configuration file.
Listing 2-5. spring-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
>
 
Search WWH ::




Custom Search