Basics Flashcards

(21 cards)

1
Q

What is Spring?

A

An open source framework that makes the java development easier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does spring benefits java development by making it easier?

A
  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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How it unleashes the power of POJOS?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is dependency injection

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does spring framework works?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does java knows which application context to load?

A

In main method, the context to be loaded is described

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is AOP?

A

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

Its seperation of concersns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the normal cross-cutting concerns?

A
  1. Security
  2. Transactions
  3. Logger
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Generic explanation of AOP?

A
Using AOP, system-wide
concerns blanket the components
they impact. This leaves the
application components to focus on
their specific business functionality
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How spring eliminates boiler plate code?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Where does the application objects live in Spring based application?

A

Spring container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which is the core of the Spring framework?

A

Spring container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the two types of Spring framework?

A

Bean factories - simplest of containers, basic support of DI

Application contexts - Application framework services

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the different application context?

A
  1. AnnotationConfigApplicationContext
  2. ClassPathXMLApplicationContext
  3. AnnotationConfigWebApplicationContext
  4. FileSystemXMLApplicationContext
  5. XMLApplicationContext
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Where does the ClassPathXmlApplicationContext looks for bean configuration xml?

A

In the Class path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Life cycle of beans?

A
  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
Q

what are the three ways of bean configuration?

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

How can we wire collections eg.. List?

A

Dilli
DilliGanesh

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

19
Q

Choosing between constructor injection and property injection?

A

Hard dependencies - constructor injection

Optional dependencies - property injection

20
Q

What attribute does Spring provides for resolving environment specific details?

A

@profile(“prod”) -> java config

-> xml config

21
Q

What are the different scopes of beans in spring?

A
  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