Spring
developed by Rod Johnson in 2003Spring FrameworkSpring is a lightweight framework. It can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, Tapestry, EJB, JSF etc.
The framework, in broader sense, can be defined as a structure where we find solution of the various technical problems.
Advantages of Spring Framework
Predefined TemplatesLoose CouplingEasy to testLightweightFast DevelopmentPowerful abstractionDeclarative supportModules:
Core, Beans, Context, Expression LanguageAOP, Aspects and Instrumentation
Data Access / Integration
JDBC, ORM, OXM, JMS and Transaction modules.
Web, Web-Servlet, Web-Struts and Web-Portlet.
Spring batch
IoC Container
The IoC container is responsible to instantiate, configure and assemble the objects. The IoC container gets informations from the XML file and works accordingly.The main tasks performed by IoC container are:
to instantiate the application classto configure the objectto assemble the dependencies between the objects
There are two types of IoC containers. They are:
BeanFactory
ApplicationContextResource resource=new ClassPathResource("applicationContext.xml"); BeanFactory factory=new XmlBeanFactory(resource);
Bean Factory
Bean instantiation/wiringApplication ContextApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Bean instantiation/wiringAutomatic BeanPostProcessor registrationAutomatic BeanFactoryPostProcessor registrationConvenient MessageSource access (for i18n)ApplicationEvent publication
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
Dependency Injection in Spring
Dependency Injection (DI) is a design pattern that removes the dependency from the programming code so that it can be easy to manage and test the application. Dependency Injection makes our programming code loosely coupledTwo ways to perform Dependency Injection in Spring framework
Spring framework provides two ways to inject dependency
No comments:
Post a Comment