Example

Now, there is no dependency between Employee and Address because Employee is not forced to use the same address instance. It can use any address instance.

What is the role of IOC container in spring ?

IOC container is responsible to:

create the instance

configure the instance, and

assemble the dependencies

What are the types of IOC container in spring ?

There are two types of IOC containers in spring framework.

BeanFactory

ApplicationContext

What is the difference between BeanFactory and ApplicationContext ?

BeanFactory is the basic container whereas ApplicationContext is the advanced container. ApplicationContext extends the BeanFactory interface. ApplicationContext provides more facilities than BeanFactory such as integration with spring AOP, message resource handling for i18n etc.

Difference between constructor injection and setter injection

Constructor Injection

Setter Injection

No Partial Injection

Partial Injection

Desn't override the setter property

Overrides the constructor property if both are defined.

Creates new instance if any modification occurs

Doesn't create new instance if you change the property value

Better for too many properties

Better for few properties.

In which scenario, you will use singleton and prototype scope ?

Singleton scope should be used with EJB stateless session bean and prototype scope with EJB stateful session bean.

Does Spring singleton beans are thread-safe ?

What is dependency Injection ?

Dependency Injection is one of the design pattern, which allows injecting dependency on Object, instead of object resolving the dependency.

What are different implementations of View interface you have used in Spring MVC ?

ULBased View e.g. JSP , JSTLView.

Define Bean Wiring ?

Bean wiring is the creation of associations between application components that are between the beans in a particular spring container.

What is called Spring MVC ?

A Spring MVC is a single shared controller instance and it is used to handle request type controllers, interceptors which run in the IoC container. It also allows multiple Dispatcher Servlets which can share application context interface but not class based interface.

Why Spring framework is needed ?

Spring framework is needed because it is;

Very Light Weight Container

Framework

IOC

AOP

What is Auto Wiring ?

Autowiring is used to build relationships between the collaborating beans. Spring container can automatically resolve collaborators for beans.

Differentiate between singleton and prototype bean ?

Singleton means only one bean is defined per object instance while Prototype means one definition to more than one object instances in Spring.

Write about Core container module

Core container module is responsible for the basic functionality of the spring framework. The whole Spring framework is built with this module as a base.

What is a Pointcut ?

Pointcut is used to allow where the advice can be applied.

What is weaving ?

Weaving is used to create new proxy object by applying aspects to target object.

What is difference between singleton and prototype bean ?

Singleton Bean: Single bean definition to a single object instance per Spring IOC container

Prototype Bean :Single bean definition to any number of object instances per Spring IOC Container

What are the different types of AutoProxying ?

BeanNameAutoProxyCreator

DefaultAdvisorAutoProxyCreator

Metadata autoproxying

How can beans be made singleton or prototype ?

The bean tag has an attribute called ‘singleton’. The bean is singleton if its value is ‘TRUE’, otherwise the bean is a prototype.