Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Java	
  EE	
  8	
  
What’s	
  new	
  on	
  the	
  Web	
  front

David	
  Delabassee	
  -­‐	
  @delabassee	
  
Oracle
Copyr...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
The	
   following	
   is	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Agenda
Context	
  
Web	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Agenda
Context	
  
Web	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Java	
  EE	
  8
Cloud
Mobi...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Community-­‐Prioritized	
 ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
Java	
  EE	
  8	
  The...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Agenda
Context	
  
Web	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
JSRs
	
  	
  	
  Updated	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
JSON
• Java	
  API	
  for	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
Java	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
• Stri...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
JsonAr...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
• Stri...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
• Patc...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
[	
  
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
[	
  
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
[	
  
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
	
  JsonArray	
  targe...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
JSON-­...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
{	
  
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
	
  JsonObject	
  cont...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
• Reve...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
JSON	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
JSON	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐P	
  1.1
• Keep...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐B
• API	
  to	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐B
• Draw	
  fro...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JSON-­‐B
// from defau...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Java	
  API	
  for	
  REST...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
Server-­‐sent	
  Event...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
Server-­‐sent	
  Event...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
Server-­‐sent	
  Event...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JAX-­‐RS	
  StockThrea...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
WebTarget	
  target	
 ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
JAX-­‐RS	
  2.1
37
• S...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Java	
  Servlet
38
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
HTTP	
  1.1	
  circa	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
HTTP/2
• HTTP/2	
  
– ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
HTTP/2
• One	
  TCP	
 ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
Stream	
  Prioritizati...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
HTTP/2
Server	
  Push
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
HTTP/2
Header	
  Compr...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
Servlet	
  4.0
• Reque...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Push
PushBuilder	
  builde...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Stream	
  Prioritization
4...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved. 48
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   49
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   50
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   51
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   52
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Model-­‐View-­‐Controller
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Component-­‐based	
  MVC
•...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Action-­‐based	
  MVC
• Co...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Model-­‐View-­‐Controller	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
MVC	
  1.0
• Action-­‐...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Controller
• Combine	
  da...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Controller
• Class/method	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Controller
@Path(“hello")
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Controller
…
@GET
@Control...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Model
• “Refers	
  to	
  t...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Model
@Named(“greeting”)
@...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Model
@Path(“hello”)
publi...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
View
• Define	
  the	
  st...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
View
<%@ page contentType=...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  
View
<html>
<head>
<ti...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
View	
  Engine
• CDI	
  ba...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Miscellaneous
• Bootstrap	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
MVC
• New	
  annotations	
...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
JavaServer	
  Faces
71
• C...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Agenda
Context	
  
Web	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Java	
  EE	
  8
• Java	
  ...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Roadmap
• Q4	
  2015	
  Ea...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Contribute!
• Join	
  the	...
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Takk!
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.
Prochain SlideShare
Chargement dans…5
×

Java EE 8 - What’s new on the Web front

811 vues

Publié le

Presented at JavaZone (Norway, September 2015)

Publié dans : Logiciels
  • Soyez le premier à commenter

Java EE 8 - What’s new on the Web front

  1. 1. Java  EE  8   What’s  new  on  the  Web  front
 David  Delabassee  -­‐  @delabassee   Oracle Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   1
  2. 2. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. The   following   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. Safe  Harbor  Statement
  3. 3. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Agenda Context   Web  Front  update   Call  to  Action   1 2 3
  4. 4. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Agenda Context   Web  Front  update   1 2 Context   Web  Front  update   Call  to  Action  3
  5. 5. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Java  EE  8 Cloud Mobile HTTP/2 SECURITY Reactive  Programming User  Experience
  6. 6. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.
  7. 7. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Community-­‐Prioritized  Features http://glassfish.org/survey
  8. 8. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   Java  EE  8  Themes • HTML5  /  Web  Tier  Enhancements   • Ease  of  Development   • Infrastructure  for  running  in  the  Cloud
  9. 9. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Agenda Context   Web  Front  update   1 2 3 Context   Web  Front  update   Call  to  Action  
  10. 10. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. JSRs      Updated   • Servlet   • JAX-­‐RS   • JavaServer  Faces   • JSON-­‐P      New   • JSON-­‐B     • MVC   10
  11. 11. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. JSON • Java  API  for  JSON  Processing     • Process  JSON   • Java  API  for  JSON  Binding   • Unmarshall  JSON  to  Java   • Marshall  Java  to  JSON 11
  12. 12. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐P  1.1 Java  API  for  JSON  Processing • Keep  JSON-­‐P  spec  up-­‐to-­‐date   • Track  new  standards   • Add  editing  operations  to  JsonObject  and  JsonArray   • Java  SE  8   • JSON  Big  Data 12
  13. 13. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐P  1.1 • String  syntax  for  referencing  a  JSON  value     "/0/phone/mobile" JSON-­‐Pointer  –  IETF  RFC  6901 13
  14. 14. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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"}}   ]       14
  15. 15. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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  JsonPointer  pointer  =  new  JsonPointer("/0/name");    JsonArray  result  =  pointer.replace(contacts,  Json.createValue("Alex")); 15
  16. 16. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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 [        {"op":"replace","path":"/0/phones/mobile","value":"650-­‐111-­‐222"},        {"op":"remove","path":"/1"}   ] 16
  17. 17. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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"}}   ]       17
  18. 18. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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"}}   ]       18
  19. 19. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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"}}   ]       19
  20. 20. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    JsonArray  target  =  …;    JsonArray  patch  =  …;        JsonPatch  jsonPatch  =  new  JsonPatch(patch);    JsonArray  result  =  jsonPatch.apply(target); JSON-­‐P  1.1  JsonPatchBuilder  builder  =  new  JsonPatchBuilder();    JsonArray  result  =  builder.add("/Joe/phones/office",  "1234-­‐567")                                                        .remove("/Amy/age")                                                        .apply(contacts); 20
  21. 21. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐P  1.1 JSON-­‐Merge  Patch  –  IETF  RFC  7386 Orignal                                Patch                                      Result   {"a":"b"}                          {"a":"c"}                            {"a":"c"}   {"a":"b"}                          {"b":"c"}                            {"a":"b",                                                                                                                        "b":"c"}   {"a":"b"}                          {"a":null}                          {  }   {"a":"b",                          {"a":null}                          {"b":"c"}    "b":"c"}   {  }                                                  {"a":                                          {"a":                                                                {"bb":                                    {"bb":                                                                        {"ccc":                                {}}}                                                                                null}}}   21
  22. 22. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐P  1.1 {            "title":  "Hello!",            "author":  {                          "familyName":  null              },              "tags":  [  "example"  ],              "phoneNumber":  "+01-­‐123-­‐456-­‐7890"    }   {          "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 22
  23. 23. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    JsonObject  contact  =  …;  //  The  target  to  be  patched    JsonObject  patch  =  …;        JsonValue  output  =  JsonMergePatch.mergePatch(target,  patch); JSON-­‐P  1.1 JSON-­‐Merge  Patch  –  IETF  RFC  7386 23
  24. 24. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐P  1.1 • Reverse  operation   – Given  two  objects  returns  the  patch  to  apply  (diff)   JSON-­‐Patch  &  JSON-­‐Merge  Patch  Diff JsonValue  output  =  JsonMergePatch.diff(original,  target);   JsonArray  diff  =  JsonPatch.diff(original,  target); 24
  25. 25. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐P  1.1 JSON  Query  using  Lambda  Operations JsonArray  cars  =  ...;   List<String>  audis  =  cars.getValuesAs(JsonObject.class).stream()                                                    .filter(x-­‐>"Audi".equals(x.getString("brand")))                                                    .map(x-­‐>(x.getString("serial"))                                                    .collect(Collectors.toList()); 25
  26. 26. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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. 27. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   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 JSR  374 27
  28. 28. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐B • API  to  marshal/unmarshal  Java  objects  to/from  JSON   – Similar  to  JAXB  runtime  API  in  XML  world   • Default  mapping  of  classes  to  JSON   – Annotations  to  customize  the  default  mappings   – JsonProperty,  JsonTransient,  JsonNillable,  JsonValue,  … Java  API  for  JSON  Binding 28
  29. 29. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐B • Draw  from  best  practices  of  existing  JSON  binding  implementations   – Jackson,  Genson,  EclipseLink  MOXy,  Fleece,  JSON-­‐lib,  Gson,  Flexjson,  Json-­‐io,   JSONiJ,  Johnzon,  Xstream,  etc.   • Switch  JSON  binding  providers   • Implementations  compete  on  common  ground Standard  API 29
  30. 30. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JSON-­‐B // from default JsonbBuilder instance of the default JsonbProvider Jsonb jsonb = JsonbBuilder.create(); JsonbProvider myProvider = JsonbProvider.provider("foo.bar.ProviderImpl"); Jsonb jsonb = JsonbBuilder.newBuilder(myProvider); // UnMarshall Book book = jsonb.fromJson(new File("myBook.json"), Book.class); // Marshall jsonb.toJson(myObject, new File(“foo.json”)); jsonb.toJson(myObject, new PrintWriter(System.out)); 30
  31. 31. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Java  API  for  RESTful  Web  Services 31
  32. 32. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   Server-­‐sent  Events • Part  of  HTML5  standardization   • Server-­‐to-­‐client  streaming  of  text  data   • Media  type:  “text/event-­‐stream”   • Long-­‐lived  HTTP  connection   – Client  establishes  connection   – Server  pushes  update  notifications  to  client 32
  33. 33. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   Server-­‐sent  Events • Servlet,  WebSocket,  JAX-­‐RS  or  standalone  API?   • JAX-­‐RS  deemed  most  natural  fit   – Streaming  HTTP  resources  already  supported   – Small  extension   • Server  API:  new  media  type;  EventOutput     • Client  API:  new  handler  for  server  side  events   – Convenience  of  mixing  with  other  HTTP  operations;  new  media  type   – Jersey  already  supports  SSE 33
  34. 34. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   Server-­‐sent  Events @Path("tickers")   public  class  StockTicker  {   …        @Get        @Produces("text/event-­‐stream")        public  EventOutput  getQuotes()  {                EventOutput  eo  =  new  EventOutput();                new  StockThread(eo).start()                return  eo;        }   } JAX-­‐RS  resource  class 34
  35. 35. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JAX-­‐RS  StockThread  class class  StockThread  extends  Thread  {    private  EventOutput  eo;    …    @Override public  void  run()  {              try  { …                      eo.send(new  StockQuote("..."));                }  catch  (IOException  e)  {  …  } } } Server-­‐sent  Events 35
  36. 36. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   WebTarget  target  =  client.target("http://example.com/tickers");   EventSource  eventSource  =  new  EventSource(target)  {        @Override        public  void  onEvent(InboundEvent  inboundEvent)  {            StockQuote  sq  =  inboundEvent.readData(StockQuote.class);            //  ...          }      };   eventSource.open(); JAX-­‐RS  Client Server-­‐sent  Events 36
  37. 37. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   JAX-­‐RS  2.1 37 • Server-­‐sent  Events   • Improving  integration  with  CDI   • JSON-­‐B  Integration   • Building  upon  the  hypermedia  API   • NIO  support  in  providers  (filters,  interceptors,  …)   • Reactive  API   • JAX-­‐RS  resource  classes  as  MVC  controllers   • …
  38. 38. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Java  Servlet 38
  39. 39. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   HTTP  1.1  circa  1999 • HoLB   • HTTP  uses  TCP  poorly   - HTTP  flows  are  short  and  bursty   - TCP  was  built  for  long-­‐lived  flows   • Solutions   - File  concatenations,  Assets  Inlining,  Domain  sharding,  etc. Problems  Vs  Solutions 39
  40. 40. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   HTTP/2 • HTTP/2   – Hypertext  Transfer  Protocol  version  2  -­‐  RFC  7540   – HPACK  -­‐  Header  Compression  for  HTTP/2  -­‐  RFC  7541   • Reduce  latency   • Address  the  HOL  blocking  problem   • Support  parallelism   • Retain  semantics  of  HTTP  1.1   • Define  interaction  with  HTTP  1.x Address  the  Limitations  of  HTTP  1.x 40
  41. 41. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   HTTP/2 • One  TCP  Connection   • Request  -­‐>  Stream   – Multiplexed   – Prioritised   • Binary  Framing  Layer   – Prioritisation   – Flow  Control   – Server  Push   • Header  Compression Multiplexed  Binary  Frames POST  /upload  HTTP/1.1   Host:  www.test.com   Content-­‐Type:  application/json   Content-­‐Length:  15   {“name”:“duke”} HTTP  1.1 HTTP/2 HEADERS  frame DATA  frame 41
  42. 42. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   Stream  Prioritization • Stream  Dependency  in  HEADERS  Frame   • PRIORITY  frame  type   • An  additional  40  bytes   - Stream  id  (31)   - Weight  (8):  [1,  256]     - Exclusive  bit  (1)   • Only  an  advice A B C 4 12 A B CD 4 16 12 exclusive  =  0 A B C D 4 12 16 exclusive  =  1 42
  43. 43. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   HTTP/2 Server  Push /index.html  :  stream  1   /style.css  :  stream  2   /logo.png  :  stream  4 Client Server stream  1   HEADERS stream  1   FRAME  x stream  2   PROMISE stream  4   PROMISE 43
  44. 44. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   HTTP/2 Header  Compression 44
  45. 45. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   Servlet  4.0 • Request/response  multiplexing   – Servlet  Request  as  HTTP/2  message   • Stream  prioritization   – Add  stream  priority  to  HttpServletRequest   • Server  push   • Binary  framing   • Upgrade  from  HTTP  1.1 HTTP/2  Features  in  Servlet  API 45
  46. 46. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Push PushBuilder  builder = baseRequest.getPushBuilder(); builder.addHeader(“X-Pusher", …); builder.path(aResource) .etag(associated._etag) .lastModified(associated._lastModified) .push(); 46
  47. 47. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Stream  Prioritization 47 • New  Priority  class   – boolean  exclusive   – int  streamId   – int  weight   • New  methods  to  HttpServletRequest   – int  getStreamId()   – Priority  getPriority()   • New  methods  to  HttpServletResponse   – int  getStreamId()   – Priority  getPriority()   – void  setPriority(Priority  p)   • Dependency?
  48. 48. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. 48
  49. 49. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   49
  50. 50. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   50
  51. 51. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   51
  52. 52. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   52
  53. 53. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Model-­‐View-­‐Controller 53 • Pattern  used  to  implement  a  User  Interface   • Consists  of  3  major  components   – Model   – View   – Controller   • Each  of  the  components  has  a  distinct  responsibility
  54. 54. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Component-­‐based  MVC • A  specific  style  of  MVC  made  popular  by  component  frameworks   • Controller  provided  by  the  framework   • Examples   – JavaServer  Faces   – Wicket     – Tapestry   – Seam  (discontinued)   – Apache  Click  (retired) 54
  55. 55. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Action-­‐based  MVC • Controller(s)  defined  by  the  application   • Examples   – Struts  1  (end  of  life),  Struts  2   – Spring  MVC   • No  standard  Java  EE  implementation   – Good  news  we  are  creating  one!   – Targeted  for  inclusion  in  Java  EE  8 55
  56. 56. 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. JSR  371 56
  57. 57. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   MVC  1.0 • Action-­‐based  MVC   • Glues  together  key  Java  EE  technologies   – Model  :  CDI,  Bean  Validation,  JPA   –  View  :  Facelets,  JSP,  more?   –  Controller  :  Invent  new  technology  Vs.  Leverage  existing  technologies 57 Principles
  58. 58. 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() { // do something return "hello.jsp"; } } 58
  59. 59. 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.jsp") public void hello() { // do business stuff } } 59
  60. 60. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Controller @Path(“hello") @Controller public class HelloController { @GET public Viewable hello() { // some other stuff return new Viewable("hello.jsp"); } } 60
  61. 61. 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.jsp") .build(); } } 61
  62. 62. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Model • “Refers  to  the  data”   • CDI  @Named  bean   • javax.mvc.Models  interface 62
  63. 63. 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; } } 63
  64. 64. 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.set(“greeting”, new Greeting(“Salut”)); return “hello.jsp”; } } 64
  65. 65. 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/   65
  66. 66. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. View <%@ page contentType=“text/html;charset=UTF-8” language=“java” %> <html> <head> <title>Home</title> </head> <body> <p>${greeting.message}</p> </body> </html> 66
  67. 67. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.   View <html> <head> <title>FreeMarker</title> </head> <body> <p>Hello ${user}</p> … </body> </html> 67
  68. 68. 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,  Jade,  AsciiDoc,  … 68
  69. 69. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Miscellaneous • Bootstrap  via  javax.ws.rs.core.Application     • Validation   • Exception  Mapping  Providers   • New  @RedirectScoped  scope   • Security   • @Produces   • CDI  Events… 69
  70. 70. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. MVC • New  annotations   – @Controller,  @View,  @csrf,  @RedirectScoped   • Doing  MVC  now  is  not  a  bad  idea   – Leveraging  CDI,  JAX-­‐RS,  Facelets,  BV   – More?  Servlet  4.0’s  ServerPush   – Delivering  an  easy  migration  path  if  you  are  using  JSPs   • Offers  more  choices 70
  71. 71. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. JavaServer  Faces 71 • CDI  Alignment   – @Inject  FacesContext,  ExternalContext,  etc.   – CDI  managed  versions  of  Validator  and  Converter   – Rely  on  CDI  for  EL  resolving   – Invoking  CDI  managed  bean  methods  directly  from  Ajax,  etc.   • “Adjustments”  for  MVC   • Misc.   – Multi-­‐field  validation,  etc.
  72. 72. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Agenda Context   Web  Front  update   1 2 72 3 Context   Web  Front  update   Call  to  Action  
  73. 73. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Java  EE  8 • Java  EE  8  Platform  (JSR  366)   • CDI  2.0  (JSR  365)   • JSON  Binding  1.0  (JSR  367)   • JMS  2.1  (JSR  368)     • Servlet  4.0  (JSR  369)     • JAX-­‐RS  2.1  (JSR  370)   • MVC  1.0  (JSR  371)     • JSF  2.3  (JSR  372)   • Java  EE  Management  2.0  (JSR  373)   • JSON-­‐P  1.1  (JSR  374)   • Java  EE  Security  1.0  (JSR  375) So  far….. 73            Early  Draft  Review
  74. 74. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Roadmap • Q4  2015  Early  Draft   • Q1  2016  Public  Review   • Q3  2016  Proposed  Final  Draft   • H1  2017  Final  Release 74
  75. 75. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Contribute! • Join  the  JCP     • “Adopt-­‐A-­‐JSR”   – http://glassfish.java.net/adoptajsr   • Get  involved   – For  any  Spec,  join  users  mailing  list   – Test  SNAPSHOT  and  milestone  builds  of  RIs   – Tweet,  blog,  socialize  to  raise  awareness   – Fill  issues!   • The  Aquarium  Blog   – https://blogs.oracle.com/theaquarium/ 75
  76. 76. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved. Takk!
  77. 77. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.

×