Programming‎ > ‎Java‎ > ‎15. Spring‎ > ‎

0. Spring Overview




Objective

  • Getting Started with Spring and Hibernate - Dev Environment
  • Apply Spring Inversion of Control/Dependency Injection
  • Perform object/relational mapping with Hibernate
  • Leverage the Hibernate API to develop CRUD apps

Why Spring?



Spring in a Nutshell
  • Very popular framework for building enterprise java applications
  • Initially a simpler and lightweight alternative to J2EE
  • Provides a large number of helper classes...makes things easier
But what about J2EE
  • Client Side Presentation
  • Server Side Presentation - JSP, Servlets, Web Services
  • Server Side Business Logic - using Enterprise Java Beans
  • Database - backend
  • 1999 : J2EE 1.2 - Servlets, JSP, EJB, JMS, RMI
  • 2001 : J2EE 1.3 - EJB, CMP, JCA
  • 2003 : J2EE 1.4 - Web Services Mgmt Deployment
  • 2006 : Java EE 5 - Ease of use, EJB 3, JPA, JSF, JAXB, JAX-WS
  • 2009 : Java EE 6 - Pruning, Ease of use, JAX-RS, CDI, Bean Validation, EJB 3.1 introduced much easier to use
  • 2013 : Java EE 7 - JMS 2, Batch TX, Concurrency, Web Sockets, Similar features as Core Spring
  • 2017 : Java EE 8 - EE provides similar features as Spring, however Spring mush higher reputation

  • EJB - Enterprise Java Beans
  • JMS - Java Message Service
  • RMI - Remote Method Invocation
  • CMP - Container Managed Persistence
  • JCA - Java Connector Architecture
  • JPA - Java Persistence API
  • JSF - Java Server Faces
  • JAXB - Java API for XML Binding
  • JAX-WS - Java Web Services - SOAP
  • JAX-RS - Java Web Services - REST
  • CDI - Context Dependency Injection (IoC)

EJB v1 and v2 Complexity
  • Enterprise JavaBeans (EJB) is one of several Java APIs for modular construction of enterprise software. EJB is a server-side software component that encapsulates business logic of an application.
  • Early version of EJB (v1 and v2) were extremely complex
  • Multiple deployment descriptors
  • Multiple interfaces
  • Poor Performance of Entity Beans
  • Requires 3-4 java files just for Beans implementation - ELB Client, Home Interface, Home Object, Component Interface, EJB Object, Bean Class

J2EE Deployment without ELB
  • Most developers would want to use J2EE without EJB
  • Rod Johnson - Founder of Spring
  • Book - Java Development with Spring Framework
Release Timeline - Spring
  • Developer were fed-up with EJB in 2003 and then Spring came-up in 2004
  • 2004 : Spring 1.0
  • 2006 : Spring 2.0
  • 2009 : Spring 3.0
  • 2013 : Spring 4.0
  • 2016 : Spring 4.3

What Should you do?
  • Learn Spring
  • Or Java EE
  • Better learn both
  • Doing MVC, Concept of Dependency Injection are similar in both

Update - Spring 5
  • 2017 September : Spring 5
  • Updated minimum requirements for Java 8 or higher
  • Deprecated legacy integration with old third party projects - Tiles, Velocity, Portlet, Guava, etc
  • Upgraded Spring MVC to use new versions of Servlet API 4.0
  • Added new reactive programming framework - Spring WebFlux
  • What's new in Spring 5\5.1
  • Spring 5 FAQ
What about Spring 4?
  • Some of you may have projects at your job that are still using Spring 4
  • Spring 5 just added new features ...
  • But core Spring 4 features are still the same - Inversion of Control, Dependency Injection, Spring AOP, Spring MVC


Spring Framework Overview


  • www.spring.io
  • Simplify Java Enterprise Development

Goals of Spring
  • Lightweight Development with Java POJOs (Plain Old Java Objects)
  • Dependency injection to promote loose coupling - via config file or annotations
  • Declarative programming with Aspect-Oriented-Programming (AOP)
  • Minimize boilerplate Java code - using helper classes from Spring
Core Container
  • Beans
  • Core - Factory for creating beans, Manage bean dependencies
  • SpEL - Spring expression language, language to use in config file
  • Context
Infrastructure
  • AOP - Aspect oriented programming, Add functionality to objects declaratively - Logging, security, transactions, etc
  • Aspects
  • Instrumentation
  • Messaging
Data Access Layer
  • JDBC - JDFC Helper classes, reduce JDBC code by 50%
  • ORM - Object to Relational mapping, Integration with Hibernate and JPA
  • Transactions - Make use of AOP
  • OXM
  • JMS - Java Message service, Helper classes by Spring
Web Layer - All web related classes
  • Servlet
  • Websocket
  • Web
  • Portlet
Test Layer - Supports TDD, Mock objects
  • Unit
  • Integration
  • Mock

What are Spring Projects
  • www.spring.io -> Projects
  • Additional Spring modules built on top of the core Sprint Framework
  • Only use what you need
  • Spring Cloud, Spring Data
  • Spring Batch, Spring Security
  • Spring for Android, Spring Web Flow
  • Spring Web Services, Spring LDAP









Comments