Basics Flashcards Preview

Spring > Basics > Flashcards

Flashcards in Basics Deck (21)
Loading flashcards...

What is Spring?

An open source framework that makes the java development easier


How does spring benefits java development by making it easier?

1. Lightweight and minimally invasive development of Pojos
2. Loose coupling through DI
3. Declarative programming through aspects and common conventions
4. Removes boiler plate codes


How it unleashes the power of POJOS?

Spring doesnt mandate the classes to implement/extend spring specific interface/classes. Other frameworks such as Struts makes you compulsory to implement their specific interfces


What is dependency injection

Traditionally, each object gets its dependencies of its own. It makes the objects tightly bound with one another.

This DI, one object is injected with other at comple time through a third part, which is spring here - Based on configuration


How does spring framework works?

An application context loads the beans defined and wire them together according to the configuration


How does java knows which application context to load?

In main method, the context to be loaded is described


What is AOP?

Enables us to capture functionality that is used thrughout the application in reusable components.

Its seperation of concersns


What are the normal cross-cutting concerns?

1. Security
2. Transactions
3. Logger


Generic explanation of AOP?

Using AOP, system-wide
concerns blanket the components
they impact. This leaves the
application components to focus on
their specific business functionality


How spring eliminates boiler plate code?

by using Templates.Eg.., Spring JDBCTemplates eliminates the boiler plate code for JDBC Connections


Where does the application objects live in Spring based application?

Spring container


Which is the core of the Spring framework?

Spring container


What are the two types of Spring framework?

Bean factories - simplest of containers, basic support of DI
Application contexts - Application framework services


What are the different application context?

1. AnnotationConfigApplicationContext
2. ClassPathXMLApplicationContext
3. AnnotationConfigWebApplicationContext
4. FileSystemXMLApplicationContext
5. XMLApplicationContext


Where does the ClassPathXmlApplicationContext looks for bean configuration xml?

In the Class path


Life cycle of beans?

1. Instantiate
2. Populateproperties
3. BeanNameAware's (setBeanName)
4. BeanFactoryAware's (setBeanFactory)
5. ApplicationContextAware's (setApplicationContext)
6. Pre-Initialization (beanPreProcessor)
7. InitilaizingBean's (afterPropertySet)
8. custom-init method
9. beanPostProcesseor
Bean gets life
10. disposableBean (destroy method)
11. Calling custom destroy method


what are the three ways of bean configuration?

1. Explicit configuation through XML
2. Explicit configuration by java
3. Let beans automatically configure


How can we wire collections eg.. List?


If we want to inject a list of bean references, then replace with


Choosing between constructor injection and property injection?

Hard dependencies - constructor injection
Optional dependencies - property injection


What attribute does Spring provides for resolving environment specific details?

@profile("prod") -> java config
-> xml config


What are the different scopes of beans in spring?

1. Singleton- One instance of bean for entire application
2. Prototype- One instance of the bean is created every time the bean is injected
into or retrieved from the Spring application context.
3. Session - One instance of the bean created for each session in Web application
4. One instance of the bean created for each request in web application