0% found this document useful (0 votes)
25 views

Basics of Spring

The document discusses the basics of Spring, including advantages like being lightweight and easy development for enterprise applications. It also discusses Inversion of Control (IOC) in Spring, how the Spring framework uses IOC to have the container create and connect objects rather than components directly connecting. IOC allows the class dependencies to be injected rather than created.

Uploaded by

divyang_ddk
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Basics of Spring

The document discusses the basics of Spring, including advantages like being lightweight and easy development for enterprise applications. It also discusses Inversion of Control (IOC) in Spring, how the Spring framework uses IOC to have the container create and connect objects rather than components directly connecting. IOC allows the class dependencies to be injected rather than created.

Uploaded by

divyang_ddk
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Basics of Spring

Advantages of Spring Light Weight Non-invasive(i.e. not penetrating body) IOC (Inversion of control) and AOP(Aspect oriented programming) Development becomes easy for enterprise. Q-1) What is IOC (i.e. Inversion Of Control) in Spring? Ans 1: The basic concept of the Inversion of Control pattern (dependency injection) is that programmers dont need to create your objects but describe how they should be created. Dont directly connect your components and services together in code but describe which services are needed by which components in a configuration file. A container (in the case of the Spring framework, the IOC container) is responsible for all this. In a IOC scenario, the container creates all the objects, connects them together by setting the necessary properties, and determines when methods will be invoked. The implementation pattern types for IOC used by SpringFramework are as follows: * Dependencies can be assigned through JavaBeans properties (setter methods). * Dependencies are provided as constructor parameters and are not exposed as JavaBeans Setter properties. Ans 2: (simple) Inversion of control is based on the phenomenon that says, when ever dependency between two classes (say class A and class B) now if A needs to access the methods of B, then following our traditional approach we go ahead and create and object of B in A, but as the fact of matter, B is there to serve A not A serving B creating objects for B , So in IOC the class B will try to inject its object into A rather than A creating object of B. so the control is reversed , during the run time now spring container takes care which class object to inject into other class. Holywood principle "Don't call me , i will call you" Ans 3: (technical) IOC Container concept org.springframework.beans || ||--->|The BeanFactory interface advanced configuration mechanism capable of managing objects of any nature.

|| || org.springframework.beans.factory.BeanFactory || ||-->|BeanFactory is the actual representation of the Spring IoC container that is responsible for containing and otherwise managing bean XmlBeanFactory implementation BeanFactory XML configuration metadata +Business object =appplication (interdependencies between such objects)

You might also like