Thursday, 21 April 2016

Spring Rapid fire


1. Which logging framework is used for providing logging support in Spring ?
Jakarta Commons Logging API

2. Are there any ways to pass value of property of a bean as NULL ?
Yes, NULL tag can be used.

3. Can there be singleton bean initialized lazily ?
Yes, by using lazy-init="true". It will instantiate on request only

4. What are the different scopes applicable to Spring bean ?
singleton, prototype, request, session, global session

5. What will happen if a singleton-scoped bean has a reference property for the bean that has attribute as lazy-init="true"?
Spring's container will create the bean even though this is defined as lazy-init="true" and inject it into the other Spring bean that is singleton-scoped.

6. Difference between Spring's session and globalsession scopes for the bean ?
Spring's session is some what similar to the HTTP session in case of a web application, while Spring's globalsession is more useful in case of portlet-based web application, where portlets are sharing a global HTTP session for a portlet web application.

7. How can Circular dependencies occur while using Spring IOC, give an example ?
If a bean has another bean as argument type in constructor, and vice versa (the later bean has the former bean as argument type passed in constructor), then a Circular dependencies can occur. In this circular dependency, Spring will throw BeanCurrentlyInCreateionException, if the constructor injection is used.

8. How to avoid above condition ?
Avoid using constructor injection, instead going for setter injection will be good idea.

9. Can a bean be declared as anonymous ?
Yes, it is possible to define bean as anonymous, by defining bean inside property and constructor-arg tags when defined within bean tag.

10. What is the default scope for a bean ?
singleton

11. What is the default scope for anonymous bean ?
prototype

12. What is the exception class while working with data access mechanisms such as JDBC, Hibernate, JDO or JPA ?
org.springframework.dao.DataAccessException (unchecked)

13. What are main parts of Spring Core Container, Data Access/ Integration layer, Spring's Web layer ?
Core Container - Bean, Context, Epression Language
Data Access/ Integration layer - JDBC, ORM, OXM, JMS, Transaction
Web layer - Web Module, Web-Servlet, Web-Struts, Web-portal

14. What is the major difference on functionality provided by Spring's ORM module and OXM module ?
Spring's ORM module works with Object Relational Mapping tools/frameworks such as Hibernate, Oracle TopLink, JDO, JPA, iBatis and many more.
While Spring's OXM module works with Object XML Mapping implementations like JAXB, Castor and many more.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.