Book description
Over 100 hands-on recipes to build web applications easily and efficiently IN Spring 5.0
About This Book
- Solve real-world problems using the latest features of the Spring framework like Reactive Streams and the Functional Web Framework.
- Learn how to use dependency injection and aspect-oriented programming to write compartmentalized and testable code.
- Understand when to choose between Spring MVC and Spring Web Reactive for your projects
Who This Book Is For
Java developers who would like to gain in-depth knowledge of how to overcome problems that they face while developing great Spring applications. It will also cater to Spring enthusiasts, users and experts who need an arena for comparative analysis, new ideas and inquiries on some details regarding Spring 5.0 and its previous releases. A basic knowledge of Spring development is essential
What You Will Learn
- Understand how functional programming and concurrency in JDK 1.9 works, and how it will affect Spring 5.0
- Learn the importance and application of reactive programming in creating services, and also the process of creating asynchronous MVC applications
- Implement different Spring Data modules
- Integrate Spring Security to the container
- Create applications and deploy using Spring Boot
- Conceptualize the architecture behind Microservices and learn the details of its implementation
- Create different test cases for the components of Spring 5.0 components
In Detail
The Spring framework has been the go-to framework for Java developers for quite some time. It enhances modularity, provides more readable code, and enables the developer to focus on developing the application while the underlying framework takes care of transaction APIs, remote APIs, JMX APIs, and JMS APIs.
The upcoming version of the Spring Framework has a lot to offer, above and beyond the platform upgrade to Java 9, and this book will show you all you need to know to overcome common to advanced problems you might face.
Each recipe will showcase some old and new issues and solutions, right from configuring Spring 5.0 container to testing its components. Most importantly, the book will highlight concurrent processes, asynchronous MVC and reactive programming using Reactor Core APIs. Aside from the core components, this book will also include integration of third-party technologies that are mostly needed in building enterprise applications.
By the end of the book, the reader will not only be well versed with the essential concepts of Spring, but will also have mastered its latest features in a solution-oriented manner.
Style and Approach
This book follows a cookbook style approach, presenting a problem and showing you how to overcome it with useful recipes. The examples provided will help you code along as you learn.
Table of contents
- Preface
-
Getting Started with Spring
- Installing Java Development Kit 1.8
- Installing Tomcat 9 and configuring HTTP/2
- Installing STS Eclipse 3.8 IDE
- Creating Eclipse projects using Maven
- Creating Spring STS Eclipse projects using Gradle
- Deploying Spring projects using Maven
- Deploying Spring projects using Gradle
- Installing the MySQL 5.7 database server
- Installing the MongoDB 3.2 database server
-
Learning Dependency Injection (DI)
- Implementing a Spring container using XML
- Implementing a Spring container using JavaConfig
- Managing beans in an XML-based container
- Managing beans in the JavaConfig container
- Creating Singleton and Prototype beans
- Defining eager and lazy spring beans
- Creating an inner bean
- Injecting Collections and Properties
- Creating a Spring MVC using an XML-based approach
- Creating a Spring MVC using the JavaConfig approach
- Generating multiple ApplicationContexts
- Using ResourceBundleMessageSource for Views
-
Implementing MVC Design Patterns
- Creating the simple @Controller
- Creating a simple @Controller with method-level URL mapping
- Designing a simple form @Controller
- Creating a multi-action @Controller
- Form validation and parameter type conversion
- Creating request- and session-scoped beans
- Implementing page redirection and Flash-scoped beans
- Creating database connection pooling
- Implementing the DAO layer using the Spring JDBC Framework
- Creating a service layer in an MVC application
-
Securing Spring MVC Applications
- Configuring Spring Security 4.2.2
- Mapping sessions to channels and ports
- Customizing the authentication process
- Implementing authentication filters, login success, and failure handlers
- Creating user details
- Generating encrypted passwords
- Applying Security to MVC methods
- Creating roles and permissions from the database
- Managing and storing sessions
- Solving Cross-Site Request Forgery (CSRF) and session fixation attacks
- Solving Cross-Site Scripting (XSS) and clickjacking attacks
- Creating interceptors for login data validation
-
Cross-Cutting the MVC
- Logging and auditing service methods
- Managing DAO transactions
- Monitoring services and request handlers
- Validating parameters and arguments
- Managing exceptions
- Implementing the caching mechanism
- Intercepting request transactions
- Implementing user authentication
- Accessing with restrictions
- Controlling concurrent user access
- Implementing a mini-workflow using AOP
-
Functional Programming
- Implementing lambda expressions using anonymous inner classes
- Implementing lambda expression using @FunctionInterface
- Applying the built-in functional interfaces
- Applying method and constructor references
- Using the Stream API
- Applying streams to collections
- Applying streams to NIO 2.0
- Using parallel streams
-
Reactive Programming
- Applying the observer design pattern using Reactive Streams
- Creating Mono<T> and Flux<T> publishers
- Implementing the Subscriber<T> interface
- Applying backpressure to Mono<T> and Flux<T>
- Managing task executions using Schedulers
- Creating concurrent and parallel emissions
- Managing continuous data emission
- Implementing Stream manipulation and transformation
- Testing Reactive data transactions
- Implementing Reactive events using RxJava 2.x
-
Reactive Web Applications
- Configuring the TaskExecutor
- Implementing @Async services
- Creating asynchronous controllers
- Creating @Scheduled services
- Using Future<T> and CallableFuture<T>
- Using Mono<T> and Flux<T> publishers for services
- Creating Mono<T> and Flux<T> HTTP response
- Integrating RxJava 2.0
- Using FreeMarker to render Publisher<T> stream
- Using Thymeleaf to render a Publisher<T> stream
- Applying security on TaskExecutors
-
Spring Boot 2.0
- Building a non-reactive Spring MVC application
- Configuring Logging
- Adding JDBC Connectivity
- Building a reactive Spring MVC application
- Configuring Spring Security 5.x
- Using reactive view resolvers
- Using RouterFunction and HandlerFunction
- Implementing Spring Data with JPA
- Implementing REST services using @RestController and Spring REST
- Applying Spring Cache
-
The Microservices
- Exposing RESTful services in Spring 5
- Using the actuator REST endpoints
- Building a client-side application with RestTemplate, AsyncRestTemplate and, WebClient
- Configuring the Eureka server for service registration
- Implementing the Eureka service discovery and client-side load balancing
- Applying resiliency to client applications
- Consuming endpoints using a declarative method
- Using Docker for deployment
-
Batch and Message-Driven Processes
- Building synchronous batch processes
- Implementing batch processes with a database
- Constructing asynchronous batch processes
- Building synchronous interprocess communication using AMQP
- Creating asynchronous send-receive communication
- Creating an event-driven asynchronous communication using AMQP
- Creating stream communication with Spring Cloud Stream
- Implementing batch processes using Spring Cloud Task
-
Other Spring 5 Features
- Using Hibernate 5 object-relational mapping
- Applying Hazelcast distributed caching
- Building client-server communications with WebSocket
- Implementing Reactive WebSocket communication
- Implementing asynchronous Spring Data JPA properties
- Implementing Reactive Spring Data JPA repositories
- Using Spring Data MongoDB
- Building applications for big data storage
- Building a Spring 5 application using Kotlin
-
Testing Spring 5 Components
- Creating tests for Spring MVC components
- Building standalone controller tests
- Creating tests for DAO and service layers
- Creating tests on secured applications
- Creating tests using Spring Boot 2.0
- Creating tests for Spring Data JPA
- Building tests for blocking, asynchronous and reactive RESTful services
- Building tests for Kotlin components
Product information
- Title: Spring 5.0 Cookbook
- Author(s):
- Release date: September 2017
- Publisher(s): Packt Publishing
- ISBN: 9781787128316
You might also like
book
Spring 5.0 By Example
Discover the real power of Spring Framework 5.0 and learn to create powerful applications in its …
book
Spring 5 Recipes: A Problem-Solution Approach
Solve all your Spring 5 problems using complete and real-world code examples. When you start a …
book
Spring 5.0 Projects
Discover the latest features of Spring framework by building robust, fast, and reactive web applications Key …
book
Spring Boot 2.0 Cookbook - Second Edition
Take your application development skills to the next level by implementing Spring Boot features effectively About …