1. Agenda
What is CRUD?
What is REST?
What is Spring?
What is HATEOAS?
What is Microservice?
So… hands on!
2. What is CRUD?
“In computer programming, create, read, update and delete
(as an acronym CRUD) (Sometimes called SCRUD with an "S" for
Search) are the four basic functions of persistent storage.”
http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
3. What is REST?
“Representational state transfer (REST) is an abstraction of the
architecture of the World Wide Web; more precisely, REST is an
architectural style consisting of a coordinated set of
architectural constraints applied to components, connectors,
and data elements, within a distributed hypermedia system.”
http://en.wikipedia.org/wiki/REST
4. Basic CRUD with REST
Operation HTTP / REST
Create PUT / POST
Read (Retrieve) GET
Update (Modify) PUT / PATCH
Delete (Destroy) DELETE
5. What is Spring?
“The Spring Framework is an open source application
framework and inversion of control container for the Java
platform.”
http://en.wikipedia.org/wiki/Spring_Framework
Inversion of control container is also called dependency
injection
Supports many templating engines for web-service and also
full-featured dynamic web-sites.
Support for popular Frameworks such as Bootstrap, Vaadin,
Thymleaf, etc. etc. etc.
6. Inversion of control container / dependency
injection:
Rather than instantiating an object using the new keyword, the
container injects (and manages) a reference for you.
This may seem just a delegation swap, but it has important
implications for the scope of those objects.
You have seem dependency injection in FXML already.
Inversion of control container is also called dependency
injection
7. What is HATEOAS?
“HATEOAS, an abbreviation for Hypermedia as the Engine of
Application State, is a constraint of the REST application
architecture that distinguishes it from most other network
application architectures.”
http://en.wikipedia.org/wiki/HATEOAS
9. What is Microservice?
“The term "Microservice Architecture" has sprung up over the last
few years to describe a particular way of designing software
applications as suites of independently deployable services.”
http://martinfowler.com/articles/microservices.html
10. What are “Web Services”?
A service is a software entity that can be discovered and
invoked by other software systems.
11. More precisely: Web Service
A web service is just a web page meant for a computer to request and
process
More precisely, a Web service is a Web page that’s meant to be
consumed by an autonomous program as opposed to a Web browser
which is for human consumption.
12. Microservices Reference
The “ID” on a HATEOAS system is mainly an URI
Example: If you create a “teacher”, his “id” will be
“http://localhost:8080/teacher/1” instead of just “1”.
Then, each Microservice can reference other services entities.
17. A very basic app
>my first spring app
@RestController is used in conjunction with @RequestMapping
18. What is a bean?
> add Service implementation details
There are four types of beans that spring will manage: component,
service, controller, repository
Controller: often times a RestController which defines routes, produces and
consumes defintions.
Service: This is where you put your business logic. Typically defined as an
interface to CRUD + L.
Repository: defines low-level DB operations, mostly inherited.
Component: everything else.
20. What is REST ?
REST is a term coined by Roy Fielding to describe an
architecture style of networked systems. REST is an
acronym standing for REpresentational State Transfer.
22. Two Fundamental Aspects of the REST
Design Pattern
Resources
Every distinguishable entity is a resource. A resource
may be a Web site, an HTML page, an XML document,
a Web service, a physical device, etc.
URLs Identify Resources
Every resource is uniquely identified by a URL. This is
Tim Berners-Lee Web Design, Axiom 0.
22
23. Why is it called Representational State Transfer ?
Client Resource
http://weather.example.com/oaxaca
OaxacaWeather.html
24. "Representational State Transfer is intended to evoke an image of
how a well-designed Web application behaves: a network of web
pages (a virtual state-machine), where the user progresses
through an application by selecting links (state transitions),
resulting in the next page (representing the next state of the
application) being transferred to the user and rendered for their
use."
Roy Fielding.
25. REST and HTTP
HTTP 1.1 was designed to conform to REST
Its methods are defined well enough to get work done
Unsurprisingly, HTTP is the most RESTful protocol
But it's possible to apply REST concepts to other protocols and systems
26. REST - An Architectural Style of Networked System
Utilize the underlying architectural model of the world
wide web – rather than inventing your own.
Guiding framework for Web protocol standards.
REST based web services
Online shopping
Search services
Dictionary services
27. Characteristics of a REST based network
Client-Server: a pull-based interaction style(Client request data from servers as
and when needed).
Stateless: each request from client to server must contain all the information
necessary to understand the request, and cannot take advantage of any stored
context on the server.
Cache: to improve network efficiency, responses must be capable of being
labeled as cacheable or non-cacheable.
Uniform interface: all resources are accessed with a generic interface (e.g.,
HTTP GET, POST, PUT, DELETE).
Named resources - the system is comprised of resources which are named
using a URL.
Interconnected resource representations - the representations of the
resources are interconnected using URLs, thereby enabling a client to progress
from one state to another, and to communicate statelessly to whichever
resource it needs on the web.
28. Web Design, Axiom 0
(Tim Berners-Lee, director of W3C)
Axiom 0: all resources on the Web must be uniquely identified
with a URI.
28
resource1
URL1
resource2
URL2
resource3
URL3
29. Approach 2:
URLs are Cheap! Use Them!
The airline provides several URLs - one URL for premier members,
a different URL for frequent flyers, and still another for regular
customers.
29
Premier Members
Frequent Flyer Members
Regular Members
client
client
client
http://www.kings-air/reservations/premier
http://www.kings-air/reservations/frequent-flyer
http://www.kings-air/reservations/regular
Premier
Member
Reservation
Service
Frequent
Flyer
Reservation
Service
Regular
Member
Reservation
Service
30. This Ain't the
REST Design Pattern
30
Premier Members
Frequent Flyer Members
Regular Members
Airline Reservation
Answering
Machine
Premier
Customer
Representative
F.F.
Customer
Representative
Regular
Customer
Representative
“press 7 to be
connected to the
Executive club”
31. This is the
REST Design Pattern
31
Premier Members
Frequent Flyer Members
Regular Members
1-800-Premier
Premier
Customer
Representative
F.F.
Customer
Representative
Regular
Customer
Representative
1-800-Frequent
1-800-Reservation
Numbers are cheap, use them.
32. This ain't the
REST Design Pattern
32
Premier Members
Frequent Flyer Members
Regular Members
Reservation
Web
Service
Determine
Priority
Premier
Customer
F.F.
Customer
Regular
Customer
client
client
client
33. This is the
REST Design Pattern
33
Premier Members
Frequent Flyer Members
Regular Members
client
client
client
http://www.kings-air/reservations/premier
http://www.kings-air/reservations/frequent-flyer
http://www.kings-air/reservations/regular
Premier
Member
Reservation
Service
Frequent
Flyer
Reservation
Service
Regular
Member
Reservation
Service
URLs are cheap, use them.
39. Atividade – Construindo uma tela de
busca de endereço
Eu. como usuário do sistema, preciso de uma tela que busque na base
dos correios as informações de endereço completo, passando para isso
o CEP do logradouro.
Para resolver este caso vamos implementar um sistema que funcione
desta forma:
•Usar o selenium para buscar as informações na página dos Correios;
•Usar SpringBoot para criar o Service Rest que exporá as informações
de CEP para os consumidores;