SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
JAX-­‐RS.next	
  
Michal	
  Gajdos	
  
michal.gajdos@oracle.com	
  
	
  
January,	
  2015	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Safe	
  Harbor	
  Statement	
  
The	
  following	
  is	
  intended	
  to	
  outline	
  our	
  general	
  product	
  direcPon.	
  It	
  is	
  intended	
  for	
  
informaPon	
  purposes	
  only,	
  and	
  may	
  not	
  be	
  incorporated	
  into	
  any	
  contract.	
  It	
  is	
  not	
  a	
  
commitment	
  to	
  deliver	
  any	
  material,	
  code,	
  or	
  funcPonality,	
  and	
  should	
  not	
  be	
  relied	
  upon	
  
in	
  making	
  purchasing	
  decisions.	
  The	
  development,	
  release,	
  and	
  Pming	
  of	
  any	
  features	
  or	
  
funcPonality	
  described	
  for	
  Oracle’s	
  products	
  remains	
  at	
  the	
  sole	
  discrePon	
  of	
  Oracle.	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
•  Generic	
  
–  Protocol-­‐independent	
  
–  In	
  retrospect,	
  most	
  important	
  Java	
  EE	
  
technology	
  
•  But	
  brought	
  HTTP	
  to	
  Java	
  EE	
  
•  Old-­‐school	
  Programming	
  Model	
  
–  StaPc,	
  Interface-­‐driven	
  
–  Singleton-­‐Scoped	
  
–  Lot’s	
  of	
  distracPons	
  /	
  boilerplate	
  
•  Laser-­‐focused	
  on	
  REST	
  Services	
  
–  HTTP	
  Centric	
  
•  method	
  matching,	
  content	
  negoPaPon,	
  …	
  
–  Payload	
  format	
  independence	
  
•  decoupled	
  from	
  business	
  logic	
  
•  Modern	
  Programming	
  Model	
  
–  Dynamic,	
  POJO-­‐based,	
  AnnotaPon-­‐driven	
  
–  Request-­‐Scoped	
  
–  No	
  distracPons	
  /	
  boilerplate	
  
HTTP	
  in	
  Java	
  EE:	
  From	
  Servlet	
  to	
  JAX-­‐RS	
  
Simplicity,	
  ProducPvity,	
  RESTful	
  Design	
  Servlet	
   JAX-­‐RS	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
public	
  class	
  MyServlet	
  extends	
  HttpServlet	
  {	
  
	
  	
  protected	
  void	
  doGet(HttpServletRequest	
  req,	
  HttpServletResponse	
  res)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  if	
  (!acceptsTextPlain(req))	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  res.sendError(406);	
  //	
  Not	
  Acceptable	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  return;	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  if	
  (!isGreetingPath(req))	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  res.sendError(404);	
  //	
  Not	
  Found	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  return;	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  String	
  name	
  =	
  req.getParameter(“name”);	
  
	
  	
  	
  	
  	
  	
  	
  	
  if	
  (name	
  ==	
  null)	
  {	
  name	
  =	
  “Joe”;	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  PrintWriter	
  pw	
  =	
  res.getWriter();	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  pw.print(“Hi	
  “	
  +	
  name	
  +	
  “!”);	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  pw.flush();	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  …	
  //	
  TODO:	
  acceptsTextPlain(…)	
  &	
  isGreetingPath(…)	
  implementations	
  
}	
  
@Path(“greeting”)	
  
public	
  class	
  MyResource	
  {	
  
	
  	
  	
  	
  @GET	
  @Produces(“text/plain”)	
  
	
  	
  	
  	
  public	
  String	
  greet(@QueryParam(“name”)	
  @DefaultValue(“Joe”)	
  String	
  name)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  “Hi	
  “	
  +	
  name	
  +	
  “!”;	
  
	
  	
  	
  	
  }	
  
}	
  
HTTP	
  in	
  Java	
  EE:	
  From	
  Servlet	
  to	
  JAX-­‐RS	
  
Simplicity,	
  ProducPvity,	
  RESTful	
  Design	
  Servlet	
   JAX-­‐RS	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
EnPty	
  
Providers	
  
Server	
  API	
  
Contexts	
  &	
  
InjecPon	
  
ExcepPon	
  
Mappers	
  
CDI	
  Support	
  
EnPty	
  
Providers	
  
Server	
  API	
  
Contexts	
  &	
  
InjecPon	
  
ExcepPon	
  
Mappers	
  
Zero-­‐XML	
  
Deployment	
  
EvoluPon	
  of	
  JAX-­‐RS	
  API	
  
EnPty	
  
Providers	
  
Client	
  API	
  
Zero-­‐XML	
  
Deployment	
  
ExcepPon	
  
Hierarchy	
  
Async	
  
Support	
  
Common	
  
Config	
  
CDI	
  Support	
  Server	
  API	
  
Contexts	
  &	
  
InjecPon	
  
ExcepPon	
  
Mappers	
  
Filters	
  &	
  
Interceptors	
  
Hypermedia	
  
Support	
  
JAX-­‐RS	
  1.0	
   JAX-­‐RS	
  1.1	
   JAX-­‐RS	
  2.0	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
•  Performance	
  
– ReacPve	
  Programming	
  Model	
  
– Java	
  SE	
  8	
  Streams	
  
– Non-­‐blocking	
  I/O	
  
•  Java	
  EE	
  Alignment	
  
– CDI	
  Alignment	
  
– DeclaraPve	
  Security	
  Model	
  
– MVC	
  1.0	
  &	
  JSONB	
  1.0	
  IntegraPon	
  
•  Filling	
  the	
  Gaps	
  
– Server-­‐Sent	
  Events	
  
– Improved	
  Hypermedia	
  Support	
  
•  ConPnued	
  EvoluPon	
  
–  All	
  simple	
  problems	
  have	
  already	
  been	
  solved…	
  
•  Targeted	
  to	
  Ship	
  with	
  Java	
  EE	
  8	
  
JSR-­‐370	
  –	
  JAX-­‐RS.next	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Program	
  Agenda	
  
Server-­‐Sent	
  Events	
  
Non-­‐Blocking	
  I/O	
  
DeclaraPve	
  Security	
  
MVC	
  IntegraPon	
  
CDI	
  Alignment,	
  JSON-­‐B,	
  …	
  
1	
  
2	
  
3	
  
4	
  
5	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Server-­‐Sent	
  Events	
  
	
  
	
  
	
  
	
  
	
  
	
  
•  Plain	
  old	
  HTTP	
  
•  Seamless	
  reconnect	
  &	
  redelivery	
  
•  HTML	
  5	
  standard	
  protocol	
  
Ajax	
  Long-­‐Polling	
  
	
  
	
  
	
  
	
  
	
  
	
  
•  Plain	
  old	
  HTTP	
  
•  Manual	
  reconnect	
  
•  Undefined	
  format	
  
WebSocket	
  
	
  
	
  
	
  
	
  
	
  
	
  
•  New	
  Protocol	
  (via	
  HTTP	
  upgrade)	
  
•  Full-­‐duplex	
  
•  HTML	
  5	
  standard	
  protocol	
  
Ajax	
  Long-­‐Polling	
  vs.	
  Server-­‐Sent	
  Events	
  vs.	
  WebSocket	
  
Time	
  
Server	
  
Client	
  
Time	
  
Server	
  
Client	
  
Time	
  
Server	
  
Client	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Why	
  Server-­‐Sent	
  Events?	
  
•  Streaming	
  asynchronous	
  events	
  from	
  Server	
  to	
  Client	
  
	
  
•  Fits	
  well	
  Ajax	
  Long-­‐Polling	
  Use	
  Cases	
  
– Progress	
  for	
  long-­‐running	
  tasks	
  	
  
– Stream	
  of	
  real-­‐Pme	
  data	
  updates	
  (e.g.	
  Stock	
  Ticker,	
  Monitoring)	
  
– Instant	
  server	
  state	
  change	
  noPficaPons	
  (e.g.	
  SysAdmin	
  Message	
  Push)	
  
– Task	
  processing	
  distribuPon	
  
– …	
  
•  Part	
  of	
  HTML5	
  Standard	
  by	
  W3C	
  	
  
– Built-­‐in	
  support	
  in	
  all	
  modern	
  browsers	
  
– Standard	
  event	
  message	
  format	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
	
  
	
  
	
  
:	
  Comment	
  lines	
  start	
  with	
  a	
  ‘:’	
  prefix	
  
:	
  Events	
  can	
  have	
  numeric	
  IDs…	
  
id:	
  1234	
  
:	
  …can	
  contain	
  reconnect	
  delay	
  instructions…	
  
retry:	
  5000	
  
:	
  …can	
  be	
  named…	
  
event:	
  text-­‐message	
  
:	
  …typically	
  contain	
  one	
  or	
  more	
  lines	
  of	
  event	
  payload	
  data.	
  
data:	
  Hello,	
  this	
  is	
  a	
  
data:	
  multi-­‐line	
  message.	
  
:	
  Events	
  are	
  separated	
  from	
  each	
  other	
  by	
  a	
  blank	
  line.	
  
<blank	
  line>	
  
	
  
An	
  SSE	
  Event	
  Message	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Typical	
  HTTP	
  Request	
  /	
  Response	
  Flow	
  
JAX-­‐RS	
  
Resource	
  
invoke()	
  GET	
  /resource	
  HTTP/1.1	
  
HTTP/1.1	
  200	
  OK	
  
<CR+LF>	
  
data	
  
data	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Asynchronous	
  HTTP	
  Request	
  /	
  Response	
  Flow	
  
JAX-­‐RS	
  
Resource	
  
invoke()	
  GET	
  /resource	
  HTTP/1.1	
  
resume(data)	
  
HTTP/1.1	
  200	
  OK	
  
<CR+LF>	
  
data	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Server-­‐Sent	
  Events	
  Flow	
  
JAX-­‐RS	
  
Resource	
  
invoke()	
  GET	
  /resource	
  HTTP/1.1	
  
write(event)	
  
write(event)	
  
…	
  
event	
  
event	
  
…	
  
[event]	
  HTTP/1.1	
  200	
  OK	
  
<CR+LF>	
  
[event]	
  
close()	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Producer	
  API	
  –	
  Server	
  side	
  
OutboundEvent	
  	
  
–  single	
  event;	
  outgoing	
  
EventOutput	
  
–  single	
  client	
  connecPon;	
  outbound	
  
SseBroadcaster	
  
–  connecPon	
  aggregaPon	
  
–  BroadcasterListener	
  
•  broadcast	
  noPficaPon	
  
Consumer	
  API	
  –	
  Client	
  side	
  
InboundEvent	
  
–  single	
  event;	
  incoming	
  
EventInput	
  
–  streaming	
  connecPon;	
  inbound	
  
EventSource	
  
–  IoC	
  connecPon;	
  inbound	
  
–  EventListener	
  
•  asynchronous	
  event	
  processing	
  
Jersey	
  Server-­‐Sent	
  Events	
  API	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
@Path(“messages”)	
  
@Produces(APPLICATION_JSON)	
  
public	
  class	
  MessageBoardResource	
  {	
  
	
  
	
  	
  	
  	
  private	
  static	
  SseBroadcaster	
  broadcaster	
  =	
  new	
  SseBroadcaster();	
  
	
  	
  	
  	
  	
  
	
  	
  	
  	
  @GET	
  @Path(“stream”)	
  
	
  	
  	
  	
  @Produces(SseFeature.SERVER_SENT_EVENTS)	
  
	
  	
  	
  	
  public	
  EventOutput	
  connect()	
  {	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  EventOutput	
  eventOutput	
  =	
  new	
  EventOutput();	
  
	
  	
  	
  	
  	
  	
  	
  	
  broadcaster.add(eventOutput);	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  eventOutput;	
  
	
  	
  	
  	
  	
  
	
  	
  	
  	
  }	
  
	
  
	
  	
  	
  	
  …	
  
Server-­‐side	
  –	
  ConnecPng	
  to	
  an	
  Event	
  Source	
  
Create	
  Outbound	
  ConnecPon	
  
Store	
  Outbound	
  ConnecPon	
  
Return	
  Outbound	
  ConnecPon	
  
Create	
  Broadcaster	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Server-­‐Sent	
  Events	
  Flow	
  
JAX-­‐RS	
  
Resource	
  
invoke()	
  GET	
  /resource	
  HTTP/1.1	
  
HTTP/1.1	
  200	
  OK	
  
<CR+LF>	
  
[event]	
  
eventOutput	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
	
  	
  	
  	
  …	
  	
  	
  	
  
	
  
	
  	
  	
  	
  @POST	
  	
  
	
  	
  	
  	
  @Consumes(MediaType.APPLICATION_JSON)	
  
	
  	
  	
  	
  public	
  String	
  postMessage(Message	
  message)	
  {	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  OutboundEvent	
  event	
  =	
  new	
  OutboundEvent.Builder()	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .id(getNextId())	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .mediaType(MediaType.APPLICATION_JSON_TYPE)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .data(Message.class,	
  message)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .build();	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  broadcaster.broadcast(event);	
  //	
  invokes	
  eventOutput.write(event);	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  “Message	
  posted!”	
  
	
  	
  	
  	
  }	
  
}	
  
Server-­‐side	
  –	
  Dispatching	
  Events	
  
Create	
  Outbound	
  Event	
  
Send	
  Outbound	
  Event	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Server-­‐Sent	
  Events	
  Flow	
  
JAX-­‐RS	
  
Resource	
  
invoke()	
  GET	
  /resource	
  HTTP/1.1	
  
HTTP/1.1	
  200	
  OK	
  
eventOutput	
  
write(event)	
  
write(event)	
  
…	
  event	
  
event	
  
…	
  
close()	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
EventSource	
  eventSource	
  =	
  	
  
	
  	
  	
  	
  new	
  EventSource(target.path(“messages/stream”))	
  {	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  @Override	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  public	
  void	
  onEvent(InboundEvent	
  event)	
  {	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  String	
  name	
  =	
  event.getName();	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Message	
  message	
  =	
  event.readData(Message.class);	
  
	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  display(name,	
  message);	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  	
  
	
  	
  	
  	
  };	
  
	
  
…	
  
	
  
eventSource.close();	
  
	
  
Client-­‐side	
  Event	
  Processing	
  –	
  IoC	
  Model	
  
Create	
  Event	
  Source	
  
Close	
  Event	
  Source	
  
Implement	
  Event	
  Callback	
  
Process	
  Inbound	
  Event	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
EventInput	
  events	
  =	
  target.path(“messages/stream”)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .request().get(EventInput.class);	
  
	
  
while	
  (!stop)	
  {	
  
	
  
	
  	
  	
  	
  InboundEvent	
  event	
  =	
  events.read();	
  
	
  	
  	
  	
  String	
  name	
  =	
  event.getName();	
  
	
  	
  	
  	
  Message	
  message	
  =	
  event.readData(Message.class);	
  
	
  	
  	
  	
  	
  
	
  	
  	
  	
  display(name,	
  message);	
  	
  
}	
  
	
  
events.close();	
  
Client-­‐side	
  Event	
  Processing	
  –	
  Pull	
  Model	
  
Retrieve	
  Event	
  Stream	
  
Close	
  Event	
  Source	
  
Implement	
  Event	
  Loop	
  
Process	
  Inbound	
  Event	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Program	
  Agenda	
  
Server-­‐Sent	
  Events	
  
Non-­‐Blocking	
  I/O	
  
DeclaraPve	
  Security	
  
MVC	
  IntegraPon	
  
CDI	
  Alignment,	
  JSON-­‐B,	
  …	
  
1	
  
2	
  
3	
  
4	
  
5	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Servlet	
  3.1	
  Non-­‐Blocking	
  I/O	
  API	
  
•  Receiving	
  data	
  
– ServletInputStream	
  
•  isReady(),	
  isFinished(),	
  setReadListener(ReadListener)	
  
– ReadListener	
  
•  onDataAvailable(),	
  onError(Throwable),	
  onAllDataRead()	
  
•  Sending	
  data	
  
– ServletOutputStream	
  
•  isReady(),	
  setWriteListener(WriteListener)	
  
– WriteListener	
  
•  onWritePossible(),	
  onError(Throwable)	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Non-­‐Blocking	
  I/O	
  API	
  in	
  JAX-­‐RS	
  
•  Main	
  Constraints	
  and	
  Goals	
  
– Backward-­‐compaPbility	
  
– Alignment	
  with	
  Servlet	
  3.1	
  Non-­‐Blocking	
  I/O	
  API	
  
•  At	
  least	
  conceptually	
  
– Support	
  for	
  standalone	
  JAX-­‐RS	
  deployments	
  
•  no	
  hard	
  dependency	
  on	
  Servlet	
  API	
  
•  Problems	
  to	
  solve	
  
– Unclear	
  impact	
  on	
  request/response	
  processing	
  chain	
  
– MulPple	
  extension	
  points	
  to	
  cover	
  (in	
  a	
  backward-­‐compaPble	
  way)	
  
•  Filters,	
  Interceptors,	
  EnPty	
  Providers,	
  ExcepPon	
  Mappers,	
  Parameter	
  Converters	
  
•  PotenPal	
  interoperability	
  issues	
  in	
  mixed	
  models	
  
–  e.g.	
  blocking	
  and	
  non-­‐blocking	
  request	
  filter	
  in	
  the	
  same	
  processing	
  chain	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Program	
  Agenda	
  
Server-­‐Sent	
  Events	
  
Non-­‐Blocking	
  I/O	
  
DeclaraPve	
  Security	
  
MVC	
  IntegraPon	
  
CDI	
  Alignment,	
  JSON-­‐B,	
  …	
  
1	
  
2	
  
3	
  
4	
  
5	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Securing	
  Resources	
  in	
  JAX-­‐RS	
  
•  New	
  Security	
  JSR	
  planned	
  for	
  Java	
  EE	
  8	
  
– Focused	
  on	
  unificaPon,	
  ease	
  of	
  use	
  and	
  portability	
  improvements	
  
– JAX-­‐RS	
  EG	
  will	
  monitor	
  progress	
  of	
  this	
  JSR	
  
•  OAuth	
  2.0	
  gaining	
  a	
  lot	
  of	
  adopPon	
  from	
  many	
  big	
  players	
  
– Google,	
  Facebook,	
  Twiler,	
  …	
  
•  Vision	
  for	
  REST	
  Services	
  Security	
  Model	
  in	
  Java	
  EE	
  
– Easy	
  and	
  Straighmorward	
  
– DeclaraPve	
  whenever	
  possible	
  
•  Java	
  EE	
  Security	
  AnnotaPons	
  fit	
  JAX-­‐RS	
  very	
  well	
  
•  Jersey	
  already	
  provides	
  annotaPon-­‐based	
  authorizaPon	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
ExisPng	
  Jersey	
  Security	
  Features	
  
•  Leveraging	
  standard	
  JAX-­‐RS	
  extension	
  points	
  
•  Off-­‐the-­‐shelf	
  modules	
  &	
  components	
  ready	
  to	
  use	
  
•  Client-­‐side	
  
– HTTP	
  Basic	
  &	
  Digest	
  AuthenPcaPon	
  Support	
  
•  Server-­‐side	
  
– DeclaraPve	
  Role-­‐base	
  AuthorizaPon	
  (javax.annotation.security)	
  
•  @RolesAllowed,	
  @PermitAll,	
  @DenyAll	
  	
  
•  OAuth	
  1.0,	
  2.0	
  Support	
  
– Client	
  and	
  Server	
  Side	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
	
  
@Path(“messages”)	
  
@Produces(APPLICATION_JSON)	
  
@DenyAll	
  
public	
  class	
  MessageBoardResource	
  {	
  
	
  	
  	
  	
  …	
  
	
  	
  	
  	
  	
  
	
  	
  	
  	
  @GET	
  @Path(“stream”)	
  
	
  	
  	
  	
  @Produces(SseFeature.SERVER_SENT_EVENTS)	
  	
  	
  	
  	
  
	
  	
  	
  	
  @PermitAll	
  
	
  	
  	
  	
  public	
  EventOutput	
  connect()	
  {	
  …	
  }	
  
	
  
	
  	
  	
  	
  @POST	
  	
  
	
  	
  	
  	
  @Consumes(MediaType.APPLICATION_JSON)	
  
	
  	
  	
  	
  @RolesAllowed(“publisher”)	
  
	
  	
  	
  	
  public	
  String	
  postMessage(Message	
  message)	
  {	
  …	
  }	
  
}	
  
AuthorizaPon	
  in	
  Jersey	
  
No	
  access	
  by	
  default	
  
Only	
  “publisher”	
  role	
  
Public	
  access	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Program	
  Agenda	
  
Server-­‐Sent	
  Events	
  
Non-­‐Blocking	
  I/O	
  
DeclaraPve	
  Security	
  
MVC	
  IntegraPon	
  
CDI	
  Alignment,	
  JSON-­‐B,	
  …	
  
1	
  
2	
  
3	
  
4	
  
5	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Different	
  Tastes	
  of	
  MVC	
  Frameworks	
  
UI	
  Component-­‐Oriented	
  
Browser	
  
Framework	
   ApplicaPon	
  
Controller	
  
Renderer	
  
Views	
   Models	
  
EL	
  
EL	
  
EL	
  
EL	
  
AcLon-­‐Oriented	
  
Browser	
  
Framework	
   ApplicaPon	
  
Dispatcher	
  
Controllers	
   Templates	
  
AcPons	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
•  New,	
  dedicated	
  JSR	
  371	
  –	
  MVC	
  1.0	
  	
  
–  Focus	
  on	
  acPon-­‐oriented	
  Framework	
  
–  Leverage	
  exisPng	
  templaPng	
  engines	
  (JSP,	
  Facelets)	
  
–  Integrate	
  with	
  JAX-­‐RS	
  
•  Model	
  
–  Context,	
  InjecPon	
  and	
  Bean	
  ValidaPon	
  support	
  
–  CDI	
  Beans	
  
•  View	
  
–  Format	
  content	
  based	
  on	
  Model	
  data	
  
–  Templates	
  (JSP,	
  Facelets,	
  FreeMarker,	
  Mustache,	
  …)	
  
•  Controller	
  
–  Dispatch	
  model	
  data	
  to	
  View	
  templates	
  
–  JAX-­‐RS	
  Resources	
  
•  NaPve	
  content-­‐negoPaPon	
  support	
  
MVC	
  
Model	
  
CDI	
  Beans	
  
View	
  
Templates	
  
Controller	
  
JAX-­‐RS	
  Resources	
  
MVC	
  and	
  JAX-­‐RS	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
•  Jersey	
  extension	
  modules	
  
– org.glassfish.jersey.ext	
  
•  Core	
  Module	
  (jersey-­‐mvc)	
  
– View	
  Templates	
  
•  Producing	
  Human-­‐Readable	
  Content	
  
•  Convenient	
  Generators	
  for	
  new	
  Media	
  Types	
  
•  IntegraPon	
  Modules	
  
– TemplaPng	
  Engines	
  
•  JSP,	
  FreeMarker,	
  Moustache	
  
– BeanValidaPon	
  &	
  Error	
  ReporPng	
  
•  MinimalisPc	
  Public	
  APIs	
  
– ProgrammaPc	
  
•  Viewable	
  
– DeclaraPve	
  
•  @Template	
  
•  @ErrorTemplate	
  
Jersey	
  MVC	
  Support	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
	
  
	
  
@Path(“motorcycle/{name}”)	
  
public	
  class	
  MotorcycleResource	
  {	
  
	
  	
  	
  	
  	
  
	
  	
  	
  	
  @Inject	
  @NotNull	
  Catalog<Motorcycle>	
  catalog;	
  
	
  
	
  	
  	
  	
  @GET	
  @Produces(TEXT_HTML)	
  
	
  	
  	
  	
  @Template(name=“motorcycle.jsp”)	
  
	
  	
  	
  	
  public	
  Motorcycle	
  getHtml(@PathParam(“name”)	
  String	
  name)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  catalog.getModel(name);	
  
	
  	
  	
  	
  }	
  
	
  
	
  	
  	
  	
  @Path(“parts”)	
  
	
  	
  	
  	
  public	
  PartsListResource	
  getParts(@PathParam(“name”)	
  String	
  name)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  new	
  PartsListResource(catalog,	
  name);	
  
	
  	
  	
  	
  }	
  
}	
  
Jersey	
  MVC	
  Templates	
  
Model	
  
Controller	
  
View	
  
Sub-­‐controller	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
public	
  class	
  PartsListResource	
  {	
  
	
  
	
  	
  	
  	
  private	
  final	
  String	
  name;	
  
	
  	
  	
  	
  private	
  final	
  Catalog	
  catalog;	
  
	
  	
  	
  	
  …	
  
	
  	
  	
  	
  @POST	
  @Consumes(APPLICATION_JSON)	
  
	
  	
  	
  	
  public	
  String	
  addPartJson(Part	
  part)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  catalog.getModel(name).addPart(part);	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  “Part	
  added.”;	
  
	
  	
  	
  	
  }	
  
	
  
	
  	
  	
  	
  @POST	
  @Consumes(APPLICATION_FORM_URLENCODED)	
  
	
  	
  	
  	
  @Template(name=“confirmation.jsp”)	
  
	
  	
  	
  	
  public	
  String	
  addPartForm(@BeanParam	
  PartFormBean	
  bean)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  catalog.getModel(name).addPart(bean.toPart());	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  “Part	
  added.”;	
  
	
  	
  	
  	
  }	
  
}	
  
Jersey	
  MVC	
  Templates	
  (contd.)	
  
Non-­‐browser	
  
Clients	
  
Browser	
  Clients	
  
View	
  
Sub-­‐Controller	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Program	
  Agenda	
  
Server-­‐Sent	
  Events	
  
Non-­‐Blocking	
  I/O	
  
DeclaraPve	
  Security	
  
MVC	
  IntegraPon	
  
CDI	
  Alignment,	
  JSON-­‐B,	
  …	
  
1	
  
2	
  
3	
  
4	
  
5	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
•  API	
  with	
  a	
  Feel	
  Similar	
  to	
  JAXB	
  
–  Inspired	
  by	
  exisPng	
  popular	
  frameworks	
  
•  Goals	
  
–  JSON	
  
–  RunPme	
  API	
  
–  Object	
  mapping	
  (Default	
  |	
  Customizable)	
  
•  Non-­‐Goals	
  
–  JSON	
  Schema	
  Support	
  
–  Round-­‐trip	
  
–  Tool-­‐Pme	
  API	
  
JSR-­‐367	
  –	
  Java	
  API	
  for	
  JSON	
  Binding	
  
I	
  
	
  	
  
	
  
	
  
application/json	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
A	
  Road	
  to	
  Java	
  EE	
  Context	
  &	
  Dependency	
  InjecLon	
  
JAX-­‐RS	
  /	
  CDI	
  Alignment	
  
2006	
   2007	
   2008	
   2009	
   2010	
  
JSR-­‐311	
  (JAX-­‐RS)	
  
JSR-­‐330	
  (DI)	
  
JSR-­‐299	
  (CDI)	
  
Copyright	
  ©	
  2015,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
JAX-­‐RS	
  /	
  CDI	
  Alignment	
  
•  Hopeful	
  about	
  CDI	
  2.0	
  (JSR-­‐365)	
  
– Define	
  the	
  behavior	
  of	
  CDI	
  outside	
  of	
  a	
  Java	
  EE	
  container	
  
•  Also	
  involves	
  introducing	
  a	
  programmaPc	
  bootstrapping	
  API	
  
– Make	
  CDI	
  more	
  modular	
  to	
  help	
  other	
  Java	
  EE	
  specs	
  to	
  beler	
  integrate	
  with	
  it	
  
•  Main	
  Pain	
  Points	
  
– Constructor	
  selecPon	
  
– Generic	
  producers	
  
•  @PathParam(“quote”)	
  String	
  quote,	
  @PathParam(“quote”)	
  Quote	
  quote	
  
– Bootstrapping	
  &	
  running	
  outside	
  of	
  Java	
  EE	
  
– Focus	
  on	
  what’s	
  important	
  (Contexts	
  and	
  InjecPon)	
  
•  Need	
  to	
  reduce	
  the	
  footprint	
  dramaPcally	
  
Copyright	
  ©	
  2014,	
  Oracle	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
  	
  	
  
Q&A	
  

Contenu connexe

Tendances

Tendances (20)

Exachk and oem12c
Exachk and oem12cExachk and oem12c
Exachk and oem12c
 
MySQL Manchester TT - Replication Features
MySQL Manchester TT  - Replication FeaturesMySQL Manchester TT  - Replication Features
MySQL Manchester TT - Replication Features
 
AWR & ASH Analysis
AWR & ASH AnalysisAWR & ASH Analysis
AWR & ASH Analysis
 
2015 UJUG, Servlet 4.0 portion
2015 UJUG, Servlet 4.0 portion2015 UJUG, Servlet 4.0 portion
2015 UJUG, Servlet 4.0 portion
 
eProseed Oracle Open World 2016 debrief - Oracle Management Cloud
eProseed Oracle Open World 2016 debrief - Oracle Management CloudeProseed Oracle Open World 2016 debrief - Oracle Management Cloud
eProseed Oracle Open World 2016 debrief - Oracle Management Cloud
 
NoSQL no MySQL 5.7
NoSQL no MySQL 5.7NoSQL no MySQL 5.7
NoSQL no MySQL 5.7
 
Oracle REST Data Services Best Practices/ Overview
Oracle REST Data Services Best Practices/ OverviewOracle REST Data Services Best Practices/ Overview
Oracle REST Data Services Best Practices/ Overview
 
Openfest15 MySQL Plugin Development
Openfest15 MySQL Plugin DevelopmentOpenfest15 MySQL Plugin Development
Openfest15 MySQL Plugin Development
 
Hackingtomcat
HackingtomcatHackingtomcat
Hackingtomcat
 
Oracle Traffic Director - a vital part of your Oracle infrastructure
Oracle Traffic Director - a vital part of your Oracle infrastructureOracle Traffic Director - a vital part of your Oracle infrastructure
Oracle Traffic Director - a vital part of your Oracle infrastructure
 
Exachk and oem12c - IOUG C15LV
Exachk and oem12c - IOUG C15LVExachk and oem12c - IOUG C15LV
Exachk and oem12c - IOUG C15LV
 
Deploying to Oracle SOA Suite 12c - Everything You Need To Know
Deploying to Oracle SOA Suite 12c - Everything You Need To KnowDeploying to Oracle SOA Suite 12c - Everything You Need To Know
Deploying to Oracle SOA Suite 12c - Everything You Need To Know
 
OpenStack & MySQL
OpenStack & MySQLOpenStack & MySQL
OpenStack & MySQL
 
OUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQLOUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQL
 
Pimping SQL Developer and Data Modeler
Pimping SQL Developer and Data ModelerPimping SQL Developer and Data Modeler
Pimping SQL Developer and Data Modeler
 
Oracle Autonomous Health Service- For Protecting Your On-Premise Databases- F...
Oracle Autonomous Health Service- For Protecting Your On-Premise Databases- F...Oracle Autonomous Health Service- For Protecting Your On-Premise Databases- F...
Oracle Autonomous Health Service- For Protecting Your On-Premise Databases- F...
 
MySQL Intro JSON NoSQL
MySQL Intro JSON NoSQLMySQL Intro JSON NoSQL
MySQL Intro JSON NoSQL
 
Boost Your Content Strategy for REST APIs
Boost Your Content Strategy for REST APIsBoost Your Content Strategy for REST APIs
Boost Your Content Strategy for REST APIs
 
Whats new in oracle trace file analyzer 18.3.0
Whats new in oracle trace file analyzer 18.3.0Whats new in oracle trace file analyzer 18.3.0
Whats new in oracle trace file analyzer 18.3.0
 
MySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt IntroMySQL Tech Tour 2015 - Alt Intro
MySQL Tech Tour 2015 - Alt Intro
 

Similaire à JAX-RS.next

Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
David Delabassee
 
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2
 

Similaire à JAX-RS.next (20)

Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c Developers
 
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
 
WebSockets in Enterprise Applications
WebSockets in Enterprise ApplicationsWebSockets in Enterprise Applications
WebSockets in Enterprise Applications
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
 
Java EE7 in action
Java EE7 in actionJava EE7 in action
Java EE7 in action
 
WebSockets - Realtime em Mundo Conectado
WebSockets - Realtime em Mundo ConectadoWebSockets - Realtime em Mundo Conectado
WebSockets - Realtime em Mundo Conectado
 
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
 
CON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To YouCON5898 What Servlet 4.0 Means To You
CON5898 What Servlet 4.0 Means To You
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
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
 
Progress application server for openedge best practices - PUG Baltic Annual C...
Progress application server for openedge best practices - PUG Baltic Annual C...Progress application server for openedge best practices - PUG Baltic Annual C...
Progress application server for openedge best practices - PUG Baltic Annual C...
 
REST Enabling your Oracle Database (2018 Update)
REST Enabling your Oracle Database (2018 Update)REST Enabling your Oracle Database (2018 Update)
REST Enabling your Oracle Database (2018 Update)
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected BusinessWSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
WSO2Con Asia 2014 - WSO2 AppDev Platform for the Connected Business
 
WSO2 AppDev platform
WSO2 AppDev platformWSO2 AppDev platform
WSO2 AppDev platform
 
Java EE7
Java EE7Java EE7
Java EE7
 
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EECON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Dernier (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

JAX-RS.next

  • 1. JAX-­‐RS.next   Michal  Gajdos   michal.gajdos@oracle.com     January,  2015   Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.      
  • 2. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Safe  Harbor  Statement   The  following  is  intended  to  outline  our  general  product  direcPon.  It  is  intended  for   informaPon  purposes  only,  and  may  not  be  incorporated  into  any  contract.  It  is  not  a   commitment  to  deliver  any  material,  code,  or  funcPonality,  and  should  not  be  relied  upon   in  making  purchasing  decisions.  The  development,  release,  and  Pming  of  any  features  or   funcPonality  described  for  Oracle’s  products  remains  at  the  sole  discrePon  of  Oracle.  
  • 3. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       •  Generic   –  Protocol-­‐independent   –  In  retrospect,  most  important  Java  EE   technology   •  But  brought  HTTP  to  Java  EE   •  Old-­‐school  Programming  Model   –  StaPc,  Interface-­‐driven   –  Singleton-­‐Scoped   –  Lot’s  of  distracPons  /  boilerplate   •  Laser-­‐focused  on  REST  Services   –  HTTP  Centric   •  method  matching,  content  negoPaPon,  …   –  Payload  format  independence   •  decoupled  from  business  logic   •  Modern  Programming  Model   –  Dynamic,  POJO-­‐based,  AnnotaPon-­‐driven   –  Request-­‐Scoped   –  No  distracPons  /  boilerplate   HTTP  in  Java  EE:  From  Servlet  to  JAX-­‐RS   Simplicity,  ProducPvity,  RESTful  Design  Servlet   JAX-­‐RS  
  • 4. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       public  class  MyServlet  extends  HttpServlet  {      protected  void  doGet(HttpServletRequest  req,  HttpServletResponse  res)  {                  if  (!acceptsTextPlain(req))  {                            res.sendError(406);  //  Not  Acceptable                            return;                  }                  if  (!isGreetingPath(req))  {                          res.sendError(404);  //  Not  Found                          return;                  }                  String  name  =  req.getParameter(“name”);                  if  (name  ==  null)  {  name  =  “Joe”;  }                  PrintWriter  pw  =  res.getWriter();                      pw.print(“Hi  “  +  name  +  “!”);                    pw.flush();          }          …  //  TODO:  acceptsTextPlain(…)  &  isGreetingPath(…)  implementations   }   @Path(“greeting”)   public  class  MyResource  {          @GET  @Produces(“text/plain”)          public  String  greet(@QueryParam(“name”)  @DefaultValue(“Joe”)  String  name)  {                  return  “Hi  “  +  name  +  “!”;          }   }   HTTP  in  Java  EE:  From  Servlet  to  JAX-­‐RS   Simplicity,  ProducPvity,  RESTful  Design  Servlet   JAX-­‐RS  
  • 5. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       EnPty   Providers   Server  API   Contexts  &   InjecPon   ExcepPon   Mappers   CDI  Support   EnPty   Providers   Server  API   Contexts  &   InjecPon   ExcepPon   Mappers   Zero-­‐XML   Deployment   EvoluPon  of  JAX-­‐RS  API   EnPty   Providers   Client  API   Zero-­‐XML   Deployment   ExcepPon   Hierarchy   Async   Support   Common   Config   CDI  Support  Server  API   Contexts  &   InjecPon   ExcepPon   Mappers   Filters  &   Interceptors   Hypermedia   Support   JAX-­‐RS  1.0   JAX-­‐RS  1.1   JAX-­‐RS  2.0  
  • 6. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       •  Performance   – ReacPve  Programming  Model   – Java  SE  8  Streams   – Non-­‐blocking  I/O   •  Java  EE  Alignment   – CDI  Alignment   – DeclaraPve  Security  Model   – MVC  1.0  &  JSONB  1.0  IntegraPon   •  Filling  the  Gaps   – Server-­‐Sent  Events   – Improved  Hypermedia  Support   •  ConPnued  EvoluPon   –  All  simple  problems  have  already  been  solved…   •  Targeted  to  Ship  with  Java  EE  8   JSR-­‐370  –  JAX-­‐RS.next  
  • 7. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Program  Agenda   Server-­‐Sent  Events   Non-­‐Blocking  I/O   DeclaraPve  Security   MVC  IntegraPon   CDI  Alignment,  JSON-­‐B,  …   1   2   3   4   5  
  • 8. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Server-­‐Sent  Events               •  Plain  old  HTTP   •  Seamless  reconnect  &  redelivery   •  HTML  5  standard  protocol   Ajax  Long-­‐Polling               •  Plain  old  HTTP   •  Manual  reconnect   •  Undefined  format   WebSocket               •  New  Protocol  (via  HTTP  upgrade)   •  Full-­‐duplex   •  HTML  5  standard  protocol   Ajax  Long-­‐Polling  vs.  Server-­‐Sent  Events  vs.  WebSocket   Time   Server   Client   Time   Server   Client   Time   Server   Client  
  • 9. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Why  Server-­‐Sent  Events?   •  Streaming  asynchronous  events  from  Server  to  Client     •  Fits  well  Ajax  Long-­‐Polling  Use  Cases   – Progress  for  long-­‐running  tasks     – Stream  of  real-­‐Pme  data  updates  (e.g.  Stock  Ticker,  Monitoring)   – Instant  server  state  change  noPficaPons  (e.g.  SysAdmin  Message  Push)   – Task  processing  distribuPon   – …   •  Part  of  HTML5  Standard  by  W3C     – Built-­‐in  support  in  all  modern  browsers   – Standard  event  message  format  
  • 10. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.             :  Comment  lines  start  with  a  ‘:’  prefix   :  Events  can  have  numeric  IDs…   id:  1234   :  …can  contain  reconnect  delay  instructions…   retry:  5000   :  …can  be  named…   event:  text-­‐message   :  …typically  contain  one  or  more  lines  of  event  payload  data.   data:  Hello,  this  is  a   data:  multi-­‐line  message.   :  Events  are  separated  from  each  other  by  a  blank  line.   <blank  line>     An  SSE  Event  Message  
  • 11. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Typical  HTTP  Request  /  Response  Flow   JAX-­‐RS   Resource   invoke()  GET  /resource  HTTP/1.1   HTTP/1.1  200  OK   <CR+LF>   data   data  
  • 12. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Asynchronous  HTTP  Request  /  Response  Flow   JAX-­‐RS   Resource   invoke()  GET  /resource  HTTP/1.1   resume(data)   HTTP/1.1  200  OK   <CR+LF>   data  
  • 13. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Server-­‐Sent  Events  Flow   JAX-­‐RS   Resource   invoke()  GET  /resource  HTTP/1.1   write(event)   write(event)   …   event   event   …   [event]  HTTP/1.1  200  OK   <CR+LF>   [event]   close()  
  • 14. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Producer  API  –  Server  side   OutboundEvent     –  single  event;  outgoing   EventOutput   –  single  client  connecPon;  outbound   SseBroadcaster   –  connecPon  aggregaPon   –  BroadcasterListener   •  broadcast  noPficaPon   Consumer  API  –  Client  side   InboundEvent   –  single  event;  incoming   EventInput   –  streaming  connecPon;  inbound   EventSource   –  IoC  connecPon;  inbound   –  EventListener   •  asynchronous  event  processing   Jersey  Server-­‐Sent  Events  API  
  • 15. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       @Path(“messages”)   @Produces(APPLICATION_JSON)   public  class  MessageBoardResource  {            private  static  SseBroadcaster  broadcaster  =  new  SseBroadcaster();                    @GET  @Path(“stream”)          @Produces(SseFeature.SERVER_SENT_EVENTS)          public  EventOutput  connect()  {                    EventOutput  eventOutput  =  new  EventOutput();                  broadcaster.add(eventOutput);                  return  eventOutput;                    }            …   Server-­‐side  –  ConnecPng  to  an  Event  Source   Create  Outbound  ConnecPon   Store  Outbound  ConnecPon   Return  Outbound  ConnecPon   Create  Broadcaster  
  • 16. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Server-­‐Sent  Events  Flow   JAX-­‐RS   Resource   invoke()  GET  /resource  HTTP/1.1   HTTP/1.1  200  OK   <CR+LF>   [event]   eventOutput  
  • 17. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.              …                  @POST            @Consumes(MediaType.APPLICATION_JSON)          public  String  postMessage(Message  message)  {                    OutboundEvent  event  =  new  OutboundEvent.Builder()                                  .id(getNextId())                                  .mediaType(MediaType.APPLICATION_JSON_TYPE)                                  .data(Message.class,  message)                                  .build();                                      broadcaster.broadcast(event);  //  invokes  eventOutput.write(event);                    return  “Message  posted!”          }   }   Server-­‐side  –  Dispatching  Events   Create  Outbound  Event   Send  Outbound  Event  
  • 18. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Server-­‐Sent  Events  Flow   JAX-­‐RS   Resource   invoke()  GET  /resource  HTTP/1.1   HTTP/1.1  200  OK   eventOutput   write(event)   write(event)   …  event   event   …   close()  
  • 19. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       EventSource  eventSource  =            new  EventSource(target.path(“messages/stream”))  {                    @Override                    public  void  onEvent(InboundEvent  event)  {                            String  name  =  event.getName();                          Message  message  =  event.readData(Message.class);                            display(name,  message);                    }            };     …     eventSource.close();     Client-­‐side  Event  Processing  –  IoC  Model   Create  Event  Source   Close  Event  Source   Implement  Event  Callback   Process  Inbound  Event  
  • 20. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       EventInput  events  =  target.path(“messages/stream”)                                                      .request().get(EventInput.class);     while  (!stop)  {            InboundEvent  event  =  events.read();          String  name  =  event.getName();          Message  message  =  event.readData(Message.class);                    display(name,  message);     }     events.close();   Client-­‐side  Event  Processing  –  Pull  Model   Retrieve  Event  Stream   Close  Event  Source   Implement  Event  Loop   Process  Inbound  Event  
  • 21. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Program  Agenda   Server-­‐Sent  Events   Non-­‐Blocking  I/O   DeclaraPve  Security   MVC  IntegraPon   CDI  Alignment,  JSON-­‐B,  …   1   2   3   4   5  
  • 22. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Servlet  3.1  Non-­‐Blocking  I/O  API   •  Receiving  data   – ServletInputStream   •  isReady(),  isFinished(),  setReadListener(ReadListener)   – ReadListener   •  onDataAvailable(),  onError(Throwable),  onAllDataRead()   •  Sending  data   – ServletOutputStream   •  isReady(),  setWriteListener(WriteListener)   – WriteListener   •  onWritePossible(),  onError(Throwable)  
  • 23. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Non-­‐Blocking  I/O  API  in  JAX-­‐RS   •  Main  Constraints  and  Goals   – Backward-­‐compaPbility   – Alignment  with  Servlet  3.1  Non-­‐Blocking  I/O  API   •  At  least  conceptually   – Support  for  standalone  JAX-­‐RS  deployments   •  no  hard  dependency  on  Servlet  API   •  Problems  to  solve   – Unclear  impact  on  request/response  processing  chain   – MulPple  extension  points  to  cover  (in  a  backward-­‐compaPble  way)   •  Filters,  Interceptors,  EnPty  Providers,  ExcepPon  Mappers,  Parameter  Converters   •  PotenPal  interoperability  issues  in  mixed  models   –  e.g.  blocking  and  non-­‐blocking  request  filter  in  the  same  processing  chain  
  • 24. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Program  Agenda   Server-­‐Sent  Events   Non-­‐Blocking  I/O   DeclaraPve  Security   MVC  IntegraPon   CDI  Alignment,  JSON-­‐B,  …   1   2   3   4   5  
  • 25. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Securing  Resources  in  JAX-­‐RS   •  New  Security  JSR  planned  for  Java  EE  8   – Focused  on  unificaPon,  ease  of  use  and  portability  improvements   – JAX-­‐RS  EG  will  monitor  progress  of  this  JSR   •  OAuth  2.0  gaining  a  lot  of  adopPon  from  many  big  players   – Google,  Facebook,  Twiler,  …   •  Vision  for  REST  Services  Security  Model  in  Java  EE   – Easy  and  Straighmorward   – DeclaraPve  whenever  possible   •  Java  EE  Security  AnnotaPons  fit  JAX-­‐RS  very  well   •  Jersey  already  provides  annotaPon-­‐based  authorizaPon  
  • 26. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       ExisPng  Jersey  Security  Features   •  Leveraging  standard  JAX-­‐RS  extension  points   •  Off-­‐the-­‐shelf  modules  &  components  ready  to  use   •  Client-­‐side   – HTTP  Basic  &  Digest  AuthenPcaPon  Support   •  Server-­‐side   – DeclaraPve  Role-­‐base  AuthorizaPon  (javax.annotation.security)   •  @RolesAllowed,  @PermitAll,  @DenyAll     •  OAuth  1.0,  2.0  Support   – Client  and  Server  Side  
  • 27. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.         @Path(“messages”)   @Produces(APPLICATION_JSON)   @DenyAll   public  class  MessageBoardResource  {          …                    @GET  @Path(“stream”)          @Produces(SseFeature.SERVER_SENT_EVENTS)                  @PermitAll          public  EventOutput  connect()  {  …  }            @POST            @Consumes(MediaType.APPLICATION_JSON)          @RolesAllowed(“publisher”)          public  String  postMessage(Message  message)  {  …  }   }   AuthorizaPon  in  Jersey   No  access  by  default   Only  “publisher”  role   Public  access  
  • 28. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Program  Agenda   Server-­‐Sent  Events   Non-­‐Blocking  I/O   DeclaraPve  Security   MVC  IntegraPon   CDI  Alignment,  JSON-­‐B,  …   1   2   3   4   5  
  • 29. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Different  Tastes  of  MVC  Frameworks   UI  Component-­‐Oriented   Browser   Framework   ApplicaPon   Controller   Renderer   Views   Models   EL   EL   EL   EL   AcLon-­‐Oriented   Browser   Framework   ApplicaPon   Dispatcher   Controllers   Templates   AcPons  
  • 30. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       •  New,  dedicated  JSR  371  –  MVC  1.0     –  Focus  on  acPon-­‐oriented  Framework   –  Leverage  exisPng  templaPng  engines  (JSP,  Facelets)   –  Integrate  with  JAX-­‐RS   •  Model   –  Context,  InjecPon  and  Bean  ValidaPon  support   –  CDI  Beans   •  View   –  Format  content  based  on  Model  data   –  Templates  (JSP,  Facelets,  FreeMarker,  Mustache,  …)   •  Controller   –  Dispatch  model  data  to  View  templates   –  JAX-­‐RS  Resources   •  NaPve  content-­‐negoPaPon  support   MVC   Model   CDI  Beans   View   Templates   Controller   JAX-­‐RS  Resources   MVC  and  JAX-­‐RS  
  • 31. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       •  Jersey  extension  modules   – org.glassfish.jersey.ext   •  Core  Module  (jersey-­‐mvc)   – View  Templates   •  Producing  Human-­‐Readable  Content   •  Convenient  Generators  for  new  Media  Types   •  IntegraPon  Modules   – TemplaPng  Engines   •  JSP,  FreeMarker,  Moustache   – BeanValidaPon  &  Error  ReporPng   •  MinimalisPc  Public  APIs   – ProgrammaPc   •  Viewable   – DeclaraPve   •  @Template   •  @ErrorTemplate   Jersey  MVC  Support  
  • 32. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.           @Path(“motorcycle/{name}”)   public  class  MotorcycleResource  {                    @Inject  @NotNull  Catalog<Motorcycle>  catalog;            @GET  @Produces(TEXT_HTML)          @Template(name=“motorcycle.jsp”)          public  Motorcycle  getHtml(@PathParam(“name”)  String  name)  {                  return  catalog.getModel(name);          }            @Path(“parts”)          public  PartsListResource  getParts(@PathParam(“name”)  String  name)  {                  return  new  PartsListResource(catalog,  name);          }   }   Jersey  MVC  Templates   Model   Controller   View   Sub-­‐controller  
  • 33. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       public  class  PartsListResource  {            private  final  String  name;          private  final  Catalog  catalog;          …          @POST  @Consumes(APPLICATION_JSON)          public  String  addPartJson(Part  part)  {                  catalog.getModel(name).addPart(part);                  return  “Part  added.”;          }            @POST  @Consumes(APPLICATION_FORM_URLENCODED)          @Template(name=“confirmation.jsp”)          public  String  addPartForm(@BeanParam  PartFormBean  bean)  {                  catalog.getModel(name).addPart(bean.toPart());                  return  “Part  added.”;          }   }   Jersey  MVC  Templates  (contd.)   Non-­‐browser   Clients   Browser  Clients   View   Sub-­‐Controller  
  • 34. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Program  Agenda   Server-­‐Sent  Events   Non-­‐Blocking  I/O   DeclaraPve  Security   MVC  IntegraPon   CDI  Alignment,  JSON-­‐B,  …   1   2   3   4   5  
  • 35. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       •  API  with  a  Feel  Similar  to  JAXB   –  Inspired  by  exisPng  popular  frameworks   •  Goals   –  JSON   –  RunPme  API   –  Object  mapping  (Default  |  Customizable)   •  Non-­‐Goals   –  JSON  Schema  Support   –  Round-­‐trip   –  Tool-­‐Pme  API   JSR-­‐367  –  Java  API  for  JSON  Binding   I           application/json  
  • 36. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       A  Road  to  Java  EE  Context  &  Dependency  InjecLon   JAX-­‐RS  /  CDI  Alignment   2006   2007   2008   2009   2010   JSR-­‐311  (JAX-­‐RS)   JSR-­‐330  (DI)   JSR-­‐299  (CDI)  
  • 37. Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.       JAX-­‐RS  /  CDI  Alignment   •  Hopeful  about  CDI  2.0  (JSR-­‐365)   – Define  the  behavior  of  CDI  outside  of  a  Java  EE  container   •  Also  involves  introducing  a  programmaPc  bootstrapping  API   – Make  CDI  more  modular  to  help  other  Java  EE  specs  to  beler  integrate  with  it   •  Main  Pain  Points   – Constructor  selecPon   – Generic  producers   •  @PathParam(“quote”)  String  quote,  @PathParam(“quote”)  Quote  quote   – Bootstrapping  &  running  outside  of  Java  EE   – Focus  on  what’s  important  (Contexts  and  InjecPon)   •  Need  to  reduce  the  footprint  dramaPcally  
  • 38. Copyright  ©  2014,  Oracle  and/or  its  affiliates.  All  rights  reserved.       Q&A