Jsr 315 servlet spec 3 0
Download
1 / 15

JSR 315 – Servlet Spec 3.0 - PowerPoint PPT Presentation


  • 65 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' JSR 315 – Servlet Spec 3.0' - april-fernandez


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Jsr 315 servlet spec 3 0
JSR 315 – Servlet Spec 3.0

Damodar [email protected]

Software Engineering Solutions, Inc.www.swengsol.com


Introductions
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
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

JAX-RPC, JAXR, EJB 2 CMP

Web Profile 1.0 :

Web, EJB Lite, JPA, JTA, Annotations


Servlet 3 0 what s on our menu
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
Annotation Processing

  • web.xml is optional but overrides annotations

  • Scans WEB-INF/classes and WEB-INF/lib/*.jar

  • metadata-complete attribute

  • Annotations for components

    • Servlets

    • Filters

    • Listeners

  • Ordering is unspecified

  • Demo MyFilter, HelloWorldServlet

@WebServlet(name=“fooServlet”,

urlPatterns={“/foo”, “/bar”}

asyncSupported = false)

@WebFilter(urlPatterns={“/foo”, “/bar”} servletNames={“fooServlet”})

@WebListener


Programmatic definition
Programmatic Definition

  • Create and configureServlets, Filters, and Listeners

  • Useful to frameworks

  • DemoMyServletContextListener, MyProgrammaticFilter, MyProgrammaticServlet


Pluggability
Pluggability

  • Frameworks can plug-in to your application

    • Configuration

    • Resources

  • Container assembles all fragments

  • DemojSwengsol.jar

META-INF/web-fragment.xml

lets frameworks augment your web.xml

META-INF/resources

frameworks can serve up static and dynamic resources

from your application’s WEB-INF!

Supports relative or absolute ordering


Async servlets prior to jsr315
Async Servlets – Prior to JSR315

  • The Synchronous Web

    • HTTP Connections

    • One Server Thread Per Connection

    • Server Thread Pool Mechanism

HTTP 1.0 and HTTP 1.1 differences

Connector / Acceptor / Processor


Async servlets the problem
Async Servlets – The Problem

  • Thread Starvation

    • Threads consume resources

    • Blocking consumes threads

  • Staleness

    • Static snapshots into a dynamic system

    • Ajax improves freshness, but does not solve.

  • Non standard solutions

    • Tomcat’s Comet, WebLogic’s Future Response servlet,WebSphere’s Asynchronous Request Dispatcher


Async servlets after jsr315
Async Servlets – After JSR315

  • The Asynchronous Web

    • Solves Thread Starvation

    • Solves Staleness

    • Solves Non Standard Solutions

Processor thread delegates to async thread

and returns to processing connections

Client can make preemptive requests.

The one true way


Async servlets ingredients
Async Servlets – Ingredients

  • Thread Pool and Queue

  • AsyncContext

  • Runnable instance

  • Servlet/Filter chain

Executor & ExecutorService

Asynchronous Execution Context

wraps the request and response

Encapsulates the processing of the blocking request

All components in the processing chain must be marked as supporting asynchronous requests


Async servlets the recipe
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
State Transition Diagram

Synchronous

servlet

Async

dispatch

Async

complete


Async servlets demo
Async Servlets – Demo

  • AsyncServlet, AsyncRequestProcessor, MyAsyncListener


Thank you
Thank You!

Contact information for training/consultation:


ad