JAX-RS: Java API For RESTful Web Services

2y ago
45 Views
3 Downloads
591.34 KB
96 Pages
Last View : 7d ago
Last Download : 3m ago
Upload by : Mika Lloyd
Transcription

JAX-RS: Java API for RESTfulWeb ServicesVersion 2.0 Final ReleaseMay 22, 2013Editors:Santiago Pericas-GeertsenMarek PotociarComments to: users@jax-rs-spec.java.netOracle Corporation500 Oracle Parkway, Redwood Shores, CA 94065 USA.

iiJAX-RSMay 22, 2013

JSR-339 Java API for RESTful Web Services (“Specification”)Version: 2.0Status: Final ReleaseRelease: May 22, 2013Copyright 2011-2013 Oracle America, Inc. (“Oracle”)500 Oracle Parkway, Redwood Shores, California 94065, U.S.AAll rights reserved.LIMITED LICENSE GRANTS1. License for Evaluation Purposes. Oracle hereby grants you a fully-paid, non-exclusive, non-transferable,worldwide, limited license (without the right to sublicense), under Oracle’s applicable intellectual property rights toview, download, use and reproduce the Specification only for the purpose of internal evaluation. This includes (i)developing applications intended to run on an implementation of the Specification, provided that such applications donot themselves implement any portion(s) of the Specification, and (ii) discussing the Specification with any thirdparty; and (iii) excerpting brief portions of the Specification in oral or written communications which discuss theSpecification provided that such excerpts do not in the aggregate constitute a significant portion of the Specification.2. License for the Distribution of Compliant Implementations. Oracle also grants you a perpetual, non-exclusive,non-transferable, worldwide, fully paid-up, royalty free, limited license (without the right to sublicense) under anyapplicable copyrights or, subject to the provisions of subsection 4 below, patent rights it may have covering theSpecification to create and/or distribute an Independent Implementation of the Specification that: (a) fully implementsthe Specification including all its required interfaces and functionality; (b) does not modify, subset, superset orotherwise extend the Licensor Name Space, or include any public or protected packages, classes, Java interfaces,fields or methods within the Licensor Name Space other than those required/authorized by the Specification orSpecifications being implemented; and (c) passes the Technology Compatibility Kit (including satisfying therequirements of the applicable TCK Users Guide) for such Specification (”Compliant Implementation”). In addition,the foregoing license is expressly conditioned on your not acting outside its scope. No license is granted hereunderfor any other purpose (including, for example, modifying the Specification, other than to the extent of your fair userights, or distributing the Specification to third parties). Also, no right, title, or interest in or to any trademarks,service marks, or trade names of Oracle or Oracle’s licensors is granted hereunder. Java, and Java-related logos,marks and names are trademarks or registered trademarks of Oracle America, Inc. in the U.S. and other countries.3. Pass-through Conditions. You need not include limitations (a)-(c) from the previous paragraph or any otherparticular ”pass through” requirements in any license You grant concerning the use of your IndependentImplementation or products derived from it. However, except with respect to Independent Implementations (andproducts derived from them) that satisfy limitations (a)-(c) from the previous paragraph, You may neither: (a) grantor otherwise pass through to your licensees any licenses under Oracles applicable intellectual property rights; nor (b)authorize your licensees to make any claims concerning their implementation’s compliance with the Specification inquestion.4. Reciprocity Concerning Patent Licenses.a. With respect to any patent claims covered by the license granted under subparagraph 2 above that would beinfringed by all technically feasible implementations of the Specification, such license is conditioned upon youroffering on fair, reasonable and non-discriminatory terms, to any party seeking it from You, a perpetual,non-exclusive, non-transferable, worldwide license under Your patent rights which are or would be infringed by alltechnically feasible implementations of the Specification to develop, distribute and use a Compliant Implementation.b. With respect to any patent claims owned by Oracle and covered by the license granted under subparagraph 2,whether or not their infringement can be avoided in a technically feasible manner when implementing theSpecification, such license shall terminate with respect to such claims if You initiate a claim against Oracle that it has,in the course of performing its responsibilities as the Specification Lead, induced any other entity to infringe Yourpatent rights.c. Also with respect to any patent claims owned by Oracle and covered by the license granted under subparagraph2 above, where the infringement of such claims can be avoided in a technically feasible manner when implementingthe Specification such license, with respect to such claims, shall terminate if You initiate a claim against Oracle thatits making, having made, using, offering to sell, selling or importing a Compliant Implementation infringes YourMay 22, 2013JAX-RSiii

patent rights.5. Definitions. For the purposes of this Agreement: ”Independent Implementation” shall mean an implementation ofthe Specification that neither derives from any of Oracle’s source code or binary code materials nor, except with anappropriate and separate license from Oracle, includes any of Oracle’s source code or binary code materials;”Licensor Name Space” shall mean the public class or interface declarations whose names begin with ”java”,”javax”, ”com.sun”, com.oracle or their equivalents in any subsequent naming convention adopted by Oracle throughthe Java Community Process, or any recognized successors or replacements thereof; and ”Technology CompatibilityKit” or ”TCK” shall mean the test suite and accompanying TCK User’s Guide provided by Oracle which correspondsto the Specification and that was available either (i) from Oracle 120 days before the first release of Your IndependentImplementation that allows its use for commercial purposes, or (ii) more recently than 120 days from such release butagainst which You elect to test Your implementation of the Specification.This Agreement will terminate immediately without notice from Oracle if you breach the Agreement or act outsidethe scope of the licenses granted above.DISCLAIMER OF WARRANTIESTHE SPECIFICATION IS PROVIDED ”AS IS”. ORACLE MAKES NO REPRESENTATIONS ORWARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT (INCLUDING ASA CONSEQUENCE OF ANY PRACTICE OR IMPLEMENTATION OF THE SPECIFICATION), OR THAT THECONTENTS OF THE SPECIFICATION ARE SUITABLE FOR ANY PURPOSE. This document does not representany commitment to release or implement any portion of the Specification in any product. In addition, theSpecification could include technical inaccuracies or typographical errors.LIMITATION OF LIABILITYTO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ORACLE OR ITS LICENSORS BELIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, LOST REVENUE, PROFITS ORDATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES,HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ORRELATED IN ANY WAY TO YOUR HAVING, IMPLEMENTING OR OTHERWISE USING THESPECIFICATION, EVEN IF ORACLE AND/OR ITS LICENSORS HAVE BEEN ADVISED OF THEPOSSIBILITY OF SUCH DAMAGES. You will indemnify, hold harmless, and defend Oracle and its licensors fromany claims arising or resulting from: (i) your use of the Specification; (ii) the use or distribution of your Javaapplication, applet and/or implementation; and/or (iii) any claims that later versions or releases of any Specificationfurnished to you are incompatible with the Specification provided to you under this license.RESTRICTED RIGHTS LEGENDU.S. Government: If this Specification is being acquired by or on behalf of the U.S. Government or by a U.S.Government prime contractor or subcontractor (at any tier), then the Government’s rights in the Software andaccompanying documentation shall be only as set forth in this license; this is in accordance with 48 C.F.R. 227.7201through 227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48 C.F.R. 2.101 and 12.212 (fornon-DoD acquisitions).REPORTIf you provide Oracle with any comments or suggestions concerning the Specification (”Feedback”), you hereby: (i)agree that such Feedback is provided on a non-proprietary and non-confidential basis, and (ii) grant Oracle aperpetual, non-exclusive, worldwide, fully paid-up, irrevocable license, with the right to sublicense through multiplelevels of sublicensees, to incorporate, disclose, and use without limitation the Feedback for any purpose.GENERAL TERMSAny action related to this Agreement will be governed by California law and controlling U.S. federal law. The U.N.Convention for the International Sale of Goods and the choice of law rules of any jurisdiction will not apply.The Specification is subject to U.S. export control laws and may be subject to export or import regulations in othercountries. Licensee agrees to comply strictly with all such laws and regulations and acknowledges that it has theresponsibility to obtain such licenses to export, re-export or import as may be required after delivery to Licensee.ivJAX-RSMay 22, 2013

This Agreement is the parties’ entire agreement relating to its subject matter. It supersedes all prior orcontemporaneous oral or written communications, proposals, conditions, representations and warranties and prevailsover any conflicting or additional terms of any quote, order, acknowledgment, or other communication between theparties relating to its subject matter during the term of this Agreement. No modification to this Agreement will bebinding, unless in writing and signed by an authorized representative of each party.Rev. December, 2010May 22, 2013JAX-RSv

viJAX-RSMay 22, 2013

Contents123Introduction11.1Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11.2Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21.3Non-Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21.4Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21.5Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31.6Expert Group Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41.7Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5Applications72.1Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72.2Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72.3Publication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72.3.1Java SE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72.3.2Servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82.3.3Other Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Resources113.1Resource Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.1Lifecycle and Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.2Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2Fields and Bean Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.3Resource Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.1Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.2Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.3Return Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3.4Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14May 22, 2013JAX-RSvii

3.3.53.4URI Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.4.1Declaring Media Type Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.6Annotation Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.7Matching Requests to Resource Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.7.1Request Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.7.2Request Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.7.3Converting URI Templates to Regular Expressions . . . . . . . . . . . . . . . . . . 24Determining the MediaType of Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Providers4.14.24.3viii27Lifecycle and Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.1.1Automatic Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.1.2Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Entity Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.2.1Message Body Reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.2.2Message Body Writer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.2.3Declaring Media Type Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2.4Standard Entity Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2.5Transfer Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.2.6Content Encoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Context Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.3.15Sub Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.53.84HEAD and OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Declaring Media Type Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . 314.4Exception Mapping Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.5Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.5.1Server Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.5.2Client Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Client API335.1Bootstrapping a Client Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.2Resource Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.3Client Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.4Typed Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.5Invocations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35JAX-RSMay 22, 2013

5.6Configurable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.6.1678Filters and Interceptors376.1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376.2Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386.3Entity Interceptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396.4Lifecycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406.5Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416.5.1Global Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416.5.2Name Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416.5.3Dynamic Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426.5.4Binding in Client API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.6Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.7Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446.7.1Server Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446.7.2Client Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Validation457.1Constraint Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457.2Annotations and Validators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477.3Entity Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477.4Default Validation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497.5Annotation Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497.6Validation and Error Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Asynchronous Processing518.1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518.2Server API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518.2.19Filters and Entity Interceptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Timeouts and Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528.3EJB Resource Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538.4Client API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Context559.1Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559.2Context Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55May 22, 2013JAX-RSix

9.2.1Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559.2.2URIs and URI Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559.2.3Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569.2.4Content Negotiation and Preconditions . . . . . . . . . . . . . . . . . . . . . . . . 569.2.5Security Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579.2.6Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579.2.7Resource Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579.2.8Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5810 Environment5910.1 Servlet Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5910.2 Integration with Java EE Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5910.2.1 Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6010.2.2 Managed Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6010.2.3 Context and Dependency Injection (CDI) . . . . . . . . . . . . . . . . . . . . . . . 6010.2.4 Enterprise Java Beans (EJBs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6110.2.5 Bean Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.2.6 Java API for JSON Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210.2.7 Additional Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6210

May 22, 2013 · JAX-RS: Java API for RESTful Web Services Version 2.0 Final Release May 22, 2013 Editors: Santiago Pericas-Geertsen Marek Potociar Comments to: users@jax-rs-spec.java.net Oracle Corp

Related Documents:

java.io Input and output java.lang Language support java.math Arbitrary-precision numbers java.net Networking java.nio "New" (memory-mapped) I/O java.rmi Remote method invocations java.security Security support java.sql Database support java.text Internationalized formatting of text and numbers java.time Dates, time, duration, time zones, etc.

REST Web Services JAX-RS JAX-RS is an API for RESTful Web Services. JAX-RS contains Interfaces, therefore, to build an App we need actual implementation of them. There are many implementation libraries of the API (e.g. Rest Jersey, Restlet, RESTEasy, etc.). REST API Application App code Jersey JAX-RS Interface annotation Implementation classes

Jax Spine & Pain Centers, I understand that this payment belongs to . Jax Spine & Pain Centers. I agree to endorse the back of the check payable to . Jax Spine & Pain Centers. and promptly deliver the check to . Jax Spine & Pain Centers. I permit a copy of this assignment to be used in place of the original. Caution: Please read carefully .

Java Version Java FAQs 2. Java Version 2.1 Used Java Version This is how you find your Java version: Start the Control Panel Java General About. 2.2 Checking Java Version Check Java version on https://www.java.com/de/download/installed.jsp. 2.3 Switching on Java Console Start Control Panel Java Advanced. The following window appears:

programmer only deals with the Java filesystem API. The virtual machine then handles translating between this “virtual” API to the true operating system API (see diagram B-2). What is Java? Part 3: Java Applets and Java Web Start Beyond the language, compiler, virtual machine and API, Java has a number of ancillary technolo-gies that .

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

api 20 e rapid 20e api 20 ne api campy api nh api staph api 20 strep api coryne api listeriaapi 20 c aux api 20 a rapid id 32 a api 50 ch api 50 chb/e 50 chl reagents to be ordered. strips ref microorganisms suspension inoculum transfer medium i

Scrum, Agile Software Development. with Ken Schwaber (Prentice Hall, fall 2001), a provocative book that assumes software development is more like . new product development. than the manufacturing-like processes that the software industry has used for the last 20 years. Arie van Bennekum. has been actively involved in DSDM and the DSDM Consortium since 1997. Before that he had been working .