servlet 4.0 adopt-a-jsr 10 minute infodeck
Post on 12-Jul-2015
235 Views
Preview:
TRANSCRIPT
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Adopt-a-JSR: JSR-369Servlet 4.0
Ed Burns and Dr. Shing-Wai ChanSpec Leads for ServletJava EE Specification TeamDecember, 2014
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
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 © 2015, Oracle and/or its affiliates. All rights reserved. |
• Ed Burns
– Oracle
• Long time user of Servlet technology• Co-spec lead of JSF since 2004
Speaker Credentials
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Ed Burns
– Oracle
• Long time user of Servlet technology• Co-spec lead of JSF since 2004
Speaker Credentials
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Dr. Shing Wai Chan
– Oracle
• Servlet Spec Lead since 2013• Expert group member on many JSRs
relating to Servlet since 2001
Speaker Credentials
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
HTTP2 Big Features
How Servlet Might Expose These Features
Adopt-a-JSR
1
2
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
HTTP2 Big Features
How Servlet Might Expose These Features
Adopt-a-JSR
1
2
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Request/Response multiplexing
• Binary Framing
• Stream Prioritization
• Server Push
• Header Compression
• Upgrade from HTTP 1.1• ALPN (or NPN)
• 101 Switching Protocols
8
HTTP/2 Big Ticket Feature Review
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2 Server Push
• Eliminates the need for resource inlining.
• Lets the server populate the browser’s cache in advance of the browser asking for the resource to put in the cache.
• No corresponding JavaScript API, but can be combined with SSE
– Server pushes stuff into the browser’s cache.
– Server uses SSE to tell the browser to go fetch it (but we know it’s already in the browser’s cache).
9E
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2 Request Response Multiplexing
• Fully bi-directional
• Enabled by defining some terms
– ConnectionA TCP socket
– StreamA “channel” within a connection
–MessageA logical message, such as a request or a response
– FrameThe smallest unit of communication in HTTP/2.
10
Lets you do more things with a single TCP connection
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2 Request Response Multiplexing
11
Connections, Streams, Messages, Frames
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2 Request Response Multiplexing
• Once you break the communication down into frames, you can interweave the logical streams over a single TCP connection.
• Yet another idea from the 1960s is new again.
12
Connections, Streams, Messages, Frames
BrowserServerSingle TCP connection for HTTP 2
STREAM'4'HEADERS'
STREAM'9'HEADERS'
STREAM'7'DATA'
STREAM'7'HEADERS'
STREAM'2'HEADERS'
STREAM'2'DATA'
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
HTTP/2 Binary Framing
• Solves Head-Of-Line (HOL) blocking problem
• Type field can be DATA, HEADERS, PRIORITY, RST_STREAM, SETTINGS, PUSH_PROMISE, PING, GOAWAY, WINDOW_UPDATE, CONTINUATION
13
Enabled by dumping newline delimited ASCII
Length (24)
Type (8) Flags (8)
R Stream Identifier (31)
Frame Payload (0 …)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
HTTP2 Big Features
How Servlet Might Expose These Features
Adopt-a-JSR
1
2
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Request/Response multiplexing
• Binary Framing
• Stream Prioritization
• Server Push
• Header Compression
• Upgrade from HTTP 1.1
– ALPN or (NPN)
– 101 Switching Protocols
15
HTTP/2 Features
Servlet 4.0 Big Ticket New Features
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Request/Response multiplexing
• Binary Framing
• Stream Prioritization
• Server Push
• Header Compression
• Upgrade from HTTP 1.1
– ALPN or (NPN)
– 101 Switching Protocols
16
HTTP/2 Features Potentially Exposed in Servlet API
Servlet 4.0 Big Ticket New Features
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Push resource to client for a given url and headers
• May add callback for completion or error of a push
• Not at all a replacement for WebSocket
• Really useful for frameworks that build on Servlet, such as JSF
17
Server Push
Servlet 4.0 Big Ticket New Features
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 18
Server Push
Servlet 4.0Big TicketNew Features
BrowserServer Thread Aservlet.service()
GET /index.html
Server discovers
browser will need style.css and script.js
request.dispatchPushRequest("style.css")
request.dispatchPushRequest("script.js")
Server Thread Bservlet.service()
synthetic GET /style.css
synthetic GET /script.js
Server Thread Cservlet.service()
style.css
script.js
index.html
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Server Push
public class FacesServlet implements Servlet {public void service(ServletRequest req,
ServletResponse resp) throws IOException, ServletException {//..HttpServletRequest request = (HttpServletRequest) req;try {
ResourceHandler handler =context.getApplication().getResourceHandler();
if (handler.isResourceRequest(context) || request.isPushRequest()) {handler.handleResourceRequest(context);
} else {lifecycle.attachWindow(context);lifecycle.execute(context);lifecycle.render(context);
}}
}
Example of Potential Use from JSF
19
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Server Push
public class ExternalContextImpl extends ExternalContext {//…public String encodeResourceURL(String url) {
if (null == url) {String message = MessageUtils.getExceptionMessageString
(MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "url");throw new NullPointerException(message);
}Map attrs = getResourceAttrs();((HttpServletRequest) request).dispatchPushRequest(url, attrs);return ((HttpServletResponse) response).encodeURL(url);
}//…
}
Example of Potential Use from JSF
20
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
HTTP2 Big Features
How Servlet Might Expose These Features
Adopt-a-JSR
1
2
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Adopt-a-JSR
• Community Tab on JSR-369 page https://jcp.org/en/egc/view?id=369
– JIRA Components: currently we have none. Come up with a list of components for us!
– Use-cases for session-less applications
– List of references to async and thread safety in the spec and javadoc
– You can think of others!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The preceding 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.
top related