Category Archives: Spring
Explain Bean lifecycle in Spring framework?
Bean life cycle in Spring Bean Factory Container is as follows:
The spring container finds the bean’s definition from the XML file and instantiates the bean.
Using the dependency injection, spring populates all of the properties as specified in the bean definition
If the bean implements the BeanNameAware interface, the factory calls setBeanName () passing the bean’s ID.
If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory (), passing an instance of itself.
If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization () methods will be called.
If an init-method is specified for the bean, it will be called.
Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization () methods will be called.
What are the modes of Auto Wiring?
-
no
-
byName
-
byType
-
constructor
-
autodirect
What are ORM’s spring supports?
Spring supports the following ORM’s:
1. Hibernate
2. iBatis
3. JPA (Java Persistence API)
4. TopLink
5. JDO (Java Data Objects)
6. OJB
What are Bean scopes in Spring Framework?
-
Singleton
-
Prototype
-
request
-
session
-
global session
What are the types of the transaction management Spring supports?
Spring Framework transaction management supports:
-
Programmatic transaction management.
-
Declarative transaction management.
What is PreparedStatementCreator?
PreparedStatementCreator:
-
Is one of the most common used interfaces for writing data to database
-
Has one method – createPreparedStatement(Connection)
-
Responsible for creating a PreparedStatement.
-
Does not need to handle SQLExceptions.
What is SQLProvider?
SQLProvider:
-
Has one method – getSql()
-
Typically implemented by PreparedStatementCreator implementers.
-
Useful for debugging.
What is RowCallbackHandler?
The RowCallbackHandler interface extracts values from each row of a ResultSet.
-
Has one method – processRow(ResultSet)
-
Called for each row in ResultSet
-
Typically stateful
What are the different points where weaving can be applied?
-
Compile Time
-
Classload Time
-
Runtime