Spring Framework

 Spring Framework

Overview of Spring Framework

  • A complete Java platform aimed at enterprise application development.
  • Simpler application configuration and development comparing to other enterprise application framework like EJB.
  • Most famous for its inversion of controller container for dependency injection.
  • The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.
  • A key element of Spring is infrastructural support at the application level.
  • Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Features of Spring Framework

  • Core technologies - dependency injection, events, resources
  • Testing - mock objects, TestContext framework
  • Data Access - transactions, DAO support
  • Spring MVC and Spring WebFlux web frameworks
  • Integration - remoting, JMS, JCA, JMX
  • Languages - Kotlin, Groovy

Advantages of Spring Framework

Use of POJO
Flexibility for configuring Spring
No Need Server
Use of Spring AOP
No Need To Reinvent
Use of Modularity
Ease of Testability
Consistency of Transaction Management
Well-designed Web Framework
Inversion Control and API's

Spring Dependency Injection

  • The Dependency Injection is a design pattern that removes the dependency of the programs.
  • In such case, instance of Address class is provided by external source such as XML file either by constructor or setter method.
  • It makes our code loosely coupled and easier for testing.
  • Spring framework provides two ways to inject dependency
    • By Constructor
    • By Setter method
  1. class Employee{  
  2. Address address;    
  3. Employee(Address address){  
  4. this.address=address;  
  5. }  
  6. public void setAddress(Address address){  
  7. this.address=address;  
  8. }    
  9. }  

 Common Annotations

@Component - Making a class Spring container aware as a Component.
@Service - Making a class Spring container aware as a Service.
@Repository - Making a class Spring container aware as a DAO.
@RestController - Making a class Spring container aware as a REST Controller.
@Configurations - Spring aware configuration class.
@Autowired

Comments

Popular posts from this blog

NoSQL