1. COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 1
February 17th, 2021
Josh Juneau & Edwin Derks
@javajuneau | @edwinderks
Jakarta EE & MicroProïŹle
2. 2
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 2
About Us
Josh Juneau
Chicago Java Users Group
Executive Board
Application Developer
Database Administrator
Author, Blogger, Podcaster
Apache NetBeans Committer/Java
Champions/Jakarta EE Guardians
Edwin Derks
Software Architect
Author, Blogger, Speaker
Contributor for Jakarta EE
Committer for MicroProïŹle
Member of Jakarta EE Guardians
3. 3
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 3
Agenda
- Demonstrate some cool features with
Jakarta EE and MicroProïŹle that
- are key features
- you possibly don't use everyday
- We will monitor the Q&A in order to answer
your questions and feedback during the
session
4. COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Jakarta EE 9
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
5. 5
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Download Payara Server or Payara Micro (Jakarta EE 8, MP 3.3)
Incorporate the dependencies into your project...the examples in this
presentation use Jakarta EE 8.
Jakarta EE 9 will NOT be backward compatible with Jakarta EE 8.
SpeciïŹcation Documents
Examples for this demo:
https://github.com/juneau001/JakartaEE-MicroProïŹle-Demos
5
Get Started Today
6. 6
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Namespace Change
â javax.* to jakarta.*
SpeciïŹcation Documents
Java SE 11 support is not be available out of gate, but will be
with Jakarta EE 9.1
6
Jakarta EE 9 Overview
7. 7
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Latest Additions:
- Modularization, support for Java SE
- Observers Ordering
- Asynchronous Events
- ConïŹgurators for major SPI elements
- ConïŹgure or Veto Observer Methods
- Apply Interceptor on Producers
7
Jakarta CDI
8. 8
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
How does one mark a CDI event as asynchronous?
Solution:
Fire the event calling upon the ïŹreAsync() method, passing the event class.
8
Jakarta CDI - Async
9. 9
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Standard binding layer for converting Java objects to/from JSON.
- Serialize/de-serialize objects to/from JSON
- Mapping of Primitive Types
- Serialize Collections and Maps
9
Jakarta JSON Binding
10. 10
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Read a JSON document and convert it into a Java object
Utilize default JSON binding mapping to quickly map a POJO.
10
Jakarta JSON Binding
11. 11
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Create JSON from a Java Object
11
Jakarta JSON Binding
12. 12
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
- Jakarta EE provides an API to parse, transform, and query JSON data
using the object model or streaming model
- JsonObjectBuilder is used to build a JSON object
- Call upon the Json.createObjectBuilder() method to create a
JsonObjectBuilder.
- Call upon the Json.createArrayBuilder() method to create a JsonArray
12
Jakarta JSON Processing
13. 13
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
JSON Pointer and JSON Patch
JSON Pointer allows one to point to a particular element within a JSON
Structure
Utilize JSON Patch to replace a speciïŹed value within a JSON document
with another value.
- Editing/Transformation Operations Added to the JSON Object Model
JSON deïŹnes only two data structures: Objects, Arrays
JSON deïŹne seven value types: String, number, object, array, true, false,
null 13
Jakarta JSON Processing
14. 14
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
LocalDateTime Conversion
Ability to convert Date-Time API values to/from expression language
JSF as Microservices Front End
The examples utilize JSF views and @ViewScoped controller classes to
interact with remote web services, which in-turn, performs transactions
against an RDBMS..
14
Jakarta Server Faces
15. 15
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
JAX-RS Client
The examples utilize JSF views and @ViewScoped controller classes to
interact with remote web services to update the database.
15
Jakarta RESTful Web Services
16. 16
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Server Sent Events
- One way communication channel
- Text protocol, âtext/event-streamâ media type
- Multiple Messages
- Retry interval
SSEEventSink used to send stream of messages
SSEEvent is base event class, OutboundSseEvent packages an event
16
Jakarta RESTful Web Services
17. 17
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Standard Security Provided
- Ability to apply across multiple identity stores: Database, LDAP,
Embedded
- Annotations for ease of development
- Remembers caller (cookie, identity store)
- Group to Role Mapping
- Standard expression language accessors
- SimpliïŹed HttpAuthenticationMechanism interface with three default
implementations: basic, form, LDAP
17
Jakarta Security
18. 18
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Validate ïŹeld content using simple annotations
- Support for more ïŹexible cascaded validation of constraint types
- Support for java.util.Optional
- Support for @Past and @Future
- New annotations: @Email, @NotEmpty, @NotBlank, @Positive,
@PositiveOrZero, @Negative, @NegativeOrZero, @PastOrPresent,
@FutureOrPresent
18
Jakarta Bean Validation
19. 19
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Updated in latest releases:
- Streams
- Repeatable Annotations
- Date-Time API
- CDI Injection in AttributeConverters
19
Jakarta Persistence
20. 20
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Full-Duplex Communication Between Peers
- Create a WebSocket endpoint by annotating a POJO with
@ServerEndpoint
- Create a message receiver method and annotate with @OnMessage
- Supports:
- @OnOpen
- @OnError
20
Jakarta WebSockets
21. COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
MicroProïŹle
22. 22
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 22
MicroProïŹle - Health
Health probes for Kubernetes
â Liveness vs Readiness probes
â liveness probe restart container when
not healthy
â readiness probe when container is ready
to receive traïŹc
Example
â Programmatic readiness probe
23. 23
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 23
MicroProïŹle - ConïŹg
Property injection
â This speciïŹcation is not part of Jakarta EE
â Spring Framework/Boot does also contain this
feature
â Can inject properties provided by the app or the
environment, like Kubernetes
Example
â Inject in Jakarta EE JAX-RS endpoint
â This is an example of where Jakarta EE and
MicroProïŹle complement each other
24. 24
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 24
MicroProïŹle - RestClient
HTTP client speciïŹcation
â JAX-RS and MP RestClient both have
programmatic client
â MP RestClient can annotate interfaces
Example
â Use CDI and MP ConïŹg to inject the MP
RestClient with an environment-speciïŹc
URL
25. 25
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 25
MicroProïŹle - FaultTolerance
Increase the success rate of your
requests by adding resilience to
requests
Good practice to add:
@Retry how many times will the request be
repeated on error
@Timeout how long will the client wait for a
response
@Fallback what will the behaviour be when no
retries are left
26. 26
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) 26
MicroProïŹle - FaultTolerance
Increase the success rate of your
requests by adding resilience to
requests
More advanced tuning of resilience:
@CircuitBreaker fail incoming requests when calls to a
downstream service are
subsequently failing over a deïŹned
threshold
@Bulkhead Limit concurrent requests to a
downstream service
27. COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Infrastructure
28. 28
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
Ship your dependencies as part of the infrastructure
â Download and ship your project's dependency together with the
Docker Image
28
Docker Image
29. 29
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
30. Thank you!
COPYRIGHT (C) 2020, ECLIPSE FOUNDATION, INC. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)