Recent Posts

Saturday, 8 June 2019

What is Spring Framework

What is Spring Framework?
     Spring Framework is one of the most popular Java-based application frameworks. Spring framework is an open source java platform and it was created by “Rod Johnson” in 2003. Spring is a complete and modular framework. It means Spring framework can be used for all layer implementations for a real time application or spring can be used for development of particular layer of a real time application unlike struts [only for front end related] and hibernate [only for database related], but with spring we can develop all layers.
     Spring framework can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, EJB, JSF etc. Using web frameworks, we can just develop web applications. Using ORM frameworks we can just develop persistence logics. But using spring framework we can develop all kinds of logics like business logic, persistence logic, integration logic, presentation logic etc. Using spring framework, we can develop all kinds of applications like standalone applications, two-tire applications, web applications, distributed applications and enterprise applications etc. Spring 1.X contains 7 modules, spring 2.X contains 6 modules, and spring 3.X contains 20 modules, but they are grouped into 6 major categories. Spring 1.X overview diagram is as follows,
Spring 2.X overview diagram is as follows,
Spring 3.X overview diagram is as follows,
Spring 4.X overview diagram is as follows,
Core Module
     It is fundamental module in Spring Framework; it has provided basic foundation for all other modules of spring framework. This module can be used to prepare Standalone Applications directly. This module is able to provide the features like IOC Containers, Beans, Dependency Injection etc.
AOP Module [Aspect Oriented Programming]
     In general, if we prepare enterprise applications by using only Object Orientation then we have to provide both business logic and Services like Transactions, JMS, JAAS etc. in combined manner, it will provide tightly coupled design, it will provide less shareability and less reusability.
In the above context, to improve shareability and Reusability we have to provide loosely coupled design, to get loosely coupled design we have to apply Aspect Oriented Programming. In Aspect Oriented Programming, we will declare each and every service as an aspect and we will inject these aspects in Business Logic at runtime.
JDBC/DAO Modules
     The main intention of this module is to interact with database from Spring application in order to perform database operations with JDBC Persistence mechanism. JDBC/DAO modules are able to abstract common JDBC implementation in order to simplify Database interaction from spring applications by providing template classes.
E.g.
In JDBC, if we want to interact with database then we have to use the following steps
1. Load And Register Driver
E.g. Class.forName("oracle.jdbc.OracleDriver");
2. Establish Connection between Java appl and DB.
E.g. Connction conn = DriverManager.getConnection("jdbc: oracle:thin:@localhost:1521:xe", "ashok", "ashok");
3. Create Statement/PreparedStatement/ CallableStatement as per the requirement.
E.g. Statement st = conn.createStatement();
4. Write and Execute SQL Queries
E.g. ResultSet rs = st.executeQuery("select * from emp");
5. Close the Connection
E.g. conn.close();
     In the above JDBC Steps, Load and Register Driver, Establish Connection and Create Statement and close the Connection are very common in all the JDBC applications, here Spring JDBC/DAO modules are able to abstract the commonly used steps and giving option to the developers to provided variable part, that is, Executing SQL queries.
     Spring DAO and JDBC modules are having their own Exception Classes hierarchy to expose the exception details. Spring DAO/JDBC modules are converting the JDBC generates checked exceptions to Spring defined Unchecked Exceptions by using Exceptions Re-Throwing Mechanism.

ORM Module [Object-Relational Mapping]
     The process of mapping Java class with DB table, member variables with table columns and making that java class objects representing DB table rows by having synchronization between them is called ORMapping.
ORM has define a set of rules and regulations to provide mapping between Object Oriented Data Model and Relational Data Model in order to achieve data persistency.
E.g. Hibernate, JPA, Toplink etc.
     To prepare Hibernate Application then we have to use the following instructions.
1. Create Configuration class object.
E.g. Configuration cfg = new Configuration();
cfg.configure();

2. Create SessionFactory class object:
E.g. SessionFactory sf = cfg.buildSessionFactory();

3. Create Session object:
E.g. Session s = sf.openSession();

4. Perform Persistence operations
Object obj = s.load("com.ashok.hibernate.model.Employee.class", 111);

5. Close SessionFactory and Configuration
sf.close();
cfg.close();

     In the above Hibernate Application steps, Create Configuration class object, Creation SessionFactory object, create Session object and close SessionFactory and Configuration steps are very common in all hibernate applications, in this case, Spring ORM module is able to abstract all the common instructions in order to simplify Data persistence in enterprise applications.
     Spring ORM module has provided its own Exceptions hierarchy to expose behalf of the under lying Persistence mechanism like Hibernate, JPA etc. provided checked exceptions.

JAVA EE/Context/Remoting
     The main intention of this module to integrate Spring applications with the distributed tech applications like EJBs, RMI etc. it able to get middleware services like JNDI, JTA, JAAS etc. from J2EE.

WEB/WEB-MVC Modules
     WEB Module has provided very good environment to integrate other MVC based framework applications like Struts, JSF, XWork2 etc.
     WEB-MVC is an MVC implementation provided by Spring framework directly in order to prepare web applications.

Test
     Spring Framework has provided its own testing environment to test the enterprise applications by the developers [Unit Testing] in their own way in the form of Test module.
Note: Spring framework has provided Test module right from its Spring3.x version.

Instrumentation
     Spring Framework has provided Instrumentation API to perform manipulations over the actions which are generated from the .class files without having modifications over the source code.

Messaging
     Spring Framework has provided Messaging module along with its Spring4.x version to provide Messaging Services what JMS is providing previously as part of J2EE.
Note: When we perform any transactions in bank application, we are able to receive mobile updations, in this context, if our mobile device is not ready to receive messages

     WEB Module has provided very good environment to integrate other MVC based framework applications like Struts, JSF, XWork2 etc. then we have to keep the respective message in Messaging Container or JMS Server to send the respective message when the target machine / device is ready.

Next Tutorial : Steps to prepare Spring application 

Previous Tutorial : Differences between Struts, JSF and Spring 
 

1 comment:

  1. The effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Final Year Project Centers in Chennai.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

    ReplyDelete