Spring Essentials
eBook - ePub

Spring Essentials

  1. 260 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

About this book

Build mission-critical enterprise applications using Spring Framework and Aspect Oriented Programming

About This Book

  • Step into more advanced features of aspect-oriented programming and API components to build enterprise grade systems
  • Build lightning-fast web applications and REST APIs using Spring MVC and its asynchronous processing capabilities with the view technologies of your choice
  • Explore simplified but powerful data access techniques including JPA (Java Persistence Architecture) repositories and NoSQL data access

Who This Book Is For

If you are a Java developer who is looking to master Enterprise Java Development using Spring Framework, then this book is ideal for you. Prior understanding of core Java programming and a high-level understanding of Spring Framework is recommended. Having sound knowledge of servlet-based web development in Java and basic Database concepts would be an advantage but not a requirement.

What You Will Learn

  • Set up and build standalone and web-based projects using Spring Framework with Maven or Gradle
  • Get familiar with JSP Form processing using Spring and Form Tag Library
  • Develop RESTful API applications for XML and JSON data transfers with non-blocking asynchronous capabilities
  • Explore Spring's comprehensive transaction support for declarative Transaction Management and its integration with Spring's data access abstractions
  • Investigate Spring Data access mechanisms with Spring Data Repositories, a simple and consistent data-access abstraction
  • Construct real-time applications using WebSocket with a SockJS fallback option
  • Understand how to secure your Spring Web and standalone applications using Spring Security declaratively and consistently
  • Get to grips with the end-to-end development of an API-based modern SPA using EmberJS at the front end and SpringMVC at the back end

In Detail

Spring is an open source Java application development framework to build and deploy systems and applications that run on the JVM. It is the industry standard and the most popular framework among Java developers with over two-thirds of developers using it.

Spring Essentials makes learning Spring so much quicker and easier with the help of illustrations and practical examples. Starting from the core concepts of features such as inversion of Control Container and BeanFactory, we move on to a detailed look at aspect-oriented programming. We cover the breadth and depth of Spring MVC, the WebSocket technology, Spring Data, and Spring Security with various authentication and authorization mechanisms.

Packed with real-world examples, you'll get an insight into utilizing the power of Spring Expression Language in your applications for higher maintainability. You'll also develop full-duplex real-time communication channels using WebSocket and integrate Spring with web technologies such as JSF, Struts 2, and Tapestry. At the tail end, you will build a modern SPA using EmberJS at the front end and a Spring MVC-based API at the back end.By the end of the book, you will be able to develop your own dull-fledged applications with Spring.

Style and approach

This book is a practical guide based on logical modules of the whole Spring Framework family, with a start-small approach, increasing in complexity as it progresses. Every chapter is an amalgamation of theory and practical examples, with further discussion on additional features and approaches.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Spring Essentials


Table of Contents

Spring Essentials
Credits
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Spring Core
The Spring landscape
The Spring Framework modules
Spring Tool Suite (STS)
Spring subprojects
Design concepts behind Spring Framework
Setting up the development environment
Your first Spring application
Inversion of Control explained
Dependency Injection
The Spring IoC container
Configuration metadata
XML-based configuration metadata
Annotation-based configuration metadata
XML-based versus annotation-based configuration
Component stereotype annotations
Java-based configuration metadata
JSR 330 standard annotations
Beans in detail
Bean definition
Instantiating beans
With constructors
With a static factory-method
With an instance factory-method
Injecting bean dependencies
Constructor-based Dependency Injection
Setter-based Dependency Injection
Constructor-based or setter-based DI – which is better?
Cleaner bean definitions with namespace shortcuts
Wiring a List as a dependency
Wiring a Map as a dependency
Autowiring dependencies
Bean scoping
Dependency Injection with scoped beans
Creating a custom scope
Hooking to bean life cycles
Implementing InitializingBean and DisposableBean
Annotating @PostConstruct and @PreDestroy on @Components
The init-method and destroy-method attributes of <bean/>
Container-level default-init-method and default-destroy-method
Working with bean definition profiles
Injecting properties into the Spring environment
Externalizing properties with PropertyPlaceholderConfigurer
Handling resources
Spring Expression Language
SpEL features
SpEL annotation support
The SpEL API
Aspect Oriented Programming
Static and dynamic AOP
AOP concepts and terminology
Spring AOP – definition and configuration styles
XML schema-based AOP
@AspectJ annotation-based AOP
Declaring an @Aspect annotation
Pointcuts
Pointcut designators
Pointcut examples
Advices
The @Around Advice
Accessing Advice parameters
Testing with Spring
Mock objects
Unit and integration testing utilities
Summary
2. Building the Web Layer with Spring Web MVC
Features of Spring MVC
The Model-View-Controller pattern
Your first Spring MVC application
Setting up a Spring MVC application
The project structure of a Spring MVC application
The web.xml file – Springifying the web app
ApplicationContext files in a Spring MVC application
HomeController – @Controller for the home screen
The home.jsp file – the landing screen
Handling incoming requests
The architecture and components of Spring MVC
DispatcherServlet explained
WebApplicationContext – ApplicationContext for the Web
Beans supporting DispatcherServlet and their roles
Controllers in detail
Mapping request URLs with @RequestMapping
URI template patterns with the @PathVariable annotation
Binding parameters with the @RequestParam annotation
Request handler method arguments
Request handler method return types
Setting Model attributes
Building RESTful services for JSON and XML media
Building a RESTful service with RestController
Asynchronous request processing in Spring MVC
Working with views
Resolving views
Resolving JSP views
Binding Model attributes in JSP pages using JSTL
Spring and Spring form tag libraries
Composing a form in JSP
Validating forms
Handling file uploads
Resolving Thymeleaf views
More view technologies
Summary
3. Accessing Data with Spring
Configuring DataSource
Using embedded databases
Handling exceptions in the Spring Data layer
DAO support and @Repository annotation
Spring JDBC abstraction
JdbcTemplate
NamedParameterJdbcTemplate
SimpleJdbc classes
JDBC operations with Sql* classes
Spring Data
Spring Data Commons
Spring Data repository specification
Spring Data JPA
Enabling Spring Data JPA
JpaRepository
Spring Data MongoDB
Enabling Spring Data MongoDB
MongoRepository
Domain objects and entities
Query resolution methods
Using the @Query annotation
Spring Data web support extensions
Auditing with Spring Data
Spring Transaction support
Relevance of Spring Transaction
Spring Transaction fundamentals
Declarative transaction management
Transactional modes – proxy and AspectJ
Defining transactional behavior
Setting rollback rules
Using the @Transactional annotation
Enabling transaction management for @Transactional
Programmatic transaction management
Summary
4. Understanding WebSocket
Creating a simple WebSocket application
STOMP over WebSocket and the fallback option in Spring 4
Broadcasting a message to a single user in a WebSocket application
Summary
5. Securing Your Applications
Authentication
Authorization
The OAuth2 Authorization Framework
Summary
6. Building a Single-Page Spring Application
The motivations behind SPAs
SPAs explained
The architectural benefits of SPAs
SPA frameworks
Introducing Ember.js
The anatomy of an Ember application
Routers
Routes or route handlers
Templates
Components
Models
Controllers
Input helpers
Custom helpers
Initializers
Services
Working with Ember CLI
Setting up Ember CLI
Getting started with Ember CLI commands
The Ember project structure
Working with the POD structure
Understanding the Ember object model
Declaring types (classes) and instances
Accessing and mutating properties
Computed properties
Property observers
Working with collections
Building UI templates using Handlebars
Handlebars helpers
Data binding with input helpers
Using control flow helpers in Handlebars
Using event helpers
Handling routes
Handling UI behavior using components
Building a ToggleButton component step by step
Persisting data with Ember Data
Ember Data architecture
Defining models
Defining model relationships
Building a Taskify application
Building the API server app
Setting up and configuring the project
Defining the model definitions – User and Task
Building API endpoints for the Taskify app
UserController.java
TaskController.java
Building the Taskify Ember app
Setting up Taskify as an Ember CLI project
Setting up Ember Data
Configuring application rout...

Table of contents

  1. Spring Essentials

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Spring Essentials by Shameer Kunjumohamed, Hamidreza Sattari in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Java. We have over one million books available in our catalogue for you to explore.