2. 2
About Us
Josh Juneau
Application Developer
Database Administrator
Author, Blogger, Podcaster
Apache NetBeans Committer/Java
Champions/Jakarta EE Guardians
Chicago Java Users Group Executive Board
Edwin Derks
Software Architect
Author, Blogger, Speaker
Contributor for Jakarta EE
Committer for MicroProfile
Member of Jakarta EE Guardians
@edwinderks
3.
4. 4
Agenda
- Demonstrate some cool features with Jakarta EE and MicroProfile that you
don't use everyday
- We will monitor the Q&A in order to answer your questions and feedback
during the session
6. 6
Get Started Today
Download GlassFish 6, Payara Runtime and others?
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.
Specification Documents
Examples for this demo:
https://github.com/juneau001/JakartaEE-MicroProfile-Demos
7. 7
Jakarta EE 9 Overview
Namespace Change
● javax.* to jakarta.*
Specification Documents
Java SE 11 may not be available out of gate, but will be with Jakarta EE 9.1
8. 8
Jakarta CDI
Latest Additions:
- Modularization, support for Java SE
- Observers Ordering
- Asynchronous Events
- Configurators for major SPI elements
- Configure or Veto Observer Methods
- Apply Interceptor on Producers
9. 9
Jakarta CDI - Async
How does one mark a CDI event as asynchronous?
Solution:
Fire the event calling upon the fireAsync() method, passing the event class.
10. 10
Jakarta CDI - Async
Example of logging on event execution:
Utilize @ObservesAsync to reserve an asynchronous event.
11. 11
Jakarta JSON Binding
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
12. 12
Jakarta JSON Binding
Read a JSON document and convert it into a Java object
Utilize default JSON binding mapping to quickly map a POJO.
14. 14
Jakarta JSON Processing
- 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
15. 15
Jakarta JSON Processing
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 specified value within a JSON document with
another value.
- Editing/Transformation Operations Added to the JSON Object Model
JSON defines only two data structures: Objects, Arrays
JSON define seven value types: String, number, object, array, true, false, null
16. 16
Jakarta Server Faces
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..
17. 17
Jakarta RESTful Web Services
JAX-RS Client
The examples utilize JSF views and @ViewScoped controller classes to interact
with remote web services to update the database.
18. 18
Jakarta RESTful Web Services
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
19. 19
Jakarta Security
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
- Simplified HttpAuthenticationMechanism interface with three default
implementations: basic, form, LDAP
20. 20
Jakarta Bean Validation
Validate field content using simple annotations
- Support for more flexible 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
21. 21
Jakarta Persistence
Updated in latest releases:
- Streams
- Repeatable Annotations
- Date-Time API
- CDI Injection in AttributeConverters
22. 22
Jakarta WebSockets
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
24. 24
MicroProfile - Health
Health probes for Kubernetes
- Liveness vs Readiness probes
- liveness probe; restart container when not healthy
- readiness probe; when container is ready to receive traffic
Example:
- Programmatic readiness probe
25. 25
MicroProfile - Config
Property injection
- This specification is not part of the Jakarta EE (yet)
- 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 MicroProfile complement each other
26. MicroProfile - RestClient
HTTP client specification
- JAX-RS and MP RestClient both have programmatic client
- MP RestClient can annotate interfaces
Example:
- Use CDI and MP Config to inject the MP RestClient with an
environment-specific URL
27. MicroProfile - 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
28. MicroProfile - 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 defined threshold
- @Bulkhead Limit concurrent requests to a downstream service