Mais conteúdo relacionado Semelhante a Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0 (20) Mais de David Delabassee (20) Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.02. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Agenda
• Java
EE
8
• Adopt
JSON-‐P
1.1
(JSR
374)
• Adopt
MVC
1.0
(JSR
371)
2
3. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Java
EE
8
Themes
• HTML5
/
Web
Tier
Enhancements
• Ease
of
Development
• Infrastructure
for
running
in
the
Cloud
3
4. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Java
EE
8
Themes
• HTML5
/
Web
Tier
Enhancements
• Ease
of
Development
• Infrastructure
for
running
in
the
Cloud
4
5. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
HTML5
Support
/
Web
Tier
Enhancements
• JSON
Binding
• JSON
Processing
enhancements
• Server-‐sent
Events
• Action-‐based
MVC
• HTTP/2
support
5
6. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
HTML5
Support
/
Web
Tier
Enhancements
• JSON
Binding
• JSON
Processing
enhancements
• Server-‐sent
Events
• Action-‐based
MVC
• HTTP/2
support
6
7. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Java
EE
8
Themes
• HTML5
/
Web
Tier
Enhancements
• Ease
of
Development
• Infrastructure
for
running
in
the
Cloud
7
8. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Ease
of
Development
• CDI
alignment
• JAX-‐RS
injection
alignment
• Simplified
messaging
through
CDI-‐based
“MDBs”
• WebSocket
scopes
• Pruning
of
EJB
2.x
client
view
and
IIOP
interoperability
• Security
interceptors
• …
8
9. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Java
EE
8
Themes
• HTML5
/
Web
Tier
Enhancements
• Ease
of
Development
• Infrastructure
for
running
in
the
Cloud
9
10. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Modernize
the
Infrastructure
• Java
EE
Management
2.0
– REST-‐based
APIs
for
Management
and
Deployment
• Java
EE
Security
1.0
– Authorization
– Password
Aliasing
– User
Management
– Role
Mapping
– Authentication
– REST
Authentication
For
On-‐Premise
and
for
in
the
Cloud
10
11. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Java
EE
8
JSRs
• MVC
1.0
(JSR
371)
*
• CDI
2.0
(JSR
365)
• JSON-‐P
1.1
(JSR
374)
• JSF
2.3
(JSR
372)
• Java
EE
Security
1.0
(JSR
375)
• JSON
Binding
1.0
(JSR
367)
• JMS
2.1
(JSR
368)
• Java
Servlet
4.0
(JSR
369)
• JAX-‐RS
2.1
(JSR
370)
• Java
EE
Management
2.0
(JSR
373)
• Java
EE
8
Platform
(JSR
366)
So
far…..
11
12. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
And
More
to
Follow…
• JCache
• Bean
Validation
• JPA
• Connector
Architecture
• WebSocket
• Interceptors
• EJB
• JTA
• Batch
• Concurrency
Utilities
• JavaMail
• …
12
13. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Roadmap
• Tentative
Delivery
Schedule
– Q3
2014:
Expert
Group
formed
– Q3
2015:
Early
Draft
– Q4
2015:
Public
Review
– Q2
2016:
Proposed
Final
Draft
– H1
2017:
Final
Release
• Contribute!
13
14. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
How
to
Get
Involved
• Join
an
Expert
Group
– http://javaee-‐spec.java.net
• Adopt
a
JSR
– http://glassfish.org/adoptajsr
• The
Aquarium
– http://blogs.oracle.com/theaquarium
• Java
EE
Reference
Implementation
– http://glassfish.org
14
15. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
• Keep
JSON-‐P
spec
up-‐to-‐date
• Track
new
standards
• Add
editing
operations
to
JsonObject
and
JsonArray
• Java
SE
8
• JSON
Big
Data
15
JSR
374
16. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
• String
syntax
for
referencing
a
JSON
value
"/0/phone/mobile"
JSON-‐Pointer
–
IETF
RFC
6901
16
17. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
JsonArray
contacts
=
…
JsonPointer
pointer
=
new
JsonPointer("/0/name");
JsonValue
value
=
pointer.getValue(contacts);
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-‐123-‐4567",
"mobile":"650-‐234-‐5678"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-‐555-‐9999"}}
]
17
18. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
• String
syntax
for
referencing
a
JSON
value
“/0/name"
• Methods
– getValue()
– JSON
operations:
add(),
replace(),
remove()
JSON-‐Pointer
–
IETF
RFC
6901
18
JsonPointer
pointer
=
new
JsonPointer("/0/name");
JsonArray
result
=
pointer.replace(contacts,
Json.createValue("Alex"));
19. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
• Patch
is
a
JSON
document
– Array
of
objects
/
operations
for
modifying
a
JSON
document
– add,
replace,
remove,
move,
copy,
test
JSON-‐Patch
–
IETF
RFC
6902
19
20. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
[
{
"op":"replace",
"path":"/0/phones/mobile",
"value":"650-‐111-‐2222"},
{
"op":"remove",
"path":"/1"}
]
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-‐123-‐4567",
"mobile":"650-‐234-‐5678"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-‐555-‐9999"}}
]
20
21. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
[
{
"op":"replace",
"path":"/0/phones/mobile",
"value":"650-‐111-‐2222"},
{
"op":"remove",
"path":"/1"}
]
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-‐123-‐4567",
"mobile":"650-‐111-‐2222"}},
{
"name":"Jane",
"gender":"F",
"phones":{
"mobile":"707-‐555-‐9999"}}
]
21
22. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
[
{
"op":"replace",
"path":"/0/phones/mobile",
"value":"650-‐111-‐2222"},
{
"op":"remove",
"path":"/1"}
]
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650-‐123-‐4567",
"mobile":"650-‐111-‐2222"}}
]
22
23. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JsonArray
target
=
…;
JsonArray
patch
=
…;
JsonPatch
jsonpatch
=
new
JsonPatch(patch);
JsonArray
result
=
jsonpatch.apply(target);
JSON-‐P
1.1
23
JsonPatchBuilder
builder
=
new
JsonPatchBuilder();
JsonArray
result
=
builder.add("/Joe/phones/office",
"1234-‐567")
.remove("/Amy/age")
.apply(contacts);
24. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
{
"title":
"Hello!",
"phoneNumber":
"+01-‐123-‐456-‐7890",
"author":
{
"familyName":
null
},
"tags":
[
"example"
]
}
24
{
"title":
"Goodbye!",
"author":
{
"givenName":
"John",
"familyName":
"Doe"
},
"tags":
[
"example",
"sample"
],
"content":
"This
will
be
unchanged"
}
{
"title":
"Hello!",
"author":
{
"givenName":
"John"
},
"tags":
[
"example"
],
"content":
"This
will
be
unchanged",
"phoneNumber":
"+01-‐123-‐456-‐7890"
}
JSON-‐Merge
Patch
–
IETF
RFC
7386
25. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
• Reverse
operation
– Given
two
objects
returns
the
patch
to
apply
(diff)
JSON-‐Patch
&
JSON-‐Merge
Patch
Diff
25
JsonValue
output
=
JsonMergePatch.diff(original,
target);
JsonArray
diff
=
JsonPatch.diff(original,
target);
26. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
JSON
Query
collecting
results
in
JsonArray
JsonArray
cars
=
...;
JsonArray
audis
=
cars.getValuesAs(JsonObject.class).stream()
.filter(x-‐>"Audi".equals(x.getString("brand")))
.map(x-‐>(x.getString("serial"))
.collect(JsonCollectors.toJsonArray());
26
27. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
Getting
Started
27
• JSR
374
- https://json-‐processing-‐spec.java.net
• JIRA
- https://java.net/jira/browse/JSON_PROCESSING_SPEC
• Repos
- git://java.net/json-‐processing-‐spec~git
- git://java.net/jsonp~git
28. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
JSON-‐P
1.1
Getting
Started
28
• Build
the
standalone
RI
- git://java.net/jsonp~git
• Check
JSR374
tests
and
the
Javadocs
- https://json-‐processing-‐spec.java.net/nonav/snapshots/1.1/javadocs/
• Follow
the
EG
users
list
- JSON
Big
Data
29. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Model-‐View-‐Controller
(MVC
1.0)
Specification
• “Action-‐based”
MVC
1.0
JSR
• Why?
– UI
landscape
is
not
one
size
fits
all
– Java
EE
8
Community
Survey
– Talking
to
our
customers,
etc.
• EG
– Oracle,
RedHat,
innoQ,
IBM,
Caelum,
LifeRay,
and
6
individuals
members
JSR
371
29
30. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
MVC
1.0
• Model
– CDI,
Bean
Validation,
JPA
• View
– Facelets,
JSP,
SPI?
• Controller
– Invent
new
technology
Vs.
Leverage
existing
technologies?
30
Glues
together
key
Java
EE
technologies
31. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Controller
• Combine
data
models
and
views
to
produce
web
application
pages
@Path("hello")
public class HelloController {
@GET
@Controller
public String hello() {
return "hello.xhtml";
}
}
31
32. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Controller
• Class/method
decorated
with
@Controller
@Path(“hello")
@Controller
public class HelloController {
@GET
@View(“hello.ftl")
public void hello() {
}
}
32
33. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Controller
@Path(“hello")
@Controller
public class HelloController {
@GET
public Viewable hello() {
return new Viewable("hello.jsp");
}
}
33
34. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Controller
…
@GET
@Controller
public Response getById(@PathParam("id") String id) {
if (id.length() == 0) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(“error.xhtml")
.build();
}
}
34
35. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Model
• “Refers
to
the
data”
• javax.mvc.Models
interface
• CDI
@Named
bean
(recommended)
35
36. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Model
@Named(“greeting”)
@RequestScoped
public class Greeting {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
36
37. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
Model
@Path(“hello”)
public class HelloController {
@Inject
private Models models;
@GET
@Controller
public String hello() {
models.put(“greeting”, new Greeting(“Hi JPrime”));
return “hello.ftl”;
}
}
37
38. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
View
• Define
the
structure
of
the
output
• Can
refer
to
model(s)
• Rendered
by
a
View
Engine
– JSP
– Facelets
• Not
accessible
as
static
resources
– /WEB-‐INF/views/
38
39. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
View
39
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC …>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Facelet!</title>
</h:head>
<h:body>
<p>${greeting.message} to all</p>
</h:body>
</html>
40. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
View
<%@ page contentType=“text/html;charset=UTF-8”
language=“java” %>
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>${greeting.message}</p>
</body>
</html>
40
41. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
View
Engine
• CDI
based
extension
mechanism
• javax.mvc.engine.ViewEngine interface
boolean supports(String view);
void processView(ViewEngineContext context)
throws ViewEngineException;
• Ozark
– JSP
&
Facelets
– FreeMarker,
Velocity,
Thymeleaf,
Mustache
&
Handlebars
41
42. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved. @delabassee#JavaEE8
JSR
371
• View
Engine
– JSP
&
Facelets
– FreeMarker,
Velocity,
Thymeleaf,
Mustache,
Handlebars
&
Pebble
• Validation
• Exception
Mapping
Providers
• Bootstrap
via
javax.ws.rs.core.Application
• @Produces
• CDI
Events
42
Early
Draft
Review
43. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
MVC
1.0
• JSR
371
- http://mvc-‐spec.java.net/
- https://jcp.org/en/jsr/detail?id=371
- https://java.net/jira/browse/MVC_SPEC
- https://java.net/projects/mvc-‐spec/lists/users/archive
• Ozark
- https://ozark.java.net
- git://java.net/ozark~sources
+
https://github.com/spericas/ozark
Getting
Started
43
44. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
MVC
1.0
• Docker
script
- https://ozark.java.net/download.html
• Samples
- http://<container-‐ip>:8080/samples
• GF
console
(admin/ozark)
- http://<container-‐ip>:4848
Getting
Started
44
45. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
MVC
1.0
• GlassFish
4.1
nightly
- http://dlc-‐cdn.sun.com/glassfish/4.1/nightly/glassfish-‐4.1-‐
b14-‐06_12_2015.zip
• Bundle
Ozark
with
your
App
• Maven
Central
<groupId>javax.mvc</groupId>
<artifactId>javax.mvc-‐api</artifactId>
<version>1.0-‐edr1</version>
Getting
Started
45
46. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
MVC
1.0
• Full
blown
samples
• Additional
templating
engine
• Logging,
monitoring,
i.e.
improving
event
mechanism
in
place
• Internationalization/localization
• …
Getting
Started
46
47. Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.
@delabassee#JavaEE8
Devoxx
UK
• JCP,
Adopt-‐a-‐JSR
&
You
-‐
Thursday
at
12:50
(Room
BC)
• Java
EE
8,
a
snapshot
overview
-‐
Thursday
at
11:50
(Auditorium)
• Java
EE
Game
Changers
-‐
Friday
at
10:00
(Room
A)
• HTTP/2
comes
to
Java
-‐
Friday
at
11:10
12:00
(Auditorium)
• CDI
2.0:
what
is
in
the
work?
-‐
Friday
at
15:00
(Auditorium)
• Finally,
Security
API
JSR
375
-‐
Friday
at
16:20
(Room
DEF)
47
49. Safe
Harbor
Statement
The
precding
is
intended
to
outline
our
general
product
direction.
It
is
intended
for
information
purposes
only,
and
may
not
be
incorporated
into
any
contract.
It
is
not
a
commitment
to
deliver
any
material,
code,
or
functionality,
and
should
not
be
relied
upon
in
making
purchasing
decisions.
The
development,
release,
and
timing
of
any
features
or
functionality
described
for
Oracle’s
products
remains
at
the
sole
discretion
of
Oracle.
Copyright
©
2015,
Oracle
and/or
its
affiliates.
All
rights
reserved.