Monday, September 7, 2009

SPRING interview Questions

What is Aspect-oriented programming in Spring and its benefits compared to other J2EE technologies ?

AOP is a programming technique adopted in spring framework to allow programmer to modularize crosscutting issues like logging and transaction management.

In a typical oops development approach programmer usually implements logging functionality by putting logger statements in all your methods of Java classes. In an AOP approach one can instead modularize the logging services and apply them declaratively to the components that required logging.

What is the Core container module?

Most basic part of framework that provides IOC and dependency injection features .The most basic part is BeanFactory which provides a sophisticated implementation of the factory pattern which allows programmer to decouple the configuration and specification of dependencies from actual program logic.

What is Spring Context Package ?

The package, which provides a way to access objects in a framework-style manner similar to JNDI naming Concept.

What is Spring DAO package?

This Package provides a JDBC-abstraction layer that removes the need to write JDBC coding and parsing database-vendor specific error codes.

What is Spring ORM package ?

This Package provides integration layers for popular object-relational mapping. APIs, like JDO, Hibernate etc. Using the ORM package you can use all those O/R-mappers in combination with all the other features Spring offers, such as the simple declarative transaction management feature.

What is Spring AOP Package?

This is a aspect-oriented programming implementation which allows to define method-interceptors and point cuts to decouple code implementing functionality that should logically be separated.

What is Spring's Web package?

This package provides basic web-oriented integration features, like multipart file-upload functionality or initialization of the IoC container using servlet listeners and a web-oriented application context. When using Spring together with Struts or any other web framework, this is the package to integrate with.

What is Spring's MVC package?

This package provides a Model-View-Controller (MVC) implementation for web-applications. Spring's MVC framework is different from other implementations as it provides a clean separation between model code and web forms, and allows you to use all the other features of the Spring Framework.

What are object/relational mapping integration module?

Spring also supports for using of an object/relational mapping (ORM) tool over straight JDBC by providing the ORM module. Spring provide support to tie into several popular ORM frameworks, including Hibernate, JDO, and iBATIS SQL Maps. Springs transaction management supports each of these ORM frameworks as well as JDBC.

What are important ApplicationContext implementations in spring framework?

  1. ClassPathXmlApplicationContext  This context loads a context definition from an XML file located in the class path, treating context definition files as class path resources.
  2. FileSystemXmlApplicationContext  This context loads a context definition from an XML file in the filesystem.
  3. XmlWebApplicationContext  This context loads the context definitions from an XML file contained within a web application.

What is XMLBeanFactory?

BeanFactory has many implementations in Spring. But one of the most useful one isorg.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions contained in an XML file. To create an XmlBeanFactory, pass a java.io.InputStream to the constructor. The InputStream will provide the XML to the factory. For example, the following code snippet uses a java.io.FileInputStream to provide a bean definition XML file to XmlBeanFactory.

 

BeanFactory factory = new XmlBeanFactory(new FileInputStream("beans.xml"));

To retrieve the bean from a BeanFactory, call the getBean() method by passing the name of the bean you want to retrieve.

MyBean myBean = (MyBean) factory.getBean("myBean");

How to split container definitions in multiple XML files ?

Container definition can be spit to the multiple XML files and combined through Import keyword.

<beans>

<import resource="services.xml"/>

<import resource="message.xml"/>

<import resource="themes.xml"/>

<bean id="bean1" class="..."/>

<bean id="bean2" class="..."/>

</beans>

 

1

2

3

4

5

6

7

8

9

10

 

No comments:

Post a Comment