Friday, January 29, 2016

Spring

Spring


What is Spring ?
Spring is an open source framework created to address the complexity of enterprise application development. One of the chief advantages of the Spring framework is its layered architecture, which allows you to be selective about which of its components you use while also providing a cohesive framework for J2EE application development.
What are features of Spring ?
  • Lightweight:
    spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 1MB. And the processing overhead is also very negligible.
  • Inversion of control (IOC):
    Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects.
  • Aspect oriented (AOP):
    Spring supports Aspect oriented programming and enables cohesive development by separating application business logic from system services.
  • Container:
    Spring contains and manages the life cycle and configuration of application objects.
  • MVC Framework:
    Spring comes with MVC web application framework, built on core Spring functionality. This framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. But other frameworks can be easily used instead of Spring MVC Framework.
  • Transaction Management:
    Spring framework provides a generic abstraction layer for transaction management. This allowing the developer to add the pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues. Spring’s transaction support is not tied to J2EE environments and it can be also used in container less environments.
  • JDBC Exception Handling:
    The JDBC abstraction layer of the Spring offers a meaningful exception hierarchy, which simplifies the error handling strategy. Integration with Hibernate, JDO, and iBATIS: Spring provides best Integration services with Hibernate, JDO and iBATIS

    How many modules are there in Spring? What are they?
    Spring comprises of seven modules. They are..
      • The core container:
        The core container provides the essential functionality of the Spring framework. A primary component of the core container is the BeanFactory, an implementation of the Factory pattern. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an application’s configuration and dependency specification from the actual application code.
      • Spring context:
        The Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internalization, validation, and scheduling functionality.
      • Spring AOP:
        The Spring AOP module integrates aspect-oriented programming functionality directly into the Spring framework, through its configuration management feature. As a result you can easily AOP-enable any object managed by the Spring framework. The Spring AOP module provides transaction management services for objects in any Spring-based application. With Spring AOP you can incorporate declarative transaction management into your applications without relying on EJB components.
      • Spring DAO:
        The Spring JDBC DAO abstraction layer offers a meaningful exception hierarchy for managing the exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code you need to write, such as opening and closing connections. Spring DAO’s JDBC-oriented exceptions comply to its generic DAO exception hierarchy.
      • Spring ORM:
        The Spring framework plugs into several ORM frameworks to provide its Object Relational tool, including JDO, Hibernate, and iBatis SQL Maps. All of these comply to Spring’s generic transaction and DAO exception hierarchies.
      • Spring Web module:
        The Web context module builds on top of the application context module, providing contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.
    • Spring MVC framework:
      The Model-View-Controller (MVC) framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and accommodates numerous view technologies including JSP, Velocity, Tiles, iText, and POI.
      What are ORM’s Spring supports ? 
      Spring supports the following ORM’s :
      • iBatis
      • Hibernate
      • JPA (Java Persistence API)
      • TopLink
      • JDO (Java Data Objects)
      • OJB
      What are the ways to access Hibernate using Spring ?
      There are two approaches to Spring’s Hibernate integration:
      • Inversion of Control with a HibernateTemplate and Callback
      • Extending HibernateDaoSupport and Applying an AOP Interceptor
      How to integrate Spring and Hibernate using HibernateDaoSupport?
      Spring and Hibernate can integrate using Spring’s SessionFactory called LocalSessionFactory. The integration process is of 3 steps.
      Configure the Hibernate SessionFactory
      Extend your DAO Implementation from HibernateDaoSupport
      Wire in Transaction Support with AOP
      What are the types of the transaction management Spring supports ?
      Spring Framework supports:
      Programmatic transaction management.
      Declarative transaction management.
      What are the benefits of the Spring Framework transaction management ?
      The Spring Framework provides a consistent abstraction for transaction management that delivers the following benefits:
      Provides a consistent programming model across different transaction APIs such as JTA, JDBC, Hibernate, JPA, and JDO.
      Supports declarative transaction management.
      Provides a simpler API for programmatic transaction management than a number of complex transaction APIs such as JTA.
      Integrates very well with Spring’s various data access abstractions.
      Why most users of the Spring Framework choose declarative transaction management ?
      Most users of the Spring Framework choose declarative transaction management because it is the option with the least impact on application code, and hence is most consistent with the ideals of a non-invasive lightweight container.
      When to use programmatic and declarative transaction management ?
      Programmatic transaction management is usually a good idea only if you have a small number of transactional operations.
      On the other hand, if your application has numerous transactional operations, declarative transaction management is usually worthwhile. It keeps transaction management out of business logic, and is not difficult to configure.
    Click here for more Hadoop Interview Questions

No comments:

Post a Comment