Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Java EE 8 - What's new of the Web Front? by David Dalabassee

Riga Dev Day
March 13, 2016
36

Java EE 8 - What's new of the Web Front? by David Dalabassee

Riga Dev Day

March 13, 2016
Tweet

Transcript

  1. RigaDevDay   March  2016   David  Delabassee   @delabassee  

    Oracle Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.     Java  EE  8   What’s  new  on  the  Web  front? 1
  2. Safe  Harbor  Statement 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. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.  
  3. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Industry  Trends  We're  Seeing Cloud Mobile HTTP/2 SECURITY Reactive  Programming User  Experience
  4. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Community-­‐Prioritized  Features 5 http://glassfish.org/survey
  5. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Java  EE  8  Themes • HTML5  /  Web  Tier  Enhancements   • Ease  of  Development   • Infrastructure  for  running  in  the  Cloud 6
  6. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Java  EE  8  Themes • HTML5  /  Web  Tier  Enhancements   • Ease  of  Development   • Infrastructure  for  running  in  the  Cloud 7
  7. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Java  EE  8  Themes • HTML5  /  Web  Tier  Enhancements   • Ease  of  Development   • Infrastructure  for  running  in  the  Cloud 7
  8. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTML5  Support  /  Web  Tier  Enhancements • JSON  Binding   • JSON  Processing  enhancements   • Server-­‐sent  Events   • Action-­‐based  MVC   • HTTP/2  support 8
  9. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 9
  10. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐P  1.1 • String  syntax  for  referencing  a  JSON  value     "/0/phone/mobile" JSON-­‐Pointer  –  IETF  RFC  6901 10
  11. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}}   ]       11
  12. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}}   ]       11
  13. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}}   ]       11
  14. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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")); 12
  15. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}   ] 13
  16. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}}   ]       14
  17. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}}   ]       15
  18. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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"}}   ]       16
  19. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee  JsonArray  target  =  …;    JsonArray  patch  =  …;        JsonPatch  jsonPatch  =  new  JsonPatch(patch);    JsonArray  result  =  jsonPatch.apply(target); JSON-­‐P  1.1 17
  20. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee  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); 17
  21. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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}}}   18
  22. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 19
  23. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee  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 20
  24. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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); 21
  25. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐P  1.1 JSON  Query  using  Streams 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()); 22
  26. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐P  1.1 JSON  Query  using  Streams JsonArray  cars  =  ...;   JsonArray  audis  =  cars.getValuesAs(JsonObject.class).stream()                                              .filter(x  -­‐>  "Audi".equals(x.getString("brand")))                                              .map(x  -­‐>  (x.getString("serial")))                                              .collect(                                                      Collector.of(                                                          ()  -­‐>  Json.createArrayBuilder(),                                                            (builder,  value)  -­‐>  builder.add(value),                                                          (builder1,  builder2)  -­‐>  builder1.add(builder2),                                                            builder  -­‐>  builder.build()                                                      )                                              ); 23
  27. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐P  1.1 JSON  Query  using  Streams JsonArray  cars  =  ...;   JsonArray  audis  =  cars.getValuesAs(JsonObject.class).stream()                                                                                                            .filter(x-­‐>"Audi".equals(x.getString("brand")))                                                                                                            .map(x-­‐>(x.getString("serial"))                                                                                                            .collect(JsonCollectors.toJsonArray()); 24
  28. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐P  1.1 Misc.  JsonObject  source  =  …    source.forEach((key,  value)  -­‐>  {        //...    } 25
  29. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐P  1.1 Misc.  JsonObject  source  =  …    source.forEach((key,  value)  -­‐>  {        //...    }  JsonArray  contacts  =  (JsonArray)  JsonUtil.toJson(                          "[                                                                  "  +                          "    {  'name':  'Joanna',                          "  +                          "        'gender':  'F',                                "  +                          "        'phones':  {                                      "  +                          "              'mobile':  '505-­‐333-­‐4444'}}  "  +                          "]"); 25
  30. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 26
  31. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 27
  32. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 28
  33. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JSON-­‐B // from default JsonbBuilder instance of the default JsonbProvider Jsonb jsonb = JsonbBuilder.create(); 29
  34. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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); 29
  35. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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); // Marshall String result = jsonb.toJson(myObject); jsonb.toJson(myObject, new File(“foo.json”)); jsonb.toJson(myObject, new PrintWriter(System.out)); 29
  36. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 String result = jsonb.toJson(myObject); jsonb.toJson(myObject, new File(“foo.json”)); jsonb.toJson(myObject, new PrintWriter(System.out)); 29
  37. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JAX-­‐RS  2.1 30 • Alignment  with  MVC  and  JSON-­‐B   • Improving  integration  with  CDI   • NIO  support  in  providers  (filters,  interceptors,  …)   • Building  upon  the  hypermedia  API   • Reactive  API   • Server-­‐sent  Events
  38. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee JAX-­‐RS  2.1 …   CompletionStage<List<String>>  cs  =                                    client.target("forecast/{destination}")                                                .resolveTemplate("destination",  "mars")                                                .request()                                                .header("Rx-­‐User",  "Java8")                                                .rx()  //  CompletionStageRxInvoker                                                .get(new  GenericType<List<String>>()  {                                                });   cs.thenAccept(l  -­‐>  System.out.println(l)); Reactive  Client  API 31
  39. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee • 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 JAX-­‐RS  2.1 Server-­‐sent  Events
  40. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee • 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 JAX-­‐RS  2.1 Server-­‐sent  Events
  41. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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
  42. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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
  43. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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
  44. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 37
  45. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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   • Define  interaction  with  HTTP  1.x   • Retain  semantics  of  HTTP  1.x Address  the  Limitations  of  HTTP  1.x 38
  46. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Adoption 39 Last  year  we  announced  our  intent  to  end  support  for  the  experimental   protocol  SPDY  in  favor  of  the  standardized  version,  HTTP/2.  HTTP/2  is  the   next-­‐generation  protocol  for  transferring  information  on  the  web,  improving   upon  HTTP/1.1  with  more  features  leading  to  better  performance.     Since  then  we've  seen  huge  adoption  of  HTTP/2  from  both  web  servers   and  browsers,  with  most  now  supporting  HTTP/2.  Over  25%  of  resources  in   Chrome  are  currently  served  over  HTTP/2,  compared  to  less  than  5%  over   SPDY.  Based  on  such  strong  adoption,  starting  on  May  15th  —  the   anniversary  of  the  HTTP/2  RFC  —  Chrome  will  no  longer  support  SPDY.  … http://blog.chromium.org/2016/02/transitioning-­‐from-­‐spdy-­‐to-­‐http2.html
  47. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Adoption 40 http://caniuse.com/#search=http2 (1)  Partial  support  in  IE11  refers  to  being  limited  to  Windows  10   (2)  Only  supports  HTTP2  over  TLS   (3)  Partial  support  in  Safari  refers  to  being  limited  to  OSX  10.11+
  48. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Adoption 40 http://caniuse.com/#search=http2 (1)  Partial  support  in  IE11  refers  to  being  limited  to  Windows  10   (2)  Only  supports  HTTP2  over  TLS   (3)  Partial  support  in  Safari  refers  to  being  limited  to  OSX  10.11+
  49. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTTP/2 • One  TCP  Connection   • Request  -­‐>  Stream   – Multiplexed   – Prioritised   • Binary  Framing  Layer   – Prioritisation   – Flow  Control   – Server  Push   • Header  Compression 41
  50. @delabassee Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights

     reserved. Binary  Frames • Frames   - HEADERS,  DATA,  PRIORITY,  RST_STREAM,  SETTINGS,  PUSH_PROMISE,  PING,   GOAWAY,  WINDOW_UPDATE,  CONTINUATION   • Single  TCP  Connection 42 POST  /upload  HTTP/1.1   Host:  www.test.com   Content-­‐Type:  application/json   Content-­‐Length:  15   {“name”:“duke”} HTTP  1.1
  51. @delabassee Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights

     reserved. Binary  Frames • Frames   - HEADERS,  DATA,  PRIORITY,  RST_STREAM,  SETTINGS,  PUSH_PROMISE,  PING,   GOAWAY,  WINDOW_UPDATE,  CONTINUATION   • Single  TCP  Connection 42 POST  /upload  HTTP/1.1   Host:  www.test.com   Content-­‐Type:  application/json   Content-­‐Length:  15   {“name”:“duke”} HTTP  1.1
  52. @delabassee Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights

     reserved. Binary  Frames • Frames   - HEADERS,  DATA,  PRIORITY,  RST_STREAM,  SETTINGS,  PUSH_PROMISE,  PING,   GOAWAY,  WINDOW_UPDATE,  CONTINUATION   • Single  TCP  Connection 42 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
  53. @delabassee Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights

     reserved. Binary  Frames • Frames   - HEADERS,  DATA,  PRIORITY,  RST_STREAM,  SETTINGS,  PUSH_PROMISE,  PING,   GOAWAY,  WINDOW_UPDATE,  CONTINUATION   • Single  TCP  Connection 42 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
  54. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTTP/2 Server  Push /index.html  :  stream  1   /style.css  :  stream  2   /logo.png  :  stream  4 Client Server stream  1   HEADERS 44
  55. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTTP/2 Server  Push /index.html  :  stream  1   /style.css  :  stream  2   /logo.png  :  stream  4 Client Server stream  1   HEADERS 44
  56. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTTP/2 Server  Push /index.html  :  stream  1   /style.css  :  stream  2   /logo.png  :  stream  4 Client Server stream  1   HEADERS stream  2   PROMISE 44
  57. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTTP/2 Server  Push /index.html  :  stream  1   /style.css  :  stream  2   /logo.png  :  stream  4 Client Server stream  1   HEADERS stream  2   PROMISE stream  4   PROMISE 44
  58. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee HTTP/2 Server  Push /index.html  :  stream  1   /style.css  :  stream  2   /logo.png  :  stream  4 Client Server stream  1   HEADERS stream  1   DATA  x stream  2   PROMISE stream  4   PROMISE 44
  59. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 46 HTTP/2  Features • Binary  Framing  over  single  TCP  connection   • Request/Response  multiplexing   • Server  Push   • Upgrade  from  HTTP  1.1   • Header  Compression   • Preserve  HTTP  semantic   • Stream  Prioritization   • Flow  Control
  60. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 46 HTTP/2  Features • Binary  Framing  over  single  TCP  connection   • Request/Response  multiplexing   • Server  Push   • Upgrade  from  HTTP  1.1   • Header  Compression   • Preserve  HTTP  semantic   • Stream  Prioritization   • Flow  Control
  61. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee • Binary  Framing  over  single  TCP  connection   • Request/Response  multiplexing   • Server  Push   • Upgrade  from  HTTP  1.1   • Header  Compression   • Preserve  HTTP  semantic   • Stream  Prioritization   • Flow  Control 47 HTTP/2  Features Servlet  4
  62. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 48 Servlet  4 • New  javax.servlet.http.PushBuilder  interface   Server  Push
  63. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 48 Servlet  4 • New  javax.servlet.http.PushBuilder  interface   Server  Push PushBuilder  pusher = myServletRequest.getPushBuilder(); pusher.path(aResource) .method("GET") // default: GET .etag(associated._etag) .addHeader("X-Pusher", …); // + setHeader .removeHeader(notNeeded) .lastModified(associated._lastModified); pusher.push(); // path, etag, lastModified will be cleared
  64. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 48 Servlet  4 • New  javax.servlet.http.PushBuilder  interface   Server  Push PushBuilder  pusher = myServletRequest.getPushBuilder(); pusher.path(aResource) .method("GET") // default: GET .etag(associated._etag) .addHeader("X-Pusher", …); // + setHeader .removeHeader(notNeeded) .lastModified(associated._lastModified); pusher.push(); // path, etag, lastModified will be cleared
  65. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 48 Servlet  4 • New  javax.servlet.http.PushBuilder  interface   Server  Push PushBuilder  pusher = myServletRequest.getPushBuilder(); pusher.path(aResource) .method("GET") // default: GET .etag(associated._etag) .addHeader("X-Pusher", …); // + setHeader .removeHeader(notNeeded) .lastModified(associated._lastModified); pusher.push(); // path, etag, lastModified will be cleared
  66. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 49 Servlet  4 • Disable  Server  Push     - SETTINGS_ENABLE_PUSH  -­‐>  0     • Refuse  Server  Push     - CANCEL  or  REFUSED_STREAM  +  Id Server  Push
  67. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 50 HTTP/2  Features • Binary  Framing  over  single  TCP  connection   • Request/Response  multiplexing   • Stream  Prioritization   • Server  Push   • Upgrade  from  HTTP  1.1   • Header  Compression   • Preserve  HTTP  semantic   • Flow  Control Servlet  4
  68. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Action-­‐based  MVC • Controller(s)  defined  by  the  application   • Examples   – Struts  1  (EoL),  Struts  2   – Spring  MVC   • UI  landscape  is  not  one  size  fits  all     • No  standard  Java  EE  implementation   – JSR  371   – “Action-­‐based”  MVC  1.0  JSR   – Targeted  for  inclusion  in  Java  EE  8 51
  69. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee 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 52 Principles
  70. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee 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”; } } 53
  71. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Controller • Class/method  decorated  with  @Controller @Path(“hello") @Controller public class HelloController { @GET @View(“hello.md”) public void hello() { // do business stuff } } 54
  72. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Controller @Path(“hello") @Controller public class HelloController { @GET public Viewable hello() { // some other stuff return new Viewable("hello.adoc"); } } 55
  73. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee 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(); } } 56
  74. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Model • CDI  @Named  bean   • javax.mvc.Models  interface 57
  75. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Model @Named(“greeting”) @RequestScoped public class Greeting { private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } } 58
  76. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Model @Path(“hello”) public class HelloController { @Inject private Models models; @GET @Controller public String hello() { models.set(“greeting”, new Greeting(“Salut”)); return “hello.jsp”; } } 59
  77. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee 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/   60
  78. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee View <html> <head> <title>FreeMarker</title> </head> <body> <p>Hello ${user}</p> … </body> </html> 61
  79. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee 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,  … 62
  80. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee 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   – Easy  migration  path  for  JSPs   • Offers  more  choices 63
  81. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee JavaServer  Faces 64 FacesContext facesContext = FacesContext.getCurrentInstance() ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Map<String, Object> cookieMap = FacesContext.getCurrentInstance() .getExternalContext().getRequestCookieMap(); … Artefacts  Injection @Inject private ExternalContext context;
  82. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee JavaServer  Faces 65 • 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.
  83. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Java  EE  8  Themes • HTML5  /  Web  Tier  Enhancements   • Ease  of  Development   • Infrastructure  for  running  in  the  Cloud   • Java  SE  8  alignment 66
  84. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee Java  EE  8  Themes • HTML5  /  Web  Tier  Enhancements   • Ease  of  Development   • Infrastructure  for  running  in  the  Cloud   • Java  SE  8  alignment 66
  85. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee Java  EE  8 So  far….. 67            Early  Draft  Review
  86. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.

    @delabassee 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….. 67            Early  Draft  Review
  87. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee More  to  Follow… • Batch     • JPA   • Bean  Validation   • Connector  Architecture   • WebSocket   • Interceptors   • EJB   • JTA   • JCache   • Concurrency  Utilities     • JavaMail   • … 68
  88. Copyright  ©  2016,  Oracle  and/or  its  affiliates.  All  rights  reserved.

      @delabassee • The  Aquarium   – http://blogs.oracle.com/theaquarium   • Java  EE  8  Platform   – http://javaee-­‐spec.java.net   • Java  EE  Reference  Implementation   – http://glassfish.org 69 More  to  Follow…