Flashcards in Basics Deck (21)
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?
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?
Which is the core of the Spring framework?
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?
Where does the ClassPathXmlApplicationContext looks for bean configuration xml?
In the Class path
Life cycle of beans?
3. BeanNameAware's (setBeanName)
4. BeanFactoryAware's (setBeanFactory)
5. ApplicationContextAware's (setApplicationContext)
6. Pre-Initialization (beanPreProcessor)
7. InitilaizingBean's (afterPropertySet)
8. custom-init method
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