jsr 315 – servlet spec 3.0

15
JSR 315 – Servlet Spec 3.0 Damodar Chetty [email protected] Software Engineering Solutions, Inc. www.swengsol.com

Upload: april-fernandez

Post on 31-Dec-2015

37 views

Category:

Documents


0 download

DESCRIPTION

JSR 315 – Servlet Spec 3.0. Damodar Chetty [email protected] Software Engineering Solutions, Inc. www.swengsol.com. Introductions. Author, Coach, Architect Blogger at www.swengsol.com Two decades in software development Adjunct Faculty at Metro State University. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: JSR 315 – Servlet Spec 3.0

JSR 315 – Servlet Spec 3.0Damodar Chetty

[email protected]

Software Engineering Solutions, Inc.www.swengsol.com

Page 2: JSR 315 – Servlet Spec 3.0

Introductions

Author, Coach, Architect Blogger at www.swengsol.com Two decades in software development Adjunct Faculty at Metro State University

Page 3: JSR 315 – Servlet Spec 3.0

Java 6 - What’s New?

JSR 316 - umbrella specification Contains 28 specs.

Web Services (JAX-WS, JAX-RS, JAXB, …)Web (Servlet 3, JSF, JSP, JSTL, EL)Enterprise (EJB 3, JPA, JTA, …)Misc (Annotations, …)

Introduces Pruning and Profiles

Page 4: JSR 315 – Servlet Spec 3.0

Servlet 3.0: What’s on our menu? Asynchronous Servlets Enhanced Modularity Programmatic registration and

configuration of components Annotations Security (won’t discuss this tonight)

Page 5: JSR 315 – Servlet Spec 3.0

Annotation Processing web.xml is optional but overrides annotations Scans WEB-INF/classes and WEB-INF/lib/*.jar metadata-complete attribute Annotations for components

ServletsFiltersListeners

Ordering is unspecified Demo

MyFilter, HelloWorldServlet

Page 6: JSR 315 – Servlet Spec 3.0

Programmatic Definition

Create and configureServlets, Filters, and Listeners

Useful to frameworks Demo

MyServletContextListener, MyProgrammaticFilter, MyProgrammaticServlet

Page 7: JSR 315 – Servlet Spec 3.0

Pluggability

Frameworks can plug-in to your applicationConfiguration Resources

Container assembles all fragments Demo

jSwengsol.jar

Page 8: JSR 315 – Servlet Spec 3.0

Async Servlets – Prior to JSR315 The Synchronous Web

HTTP ConnectionsOne Server Thread Per ConnectionServer Thread Pool Mechanism

Page 9: JSR 315 – Servlet Spec 3.0

Async Servlets – The Problem Thread Starvation

Threads consume resourcesBlocking consumes threads

StalenessStatic snapshots into a dynamic systemAjax improves freshness, but does not solve.

Non standard solutionsTomcat’s Comet,

WebLogic’s Future Response servlet,WebSphere’s Asynchronous Request Dispatcher

Page 10: JSR 315 – Servlet Spec 3.0

Async Servlets – After JSR315 The Asynchronous Web

Solves Thread StarvationSolves StalenessSolves Non Standard Solutions

Page 11: JSR 315 – Servlet Spec 3.0

Async Servlets – Ingredients

Thread Pool and Queue AsyncContext Runnable instance Servlet/Filter chain

Page 12: JSR 315 – Servlet Spec 3.0

Async Servlets – The Recipe Context listener sets up an Executor Servlets/filters that will block are marked as asyncSupported. An async servlet:

invokes startAsync() on the request wraps the returned AsyncContext in a Runnable, hands the Runnable to an Executor for async processing. returns without the response being committed.

The main thread returns to the server’s pool ready to handle the next request. The Executor assigns an async thread to process the Runnable. The Runnable:

uses the request and response stored in its AsyncContext accesses request attributes/parameters as necessary. stores the result in the request. “completes” the response, by generating the response, or by dispatching to a server side

resource.

The client, which has been waiting patiently, now displays the response.

Page 13: JSR 315 – Servlet Spec 3.0

State Transition Diagram

Page 14: JSR 315 – Servlet Spec 3.0

Async Servlets – Demo

AsyncServlet, AsyncRequestProcessor, MyAsyncListener

Page 15: JSR 315 – Servlet Spec 3.0

Thank You!

[email protected]@softwareengineeringsolutions.com

www.swengsol.com

651 270 8457

Contact information for training/consultation: