Building Spring/JPA RESTful services with Angular front-end

Duration: 5 days

This courses teaches the following topics

  • Spring and Spring Boot to developer Restful services (2 days)
  • JPA/Hibernate (2 days)
  • Introduction to Angular as a front-end (1 day)

To get the greatest benefit from this course you should be an experienced Java Developer. Students should also be familiar with JavaScript and have a strong understanding of HTML/CSS. Some experience with TypeScript would be helpful.

Please find the course objectives below:

This highly stimulating course guides students through all the steps required to build secure contemporary RESTful services as well as rich and easy-to-maintain HTML5 web applications using the fantastic Spring MVC framework.

During this course you will be exposed to: Spring, Spring with JPA/Hibernate, Spring MVC, building Restful services, Jackson, For some exercises you will be using Spring Boot. The build system during the course is gradle

Spring (2 days)

Core Spring

Introduction

  • Introduction to Spring
  • Spring in a historical context
  • Introduction to dependency injection and inversion of control (IOC)
  • Overview of Spring modules
  • Setting up Spring projects with Gradle (also maven and sbt)

Inversion of Control

  • Spring configuration using (namespace driven) XML
  • Java based Spring configuration (@Configuration)
  • Understanding the Application Context and related interfaces
  • Initialising an application
  • Defining and configuring beans in XML
  • Life-cycle callbacks (init, destroy)
  • Defining bean creation (constructor params, factory methods)
  • Understand bean scopes
  • Property and constructor injection
  • Injecting beans
  • Injecting values
  • Defining lists, maps, properties,… in the spring configuration
  • Auto-wiring by type and by name
  • Bean configuration inheritance
  • Overview spring namespaces for XML configuration
  • The util namespace
  • Externalising configuration with property files using Property Placeholders
  • Using Profiles

Annotation-driven

  • Enabling and using annotation driven configuration
  • Overview of Spring, JSR250 and JSR330 annotations
  • Dependency inject by type (@Autowired/@Inject) and by value (@Resource)
  • Using the @Primary annotation
  • Using Spring Qualifiers
  • Using JSR330 Qualifiers
  • Component scanning
  • Using stereotype annotations
  • Using other techniques for scanning (regex, …)
  • Fine tuning scanning
  • Using Profiles

Java configuration

  • Using @Configuration and @Bean
  • Configure beans (names, Life-cycle methods, scope)
  • bean references in the configuration
  • Injecting beans into the configuration
  • Enabling component scanning
  • Using @Import
  • Obtaining the AnnotationConfigApplicationContext

I18 and and more

  • Using Factory Beans
  • Registering Component Editors
  • Internationalisation

Spring Test Framework

Here we merely introduce te Spring Test Framework. Concepts such as database integration tests, transactional tests, mocks, testing web mvc application are explained in their respective session.

  • Introduction to Spring Testing
  • Using it with junit
  • Loading the context configuration using @ContextConfiguration
  • Using Dependency Injection for your test fixture
  • Using profiles during testing
  • Use other spring test annotations (@Timed, @Repeat, @DirtiesContext)

Spring data access

Introduction

  • Understand the module's architecture
  • Understand its features
  • Define Datasources (JNDI, DBCP, C3P0, HikariCP)
  • Introduce repository classes
  • Introduction to template classes
  • Using DaoSupport
  • Understand Spring's consistent exception translation for repositories
  • Managing Transactions
  • Programmatic and Declarative transaction management
  • List various platform transaction managers (DataSource, Jta, Jpa, …)
  • Understand the seven transaction attributes
  • Setting transaction isolation levels
  • Managing transaction time-outs
  • Using Spring Test for database integration tests
  • Executing sql scripts using @Sql during testing

JDBC

  • Using templates (JdbcTemplate/NamedParameterJdbcTemplate)
  • query and update the database using templates
  • Using different parameters sources
  • Use different result mapping techniques
  • Query for single results
  • Query for *multiple** results
  • Working with generated keys
  • Working with exceptions
  • Using jdbc classes such as SimpleJdbcInsert
  • Introduce RDBMS Objects such as SqlUpdate

Introduction to Spring Boot

  • Introduce idea and architecture behind SpringBoot
  • Discuss various starters (Spring Initializr)
  • Setting up a gradle project for spring boot
  • Use the spring boot cli (command line interface)
  • Configure a SpringBoot application
  • Using yaml configuration for datasources
  • Configure for logging
  • List other key configuration properties
  • Setting up your own properties
  • Bootstrap the SpringBoot application

Introduction to Spring MVC

  • Introduce the Spring MVC architecture
  • Discuss Spring MVC's features
  • Introduce the DispatchServlet
  • Configure Spring MVC using Java configuration (Servlet Environment)
  • Configure Spring MVC inside a Spring Boot application
  • Introduce controllers and RequestMapping
  • Map URIs and HTTP methods
  • Handle request parameters
  • Handle http headers
  • List the possible return types of handler methods
  • Overview of Handling exceptions
  • Using the @ControllerAdvice

Testing Spring MVC

  • Introduction to Testing Spring MVC Applications
  • Mocking Spring MVC
  • Understand how to use the RequestBuilder
  • Supply parameters, mime-types, headers, cookies, …
  • Setup expectations with ResultMatcher
  • Using jsonPath to state expectations on returned json data

Rest with Spring

Introduction

  • Overview of Rest with Spring
  • Creating ResultController implementations
  • More on URL Patterns mapping (path variables, regex)
  • Handle mime-types
  • Using HttpEntity in handler methods
  • Validating data using jsr303

Jackson

  • Introduction to Jackson
  • Mapping pojos to json/xml/protobuf etc.
  • Use Jackson annotations
  • Mapping null, Optional.none, and empty strings values
  • Introduce Jacksons Views
  • Discuss various plugins for data types (most notably jdk8 and jsr310)
  • Same for data formats (xml, protobuf, avro, …)
  • Configuring Jackson with Spring
  • Configure Spring's content negotiation

JPA/Hibernate (2 days)

Introduction

  • Architecture of JPA
  • When to use JPA (benefits), and when not to use JPA (disadvantages)
  • Problems solves by an ORM

Getting Started

  • JPA Configuration (defining a persistence unit)
  • Writing Entities
  • Provide mapping meta-data using XML
  • Provide mapping meta-data using annotations
  • Introduction to the EntityManagerFactory and EntityManager
  • Use the EntityManager API
  • Injecting EntityManagerFactory and EntityManager instances with Spring
  • Introduction to transactions

Core ORM

  • list different types of objects (Entities, values, embeddables, collections)
  • Mapping entities to tables
  • Use various primary keys strategies
  • Mapping columns
  • Model composites/aggregates using Embeddables
  • Mapping collections and maps of values and embeddables

Associations

  • Recap OO semantics of associations
  • Map one-to-one using shared pirmary key
  • Mapping one-to-one using a foreign key
  • Map one-to-many/many-to-one using foreign keys and mapping tables
  • Map many-to-one and many-to-many using mapping tables
  • Map bidirectional and unidirectional associations
  • Appreciate the passive (aka inverse) end of the associations
  • Cascade options
  • Mapping Qualified Associations using java.util.Map
  • Manage lazy loading
  • Discuss performance implications

Inheritance

  • Discuss various options for mapping inheritance
  • Map using Single Table per Class Hierarchy
  • Map using Joined Subclass
  • Map using Table per Concrete class
  • Understand discriminators (columns/values)
  • Discuss performance implications per inheritance mapping strategy
  • Understand impact on instanceof and type-casting

Introduction to Angular (1 day)

During the course we give you the basics of Angular (4.x) and use it as a front-end framework for the services developed earilier in the course.

Core

  • Understand the role of components
  • Develop Components (using decorators)
  • Bootstrapping an angular 2 application
  • Understand ngModule
  • Appreciate the different data binding styles (property, event, two-way, class, style, ...)
  • Use Interpolation and built-in directives
  • Understand and develop pipes
  • Building forms with angular (including validation)

Accessing Restful Services

  • More on dependency injection
  • Define services
  • Register and inject services
  • Different injection techniques (named, using a factory)
  • Understand Promises

This course has been designed to deliver maximum knowledge transfer and understanding while remaining dynamic and engaging.

For an onsite course please contact us