Jersey (1.19.1)-life-cycle of Root Resource Classes

Source: Internet
Author: User

by Default the life-cycle of root resource classes are per-request, namely that a new instance of a root resource Class is created every time the request URI path matches the root resource. This makes for a very natural programming model where constructors and fields can is utilized (as in the previous section Showing the constructor of the SparklinesResource class) without concern for multiple concurrent requests to the same resource.

In the unlikely to be a cause of performance issues. Class Construction and garbage collection of JVMs have vastly improved over the years and many objects would be created and Discarded to serve and process the HTTP request and return the HTTP response.

Instances of Singleton root resource classes can be declared by an instance of application.

Jersey supports-further life-cycles using Jersey specific annotations. If a root resource class is annotated with @Singleton then only one instance is created Per-web application. If a root resource class is annotated with @PerSession then one instance is created per Web session and stored as A session attribute.

Jersey (1.19.1)-life-cycle of Root Resource Classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.