EIEIOTECHNOVATION
← Training programmes

EIEIO / PROGRAMMING & DEVELOPMENT

Building a REST API with Spring 4

Course outline

3 days

Duration

3 days

OVERVIEW

API (Application Programming Interface) endpoints are the connections between your application and the rest of the developer community. Writing secure, developer-friendly APIs that will make your back-end application thrive and keep your users happy.

This course enables the experienced Java developer to create Spring based RESTful API.

AUDIENCE

  • IT Programmers who would like to program on Java Web Programming.
  • Application and Project Managers involved in IT Enterprise Projects.
  • Those who are interested in develop programs on public cloud platforms.

PREREQUISITES

  • Strong Java programming skills are essential
  • Experience with other Java EE standards, especially servlets and JSP, will be very helpful in class, but is not strictly required.
  • Understanding of Spring Core - Spring Framework Core is excellent preparation.
  • Basic knowledge of XML.

Development Tools

OS: MS Windows platform with JDK 8 or Higher

IDE:Eclipse

Server: Apache

DBMS: MySQL

METHODOLOGY

This program will be conducted with interactive lectures, PowerPoint presentation, discussions and practical exercise

Module 1 – REST Basics

  • The REST Vision
  • Use of HTTP
  • Use of URIs
  • Use of Content Types
  • CRUD Operations and Business Operations

Overview

  • The Maven pom.xml
  • The Java based Web Configuration

Overview

  • Understanding REST in Spring
  • The Java Configuration
  • Testing the Spring Context
  • The Controller
  • Mapping the HTTP response codes
  • Additional Maven dependencies

Module 4 – Persistence with JDBC

  • Reducing Code Complexity
  • The DataAccessException Hierarchy
  • JdbcTemplate
  • RowMapper<T> and ResultSetExtractor<T>
  • The DaoSupport Hierarchy
  • Transaction Handling

Module 5 – Persistence with JPA

  • Object/Relational Mapping
  • The Java Persistence API
  • JpaDaoSupport and JpaTemplate
  • @PersistenceUnit and @PersistenceContext
  • Shared Entity Managers
  • The @Transaction Annotation
  • Isolation and Propagation
  • A Limitation of @Transactional
  • Understanding Entity States
  • Optimistic Locking
  • Bi-Directional Associations and Serialization
  • Using @XmlTransient
  • Using @JsonView

Overview

  • Spring Security in the web.xml
  • The Security Configuration
  • Maven and other trouble

Overview

  • Spring Security Basic Authentication
  • Consuming the Secured Application
  • Further Configuration – The Entry Point
  • The Maven Dependencies

Overview

  • The Security XML Configuration
  • Consuming the Secured Application
  • The Maven Dependencies

Overview

  • Configuration of Basic Authentication
  • Configuration of Digest Authentication
  • Supporting both authentication protocols in the same RESTful service
  • Testing both scenarios

Overview

  • The Basics
  • Client-Server Communication with JSON
  • Custom Converters Configuration – adding XML Support
  • Using Spring’s RestTemplate with Http Message Converters

Overview

  • REST and ETags
  • Client-Server communication with curl
  • ETag support in Spring
  • Testing ETags
  • More on ETags

Overview

  • Page as Resource vs Page as Representation
  • The Controller
  • Discoverability for REST pagination
  • Test Driving Pagination
  • Test Driving Pagination Discoverability
  • Getting All Resources
  • REST Paging with Range HTTP headers

Overview

  • Solution #1 - The Controller level @ExceptionHandler
  • Solution #2 - The HandlerExceptionResolver
  • Solution #3 - The new @ControllerAdvice

Module 14 – Versioning a REST API

  • The Problem
  • What is in the Contract?
  • High Level Options
  • Advantages and Disadvantages
  • Possible Changes to the API

Overview

  • Goals
  • Testing Infrastructure
  • The JSON and XML Marshallers
  • Consuming the Service with both JSON and XML
  • Maven and Jenkins

Programme scope, delivery arrangements and suitability are confirmed during enquiry.