jsr 315 – servlet spec 3.0
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 PresentationTRANSCRIPT
![Page 1: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/1.jpg)
JSR 315 – Servlet Spec 3.0Damodar Chetty
Software Engineering Solutions, Inc.www.swengsol.com
![Page 2: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/5.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/6.jpg)
Programmatic Definition
Create and configureServlets, Filters, and Listeners
Useful to frameworks Demo
MyServletContextListener, MyProgrammaticFilter, MyProgrammaticServlet
![Page 7: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/7.jpg)
Pluggability
Frameworks can plug-in to your applicationConfiguration Resources
Container assembles all fragments Demo
jSwengsol.jar
![Page 8: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/8.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/10.jpg)
Async Servlets – After JSR315 The Asynchronous Web
Solves Thread StarvationSolves StalenessSolves Non Standard Solutions
![Page 11: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/11.jpg)
Async Servlets – Ingredients
Thread Pool and Queue AsyncContext Runnable instance Servlet/Filter chain
![Page 12: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/12.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/13.jpg)
State Transition Diagram
![Page 14: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/14.jpg)
Async Servlets – Demo
AsyncServlet, AsyncRequestProcessor, MyAsyncListener
![Page 15: JSR 315 – Servlet Spec 3.0](https://reader036.vdocuments.net/reader036/viewer/2022081514/56812de9550346895d9345fe/html5/thumbnails/15.jpg)
Thank You!
[email protected]@softwareengineeringsolutions.com
www.swengsol.com
651 270 8457
Contact information for training/consultation: