SlideShare a Scribd company logo
Java EE 8 Recipes
Presented By: Josh Juneau
Author and Application Developer
About Me
Josh Juneau
Day Job: Developer and DBA @ Fermilab
Night/Weekend Job: Technical Writer
- Java Magazine and OTN
- Java EE 7 Recipes
- Introducing Java EE 7
- Java 8 Recipes
JSR 372 EG and JSR 378 EG
Twitter: @javajuneau
Agenda
- Take a look at big picture of Java EE 8
- Resolve a series of real life scenarios using
the features of Java EE 7 and Java EE 8
Before we start. . .
Old: J2EE
Modern: Java EE
Java EE of the Past
(J2EE)
Difficult to Use Configuration
Verbose
Few Standards
Progressive
Improvements
More Productive
Less Configuration
More Standards
Java EE 7 Increases
Productivity Even More
and Introduces
Standards for Building
Modern Applications
Java EE 7 Increased
Productivity
• CDI Everywhere
• JAX-RS Client API,Async Processing
• BeanValidation in EJBs and POJOs
• JSF Flows
• JMS 2.0 - Much Less Code
Java EE 7 Introduced
New Standards
• WebSockets
• JSON-P
• Batch API
• Concurrency Utilities for Java EE
Who uses Java EE?
Java EE 8 Continues
this Momentum
• Continued enhancements for productivity
and web standards alignment
• Cloud enhancements
• Better alignment with Java SE 8
• Work towards a better platform for
development of microservices
Recipes!
Lots to cover…
Recipes!
Statement for Completeness:
Recipes are not meant to provide comprehensive coverage
of the features. Rather, they are meant to get you up and
running with the new functionality quickly, providing the
details you need to know. To learn more details on any of
the features covered, please refer to the online
documentation.
Let’s Cook!
How to Run
Setting up your environment for Java EE 8
• Payara 5 Branch
• Clone git repository and build:
mvn clean install -DskipTests
• Clone and Build/Download latest EA of Spec
• Most have git repositories
JSF 2.3
JSR 372
• New features added in JSF 2.3, adding more flexibility
• Improved CDI Alignment
• PostRenderViewEvent
• WebSocket Integration and Ajax Enhancements
• Java 8 Date-Time Support
• Enhanced Components
• Much More
Problem #1
You would like to work with the Java 8 Date-
Time API via your JSF application. Does not
work with Java EE 7 out of the box.
Solution
Make use of the <f:convertDateTime /> tag.
How it Works
JSF 2.3 requires a minimum of Java 8, so we can make use
of Java 8 goodness.
New type attribute values on <f:convertDateTime>:
• localDate, localTime, localDateTime
• offsetTime,offsetDateTime, zonedDateTime
Problem #2
Oftentimes, you need to work with
FacesContext or another JSF artifact. It can
be cumbersome to obtain the current
instance, ServletContext, etc. time after time.
Problem
FacesContext context =
FacesContext.getCurrentInstance();
ExternalContext externalContext =
FacesContext.getCurrentInstance().getExter
nalContext();
Problem
Map<String, Object> cookieMap =
FacesContext.getCurrentInstance().getExternalContext()
.getRequestCookieMap();
Map<String, Object> viewMap =
FacesContext.getCurrentInstance().getViewRoot(
).getViewMap();
Solution
Inject JSF artifacts in JSF 2.3, and inject into
JSF artifacts.
Solution
@Inject
private ExternalContext externalContext;
@Inject
private ServletContext servletContext;
@Inject
@ViewMap
private Map<String, Object> viewMap;
How it Works
JSF 2.3 provides default producers for
many of the most commonly used JSF
artifacts, therefore, we can now inject
rather than hard-code.
Converters, validators and behaviors are
now also injection targets.
How it Works
BeanValidation
JSR-380
New Features in BeanValidation 2.0:
• Focus on Java SE 8 Features
• Type annotations, Date-TimeValidation, etc.
• Simpler Constraint Ordering on Single Properties
• Custom Payload for ConstraintViolations
Problem #3
You would like to validate dates and times
utilizing the Java 8 Date-Time API to
ensure that they are in the past or in the
future.
Solution
@Future and @Past will work with Java 8
Date-Time
How it Works
• Place validation constraint annotations on a field,
method, or class such as a JSF managed bean or
entity class.
• When the JSF Process Validations phase occurs, the
value that was entered by the user will be validated
based upon the specified validation criteria. At this
point, if the validation fails, the Render Response
phase is executed, and an appropriate error
message is added to the FacesContext. However, if
the validation is successful, then the life cycle
continues normally.
• Specify a validation error message using the
message attribute within the constraint annotation
How it Works
Other New Features:
Type-use annotation:
List<@NotNull @Email String> emails;
Mark standardized constraints with @Repeatable,
eliminating the need for the usage of the @Size.List
pattern.
JSON-P 1.1
JSR-374
The Java API for JSON Processing is a standard for
generation and processing of JavaScript Object
Notation data.
JSON-P provides an API to parse, transform, and
query JSON data using the object model or the
streaming model.
JSON is often used as a common format to
serialize and deserialize data for applications that
communicate with each other over the Internet.
JSON-P 1.1
• Adds new JSON standards for JSON-Pointer
and JSON-Patch
• Provides editing operations for JSON objects
and arrays
• Helper classes and Java SE 8 Support
Problem #4
You would like to build a JSON object model
using Java code.
We wish to create a list of current
reservations.
Solution
Utilize JSON Processing for the Java EE
Platform to build a JSON object model
containing all of the current reservations.
Solution
How it Works
JSON defines only two data structures: objects
and arrays.An object is a set of name-value
pairs, and an array is a list of values. JSON
defines seven value types: string, number, object,
array, true, false, and null.
How it Works
Java EE includes support for JSR 353, which
provides an API to parse, transform, and query
JSON data using the object model or the
streaming model
Make use of JsonObjectBuilder to build a JSON
object using the builder pattern.
Call upon the Json.createObjectBuilder()
method to create a JsonObjectBuilder.
How it Works
Utilize the builder pattern to build the object
model by nesting calls to the JsonObjectBuilder
add() method, passing name/value pairs.
How it Works
It is possible to nest objects and arrays.
The JsonArrayBuilder class contains similar add
methods that do not have a name (key) parameter.
You can nest arrays and objects by passing a new
JsonArrayBuilder object or a new JsonObjectBuilder
object to the corresponding add method.
Invoke the build() method to create the object.
Problem #5
You are interested in finding a specific
value within a JSON document.
Solution
Utilize JSON Pointer to find the desired value.
How it Works
• Create a new JsonPointer object and
pass a string that will be used for
identifying a specific value.
How it Works
• Obtain the value by calling the
JsonPointer.getValue() method and
passing the JsonObject you wish to
parse. The JsonValue will contain
the value to which you had pointed.
Problem #6
You would like to perform an operation
on a a specified value within a JSON
document.
Solution
Utilize JSON Patch to replace a specified
value within a JSON document with another
value.
The original document
{"baz": "qux", "foo": "bar"}
The patch
[
{ "op": "replace", "path": "/baz", "value": "boo"
},
{ "op": "add", "path": "/hello", "value": ["world"]
},
{ "op": "remove", "path": "/foo"}
]
The result
{"baz": "boo","hello": ["world"]}
Solution
How it Works
• JSON Document or
JsonPatchBuilder
• JSON Pointer is used to find the
value or section that will be patched
• A series of operations can be applied
Problem #7
You wish to parse some JSON using Java.
Solution
Use the JsonParser, which is a pull parser that
allows us to process each document record via
iteration.
How it Works
Parser can be created on a byte or character
stream by calling upon the Json.createParser()
method.
Iterate over the JSON object model and/or array,
and parse each event accordingly.
JSON-B
JSR-367
Java API for JSON Binding
• Standardize means of converting JSON to
Java objects and vice versa
• Default mapping algorithm for converting
Java classes
• Draw from best of breed ideas in existing
JSON binding solutions
• Provide JAX-RS a standard way to support
“application/json” for POJOs
• JAX-RS currently supports JSON-P
Problem #8
You would like read in a JSON document
and map it to a Java class or POJO.
Solution
Utilize default JSON binding mapping to quickly
map to a POJO.
Solution
Solution
Create JSON from Java object
Solution
Create JSON from Java List
How it Works
• JSON-B API provides serialization
and deserialization operations for
manipulating JSON documents to
Java
• Default mapping, with custom
annotation mapping available for
compile-time
• JsonConfig class for runtime
mapping customizations
CDI 2.0
JSR 365
• JSR is in active progress…can download WELD
betas and test
• Java SE Bootstrap
• XML Configuration
• Asynchronous Events
• @Startup for CDI Beans
• Portable Extension SPI Simplification
• Small features/enhancements
Problem #9
You’d like to mark a CDI event as
asynchronous.
Solution
Fire the event calling upon the fireAsync()
method, passing the event class.
Solution
Use @ObservesAsync to observe an
asynchronous event.
How it Works
• Utilizes the Java 8 Asynchronous API to
provide a streamlined approach.
• @ObservesAsync annotation added to
annotate an observer method parameter
so that existing observers annotated with
@Observes would remain synchronous.
• fireAsync() added to the Event interface.
Configuration
New Spec Pending
• Standard for externalizing configuration
• Aimed at cloud-based environments
• Provide the ability to change one or more
configurations that are independent/decoupled of
apps...multiple configuration files
• Unified API for accessing configuration in many
different environments
• Layering and overrides
Problem #10
The application that you are developing
requires some external configuration values
for specifying server-side paths and/or
resources.
Solution
Use the standardized configuration API to
retrieve the configuration values.
Suppose you have a property file with the
following values:
city=Chicago
language=Java
Solution
Config config = ConfigProvider.getConfig();
String city = config.getProperty(“city”);
String language =
config.getProperty(“language”);
Long val = config.getProperty(“someLong”,
Long.class);
How it Works
• Define the configuration sources for an
application using a config-sources.xml file,
or using an api to set up at deployment
time.
WebSockets
The Java API for WebSocket provides support
for building WebSocket applications.
WebSocket is an application protocol that
provides full-duplex communications between
peers over the TCP protocol.
What about Java EE 8??
Problem #11
You wish to create a communication channel
that can be used to receive messages
asynchronously.
Solution
Create a WebSocket endpoint by annotating a
POJO class using @ServerEndpoint, and
providing the desired endpoint path.
Create a message receiver method, and
annotate it with @OnMessage
Solution
How it Works
Create a WebSocket endpoint by annotating a
class with @ServerEndpoint, and passing the
value attribute with a desired path for the
endpoint URI.
@ServerEndpoint(value=“/chatEndpoint”)
URI: ws://server:port/application-name/path
How it Works
Method annotated @OnOpen is invoked when
the WebSocket connection is made.
Method annotated @OnMessage is invoked
when a message is sent to the endpoint. It then
returns a response.
How it Works
Specify optional Encoder and Decoder
implementations to convert messages to and
from a particular format.
How it Works
Example of a Decoder:
JAX-RS 2.1
JSR 370
• Hypermedia API
• Reactive API
• Security API
• Support for SSE (Server Sent Events)
• Improved CDI Integration
• Support for Non-Blocking IO in Providers
Problem #12
You would like to initiate an open-ended
communication channel from a server to
clients. You wish to have a connection remain
open to the client so that subsequent single-
sided communications from the server can be
sent.
Solution
Create an SSE Resource using JAX-RS 2.1, and
broadcast server messages to connected clients
at will.
Solution
How it Works
• Try now by downloading Jersey 2.24
• Similar to long-polling, but may send multiple
messages
• Annotate resource method with
@Produces(SseFeature.SERVER_SENT_EVE
NTS)
• Also possible to broadcast using
SseBroadcaster
MVC 1.0
Features of MVC 1.0:
• Action-based
• Follows suit of Spring MVC or Apache Struts
• Does not replace JSF
• No UI Components
• Model: CDI, BeanValidation, JPA
• View: Facelets, JSP, other
• Controller: Layered on top of JAX-RS
We’ve Covered A Lot
…but there is a lot more to cover!!!!
Microservices?
What is a microservice?
How to do micro services with Java EE?
We’ll get there in Java EE 9…
Learn More
Code Examples: https://github.com/juneau001/AcmeWorld
Contact on Twitter: @javajuneau

More Related Content

What's hot

50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
Arun Gupta
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
Ryan Cuprak
 
What's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and Beyond
Oracle
 
Move from J2EE to Java EE
Move from J2EE to Java EEMove from J2EE to Java EE
Move from J2EE to Java EE
Hirofumi Iwasaki
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-Side
Reza Rahman
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
Masoud Kalali
 
Jdbc
JdbcJdbc
Testing Java EE Applications Using Arquillian
Testing Java EE Applications Using ArquillianTesting Java EE Applications Using Arquillian
Testing Java EE Applications Using Arquillian
Reza Rahman
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
Murat Yener
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Java EE 6 & Spring: A Lover's Quarrel
Java EE 6 & Spring: A Lover's QuarrelJava EE 6 & Spring: A Lover's Quarrel
Java EE 6 & Spring: A Lover's Quarrel
Mauricio "Maltron" Leal
 
jsf2 Notes
jsf2 Notesjsf2 Notes
jsf2 Notes
Rajiv Gupta
 
Java EE vs Spring Framework
Java  EE vs Spring Framework Java  EE vs Spring Framework
Java EE vs Spring Framework
Rohit Kelapure
 
AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7
Kevin Sutter
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
Oleg Tsal-Tsalko
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
Fahad Golra
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6
glassfish
 
Spring framework
Spring frameworkSpring framework
Spring framework
Aircon Chen
 

What's hot (18)

50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
What's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and Beyond
 
Move from J2EE to Java EE
Move from J2EE to Java EEMove from J2EE to Java EE
Move from J2EE to Java EE
 
Java EE and Spring Side-by-Side
Java EE and Spring Side-by-SideJava EE and Spring Side-by-Side
Java EE and Spring Side-by-Side
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
 
Jdbc
JdbcJdbc
Jdbc
 
Testing Java EE Applications Using Arquillian
Testing Java EE Applications Using ArquillianTesting Java EE Applications Using Arquillian
Testing Java EE Applications Using Arquillian
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Java EE 6 & Spring: A Lover's Quarrel
Java EE 6 & Spring: A Lover's QuarrelJava EE 6 & Spring: A Lover's Quarrel
Java EE 6 & Spring: A Lover's Quarrel
 
jsf2 Notes
jsf2 Notesjsf2 Notes
jsf2 Notes
 
Java EE vs Spring Framework
Java  EE vs Spring Framework Java  EE vs Spring Framework
Java EE vs Spring Framework
 
AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7
 
Next stop: Spring 4
Next stop: Spring 4Next stop: Spring 4
Next stop: Spring 4
 
Lecture 1: Introduction to JEE
Lecture 1:  Introduction to JEELecture 1:  Introduction to JEE
Lecture 1: Introduction to JEE
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6
 
Spring framework
Spring frameworkSpring framework
Spring framework
 

Viewers also liked

Java EE 8 - February 2017 update
Java EE 8 - February 2017 updateJava EE 8 - February 2017 update
Java EE 8 - February 2017 update
David Delabassee
 
MVC 1.0 / JSR 371
MVC 1.0 / JSR 371MVC 1.0 / JSR 371
MVC 1.0 / JSR 371
David Delabassee
 
HTML5 Media Elements
HTML5 Media ElementsHTML5 Media Elements
JSR 375 Segurança em Java EE 8
JSR 375 Segurança em Java EE 8JSR 375 Segurança em Java EE 8
JSR 375 Segurança em Java EE 8
Helder da Rocha
 
Configuration for Java EE and the Cloud
Configuration for Java EE and the CloudConfiguration for Java EE and the Cloud
Configuration for Java EE and the Cloud
Dmitry Kornilov
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
David Delabassee
 
Integrity
IntegrityIntegrity
New MVC 1.0 JavaEE 8 API
New MVC 1.0 JavaEE 8 APINew MVC 1.0 JavaEE 8 API
New MVC 1.0 JavaEE 8 API
Trayan Iliev
 
Gráficos Vetoriais na Web com SVG
Gráficos Vetoriais na Web com SVGGráficos Vetoriais na Web com SVG
Gráficos Vetoriais na Web com SVG
Helder da Rocha
 
Царство грибов
Царство грибовЦарство грибов
Царство грибов
LotosPlay
 
Науки о природе
Науки о природеНауки о природе
Науки о природе
LotosPlay
 
Bag to school choosing the right school bag
Bag to school choosing the right school bagBag to school choosing the right school bag
Bag to school choosing the right school bag
permapleatcomau
 
Мир живых организмов
Мир живых организмовМир живых организмов
Мир живых организмов
LotosPlay
 
Роль грибов
Роль грибовРоль грибов
Роль грибов
LotosPlay
 
Web based apps - Demo
Web based apps - DemoWeb based apps - Demo
Web based apps - Demo
actiknow
 
Ткани растений
Ткани растенийТкани растений
Ткани растений
LotosPlay
 
Прокариотическая клетка
Прокариотическая клеткаПрокариотическая клетка
Прокариотическая клетка
LotosPlay
 
PMP with Rebus Business solutions
PMP with Rebus Business solutionsPMP with Rebus Business solutions
PMP with Rebus Business solutions
Rebus Business Solutions
 
Теория Ламарка
Теория ЛамаркаТеория Ламарка
Теория Ламарка
LotosPlay
 
Place identification paper_발표자료_summary
Place identification paper_발표자료_summaryPlace identification paper_발표자료_summary
Place identification paper_발표자료_summary
Namgee Lee
 

Viewers also liked (20)

Java EE 8 - February 2017 update
Java EE 8 - February 2017 updateJava EE 8 - February 2017 update
Java EE 8 - February 2017 update
 
MVC 1.0 / JSR 371
MVC 1.0 / JSR 371MVC 1.0 / JSR 371
MVC 1.0 / JSR 371
 
HTML5 Media Elements
HTML5 Media ElementsHTML5 Media Elements
HTML5 Media Elements
 
JSR 375 Segurança em Java EE 8
JSR 375 Segurança em Java EE 8JSR 375 Segurança em Java EE 8
JSR 375 Segurança em Java EE 8
 
Configuration for Java EE and the Cloud
Configuration for Java EE and the CloudConfiguration for Java EE and the Cloud
Configuration for Java EE and the Cloud
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
 
Integrity
IntegrityIntegrity
Integrity
 
New MVC 1.0 JavaEE 8 API
New MVC 1.0 JavaEE 8 APINew MVC 1.0 JavaEE 8 API
New MVC 1.0 JavaEE 8 API
 
Gráficos Vetoriais na Web com SVG
Gráficos Vetoriais na Web com SVGGráficos Vetoriais na Web com SVG
Gráficos Vetoriais na Web com SVG
 
Царство грибов
Царство грибовЦарство грибов
Царство грибов
 
Науки о природе
Науки о природеНауки о природе
Науки о природе
 
Bag to school choosing the right school bag
Bag to school choosing the right school bagBag to school choosing the right school bag
Bag to school choosing the right school bag
 
Мир живых организмов
Мир живых организмовМир живых организмов
Мир живых организмов
 
Роль грибов
Роль грибовРоль грибов
Роль грибов
 
Web based apps - Demo
Web based apps - DemoWeb based apps - Demo
Web based apps - Demo
 
Ткани растений
Ткани растенийТкани растений
Ткани растений
 
Прокариотическая клетка
Прокариотическая клеткаПрокариотическая клетка
Прокариотическая клетка
 
PMP with Rebus Business solutions
PMP with Rebus Business solutionsPMP with Rebus Business solutions
PMP with Rebus Business solutions
 
Теория Ламарка
Теория ЛамаркаТеория Ламарка
Теория Ламарка
 
Place identification paper_발표자료_summary
Place identification paper_발표자료_summaryPlace identification paper_발표자료_summary
Place identification paper_발표자료_summary
 

Similar to Java EE 8 Recipes

Jakarta EE Recipes
Jakarta EE RecipesJakarta EE Recipes
Jakarta EE Recipes
Josh Juneau
 
Java EE 7 Recipes
Java EE 7 RecipesJava EE 7 Recipes
Java EE 7 Recipes
Josh Juneau
 
Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Migrating to Jakarta EE 10
Migrating to Jakarta EE 10
Josh Juneau
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
Bill Lyons
 
Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020
Josh Juneau
 
AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7
WASdev Community
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
Mohamed Taman
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerZeroTurnaround
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
nrjoshiee
 
Json generation
Json generationJson generation
Json generation
Aravindharamanan S
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack ImplementationMert Çalışkan
 
Spring 4-groovy
Spring 4-groovySpring 4-groovy
Spring 4-groovyGR8Conf
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Rohit Kelapure
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
Ryan Cuprak
 
Utilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with MicroservicesUtilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with Microservices
Josh Juneau
 
13 java beans
13 java beans13 java beans
13 java beanssnopteck
 
Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomas
intuit_india
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
Sudha Hari Tech Solution Pvt ltd
 
Java EE 7 Recipes for Concurrency - JavaOne 2014
Java EE 7 Recipes for Concurrency - JavaOne 2014Java EE 7 Recipes for Concurrency - JavaOne 2014
Java EE 7 Recipes for Concurrency - JavaOne 2014
Josh Juneau
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann
Kile Niklawski
 

Similar to Java EE 8 Recipes (20)

Jakarta EE Recipes
Jakarta EE RecipesJakarta EE Recipes
Jakarta EE Recipes
 
Java EE 7 Recipes
Java EE 7 RecipesJava EE 7 Recipes
Java EE 7 Recipes
 
Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Migrating to Jakarta EE 10
Migrating to Jakarta EE 10
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020Jakarta EE and MicroProfile - EclipseCon 2020
Jakarta EE and MicroProfile - EclipseCon 2020
 
AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen Hoeller
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
 
Json generation
Json generationJson generation
Json generation
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
 
Spring 4-groovy
Spring 4-groovySpring 4-groovy
Spring 4-groovy
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Utilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with MicroservicesUtilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with Microservices
 
13 java beans
13 java beans13 java beans
13 java beans
 
Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomas
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
Java EE 7 Recipes for Concurrency - JavaOne 2014
Java EE 7 Recipes for Concurrency - JavaOne 2014Java EE 7 Recipes for Concurrency - JavaOne 2014
Java EE 7 Recipes for Concurrency - JavaOne 2014
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann
 

Recently uploaded

Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

Java EE 8 Recipes

  • 1. Java EE 8 Recipes Presented By: Josh Juneau Author and Application Developer
  • 2. About Me Josh Juneau Day Job: Developer and DBA @ Fermilab Night/Weekend Job: Technical Writer - Java Magazine and OTN - Java EE 7 Recipes - Introducing Java EE 7 - Java 8 Recipes JSR 372 EG and JSR 378 EG Twitter: @javajuneau
  • 3. Agenda - Take a look at big picture of Java EE 8 - Resolve a series of real life scenarios using the features of Java EE 7 and Java EE 8
  • 4. Before we start. . . Old: J2EE Modern: Java EE
  • 5. Java EE of the Past (J2EE) Difficult to Use Configuration Verbose Few Standards
  • 7. Java EE 7 Increases Productivity Even More and Introduces Standards for Building Modern Applications
  • 8. Java EE 7 Increased Productivity • CDI Everywhere • JAX-RS Client API,Async Processing • BeanValidation in EJBs and POJOs • JSF Flows • JMS 2.0 - Much Less Code
  • 9. Java EE 7 Introduced New Standards • WebSockets • JSON-P • Batch API • Concurrency Utilities for Java EE
  • 11. Java EE 8 Continues this Momentum • Continued enhancements for productivity and web standards alignment • Cloud enhancements • Better alignment with Java SE 8 • Work towards a better platform for development of microservices
  • 12.
  • 14. Recipes! Statement for Completeness: Recipes are not meant to provide comprehensive coverage of the features. Rather, they are meant to get you up and running with the new functionality quickly, providing the details you need to know. To learn more details on any of the features covered, please refer to the online documentation. Let’s Cook!
  • 15. How to Run Setting up your environment for Java EE 8 • Payara 5 Branch • Clone git repository and build: mvn clean install -DskipTests • Clone and Build/Download latest EA of Spec • Most have git repositories
  • 16. JSF 2.3 JSR 372 • New features added in JSF 2.3, adding more flexibility • Improved CDI Alignment • PostRenderViewEvent • WebSocket Integration and Ajax Enhancements • Java 8 Date-Time Support • Enhanced Components • Much More
  • 17. Problem #1 You would like to work with the Java 8 Date- Time API via your JSF application. Does not work with Java EE 7 out of the box.
  • 18. Solution Make use of the <f:convertDateTime /> tag.
  • 19. How it Works JSF 2.3 requires a minimum of Java 8, so we can make use of Java 8 goodness. New type attribute values on <f:convertDateTime>: • localDate, localTime, localDateTime • offsetTime,offsetDateTime, zonedDateTime
  • 20. Problem #2 Oftentimes, you need to work with FacesContext or another JSF artifact. It can be cumbersome to obtain the current instance, ServletContext, etc. time after time.
  • 21. Problem FacesContext context = FacesContext.getCurrentInstance(); ExternalContext externalContext = FacesContext.getCurrentInstance().getExter nalContext();
  • 22. Problem Map<String, Object> cookieMap = FacesContext.getCurrentInstance().getExternalContext() .getRequestCookieMap(); Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot( ).getViewMap();
  • 23. Solution Inject JSF artifacts in JSF 2.3, and inject into JSF artifacts.
  • 24. Solution @Inject private ExternalContext externalContext; @Inject private ServletContext servletContext; @Inject @ViewMap private Map<String, Object> viewMap;
  • 25. How it Works JSF 2.3 provides default producers for many of the most commonly used JSF artifacts, therefore, we can now inject rather than hard-code. Converters, validators and behaviors are now also injection targets.
  • 27. BeanValidation JSR-380 New Features in BeanValidation 2.0: • Focus on Java SE 8 Features • Type annotations, Date-TimeValidation, etc. • Simpler Constraint Ordering on Single Properties • Custom Payload for ConstraintViolations
  • 28. Problem #3 You would like to validate dates and times utilizing the Java 8 Date-Time API to ensure that they are in the past or in the future.
  • 29. Solution @Future and @Past will work with Java 8 Date-Time
  • 30. How it Works • Place validation constraint annotations on a field, method, or class such as a JSF managed bean or entity class. • When the JSF Process Validations phase occurs, the value that was entered by the user will be validated based upon the specified validation criteria. At this point, if the validation fails, the Render Response phase is executed, and an appropriate error message is added to the FacesContext. However, if the validation is successful, then the life cycle continues normally. • Specify a validation error message using the message attribute within the constraint annotation
  • 31. How it Works Other New Features: Type-use annotation: List<@NotNull @Email String> emails; Mark standardized constraints with @Repeatable, eliminating the need for the usage of the @Size.List pattern.
  • 32. JSON-P 1.1 JSR-374 The Java API for JSON Processing is a standard for generation and processing of JavaScript Object Notation data. JSON-P provides an API to parse, transform, and query JSON data using the object model or the streaming model. JSON is often used as a common format to serialize and deserialize data for applications that communicate with each other over the Internet.
  • 33. JSON-P 1.1 • Adds new JSON standards for JSON-Pointer and JSON-Patch • Provides editing operations for JSON objects and arrays • Helper classes and Java SE 8 Support
  • 34. Problem #4 You would like to build a JSON object model using Java code. We wish to create a list of current reservations.
  • 35. Solution Utilize JSON Processing for the Java EE Platform to build a JSON object model containing all of the current reservations.
  • 37. How it Works JSON defines only two data structures: objects and arrays.An object is a set of name-value pairs, and an array is a list of values. JSON defines seven value types: string, number, object, array, true, false, and null.
  • 38. How it Works Java EE includes support for JSR 353, which provides an API to parse, transform, and query JSON data using the object model or the streaming model Make use of JsonObjectBuilder to build a JSON object using the builder pattern. Call upon the Json.createObjectBuilder() method to create a JsonObjectBuilder.
  • 39. How it Works Utilize the builder pattern to build the object model by nesting calls to the JsonObjectBuilder add() method, passing name/value pairs.
  • 40. How it Works It is possible to nest objects and arrays. The JsonArrayBuilder class contains similar add methods that do not have a name (key) parameter. You can nest arrays and objects by passing a new JsonArrayBuilder object or a new JsonObjectBuilder object to the corresponding add method. Invoke the build() method to create the object.
  • 41. Problem #5 You are interested in finding a specific value within a JSON document.
  • 42. Solution Utilize JSON Pointer to find the desired value.
  • 43. How it Works • Create a new JsonPointer object and pass a string that will be used for identifying a specific value.
  • 44. How it Works • Obtain the value by calling the JsonPointer.getValue() method and passing the JsonObject you wish to parse. The JsonValue will contain the value to which you had pointed.
  • 45. Problem #6 You would like to perform an operation on a a specified value within a JSON document.
  • 46. Solution Utilize JSON Patch to replace a specified value within a JSON document with another value.
  • 47. The original document {"baz": "qux", "foo": "bar"} The patch [ { "op": "replace", "path": "/baz", "value": "boo" }, { "op": "add", "path": "/hello", "value": ["world"] }, { "op": "remove", "path": "/foo"} ] The result {"baz": "boo","hello": ["world"]}
  • 49. How it Works • JSON Document or JsonPatchBuilder • JSON Pointer is used to find the value or section that will be patched • A series of operations can be applied
  • 50. Problem #7 You wish to parse some JSON using Java.
  • 51. Solution Use the JsonParser, which is a pull parser that allows us to process each document record via iteration.
  • 52. How it Works Parser can be created on a byte or character stream by calling upon the Json.createParser() method. Iterate over the JSON object model and/or array, and parse each event accordingly.
  • 53. JSON-B JSR-367 Java API for JSON Binding • Standardize means of converting JSON to Java objects and vice versa • Default mapping algorithm for converting Java classes • Draw from best of breed ideas in existing JSON binding solutions • Provide JAX-RS a standard way to support “application/json” for POJOs • JAX-RS currently supports JSON-P
  • 54. Problem #8 You would like read in a JSON document and map it to a Java class or POJO.
  • 55. Solution Utilize default JSON binding mapping to quickly map to a POJO.
  • 59. How it Works • JSON-B API provides serialization and deserialization operations for manipulating JSON documents to Java • Default mapping, with custom annotation mapping available for compile-time • JsonConfig class for runtime mapping customizations
  • 60. CDI 2.0 JSR 365 • JSR is in active progress…can download WELD betas and test • Java SE Bootstrap • XML Configuration • Asynchronous Events • @Startup for CDI Beans • Portable Extension SPI Simplification • Small features/enhancements
  • 61. Problem #9 You’d like to mark a CDI event as asynchronous.
  • 62. Solution Fire the event calling upon the fireAsync() method, passing the event class.
  • 63. Solution Use @ObservesAsync to observe an asynchronous event.
  • 64. How it Works • Utilizes the Java 8 Asynchronous API to provide a streamlined approach. • @ObservesAsync annotation added to annotate an observer method parameter so that existing observers annotated with @Observes would remain synchronous. • fireAsync() added to the Event interface.
  • 65. Configuration New Spec Pending • Standard for externalizing configuration • Aimed at cloud-based environments • Provide the ability to change one or more configurations that are independent/decoupled of apps...multiple configuration files • Unified API for accessing configuration in many different environments • Layering and overrides
  • 66. Problem #10 The application that you are developing requires some external configuration values for specifying server-side paths and/or resources.
  • 67. Solution Use the standardized configuration API to retrieve the configuration values. Suppose you have a property file with the following values: city=Chicago language=Java
  • 68. Solution Config config = ConfigProvider.getConfig(); String city = config.getProperty(“city”); String language = config.getProperty(“language”); Long val = config.getProperty(“someLong”, Long.class);
  • 69. How it Works • Define the configuration sources for an application using a config-sources.xml file, or using an api to set up at deployment time.
  • 70. WebSockets The Java API for WebSocket provides support for building WebSocket applications. WebSocket is an application protocol that provides full-duplex communications between peers over the TCP protocol. What about Java EE 8??
  • 71. Problem #11 You wish to create a communication channel that can be used to receive messages asynchronously.
  • 72. Solution Create a WebSocket endpoint by annotating a POJO class using @ServerEndpoint, and providing the desired endpoint path. Create a message receiver method, and annotate it with @OnMessage
  • 74. How it Works Create a WebSocket endpoint by annotating a class with @ServerEndpoint, and passing the value attribute with a desired path for the endpoint URI. @ServerEndpoint(value=“/chatEndpoint”) URI: ws://server:port/application-name/path
  • 75. How it Works Method annotated @OnOpen is invoked when the WebSocket connection is made. Method annotated @OnMessage is invoked when a message is sent to the endpoint. It then returns a response.
  • 76. How it Works Specify optional Encoder and Decoder implementations to convert messages to and from a particular format.
  • 77. How it Works Example of a Decoder:
  • 78. JAX-RS 2.1 JSR 370 • Hypermedia API • Reactive API • Security API • Support for SSE (Server Sent Events) • Improved CDI Integration • Support for Non-Blocking IO in Providers
  • 79. Problem #12 You would like to initiate an open-ended communication channel from a server to clients. You wish to have a connection remain open to the client so that subsequent single- sided communications from the server can be sent.
  • 80. Solution Create an SSE Resource using JAX-RS 2.1, and broadcast server messages to connected clients at will.
  • 82. How it Works • Try now by downloading Jersey 2.24 • Similar to long-polling, but may send multiple messages • Annotate resource method with @Produces(SseFeature.SERVER_SENT_EVE NTS) • Also possible to broadcast using SseBroadcaster
  • 83. MVC 1.0 Features of MVC 1.0: • Action-based • Follows suit of Spring MVC or Apache Struts • Does not replace JSF • No UI Components • Model: CDI, BeanValidation, JPA • View: Facelets, JSP, other • Controller: Layered on top of JAX-RS
  • 84. We’ve Covered A Lot …but there is a lot more to cover!!!!
  • 85. Microservices? What is a microservice? How to do micro services with Java EE? We’ll get there in Java EE 9…
  • 86. Learn More Code Examples: https://github.com/juneau001/AcmeWorld Contact on Twitter: @javajuneau