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
JSR 315 – Servlet Spec 3.0Damodar Chetty
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
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
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)
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
Programmatic Definition
Create and configureServlets, Filters, and Listeners
Useful to frameworks Demo
MyServletContextListener, MyProgrammaticFilter, MyProgrammaticServlet
Pluggability
Frameworks can plug-in to your applicationConfiguration Resources
Container assembles all fragments Demo
jSwengsol.jar
Async Servlets – Prior to JSR315 The Synchronous Web
HTTP ConnectionsOne Server Thread Per ConnectionServer Thread Pool Mechanism
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
Async Servlets – After JSR315 The Asynchronous Web
Solves Thread StarvationSolves StalenessSolves Non Standard Solutions
Async Servlets – Ingredients
Thread Pool and Queue AsyncContext Runnable instance Servlet/Filter chain
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.
State Transition Diagram
Async Servlets – Demo
AsyncServlet, AsyncRequestProcessor, MyAsyncListener
Thank You!
[email protected]@softwareengineeringsolutions.com
www.swengsol.com
651 270 8457
Contact information for training/consultation: