Basics Flashcards Preview

Spring > Basics > Flashcards

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

What is Spring?

An open source framework that makes the java development easier

2

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

3

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

4

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

5

How does spring framework works?

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

6

How does java knows which application context to load?

In main method, the context to be loaded is described

7

What is AOP?

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

Its seperation of concersns

8

What are the normal cross-cutting concerns?

1. Security
2. Transactions
3. Logger

9

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

10

How spring eliminates boiler plate code?

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

11

Where does the application objects live in Spring based application?

Spring container

12

Which is the core of the Spring framework?

Spring container

13

What are the two types of Spring framework?

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

14

What are the different application context?

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

15

Where does the ClassPathXmlApplicationContext looks for bean configuration xml?

In the Class path

16

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
11.

17

what are the three ways of bean configuration?

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

18

How can we wire collections eg.. List?




Dilli
DilliGanesh



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

19

Choosing between constructor injection and property injection?

Hard dependencies - constructor injection
Optional dependencies - property injection

20

What attribute does Spring provides for resolving environment specific details?

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

21

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