Saturday, September 7, 2013

Spring IQ

1. What is the difference between Spring 3.0 and Spring 2.5?
The Spring Framework is the widely used framework for java based application development. Spring framework 3.0 is the next major release after Spring framework 2.5. The difference between Spring Framework 3.0 and Spring Framework 2.5 are:
Spring Framework 3.0
Spring Framework 2.5
Spring framework 3.0 is compatible with Java 5 and higher versions.
Spring framework 2.5 is compatible with Java 1.4 and higher versions.
Spring framework 3.0 introduces Spring Expression Language which defines bean definitions based XML and Annotation.
In Spring framework 2.5, native expression language exists which is less powerful than spring expression language of spring 3.0 and it has different parsing rules.
Spring framework 3.0 has type converting system and field formatting.
Spring framework 2.5 does not support type conversions and field formatting.
Spring framework 3.0 fully supports the JSR303 bean validation API.
Spring framework 2.5 does not offer complete support for JSR303 bean validation API.
Spring framework 3.0 offers support for various embedded database engines like HSQL, Derby and H2.
Spring framework 2.5 does not support the embedded database engines.
Comprehensive REST support is available in Spring framework 3.0.
Spring framework 2.5 does not support Comprehensive REST.
Spring framework 3.0 automatically validates the @Controller inputs.
Spring framework 2.0 does not validate the @Controller inputs automatically.

2. Difference between BeanFactory and ApplicationContext ?
BeanFactory
ApplicationContext
Instantiates beans lazily i.e. Beans are  instantiated when you get them from BeanFactory not on loading BeanFactory.
BeanFactory beanFactory = new XMLBeanFactory(new ClassPathResource(“spring-beans.xml”)); //factory is loaded
Emp emp = beanFactory.getBean(”empBean”);
// bean is instantiated
Instantiates beans eagerly i.e. Beans are instantiated when ApplicationContext is loaded/up. 
ApplicationContext appCtx = newClassPathXmlApplicationContext(“spring-beans.xml”); // beans are instantiated and ApplicationContext is up.
No support for Message Internationalization (i18n)
Can resolve text messages according to locale, supports Message Internationalization (i18n)
No event handling (event propagation).
Provides event-propagation to the beans which are registered as listener to ApplicationContext i.e. the beans implementing ApplicationListener interface.
Access to low level resources is not convenient in BeanFactory.
Access is very convenient. Application contexts has a generic/common way to load file resources. It is a resource loader, can load resources including
·         FileSystemResource.
·         ClassPathResource
·         ServletContextResource
·         InputStreamResource


No comments:

Post a Comment