- Docker and Kubernetes for Java Developers
- Jaroslaw Krochmalski
- 353字
- 2021-07-02 18:44:57
Java EE7 - JAX-RS with Jersey
JAX-RS was born as a result of Java Specification Request (JSR) 311. As the official definition says, the JAX-RS is the Java API for RESTful web services. It's a specification that provides support in creating web services according to the REST architectural pattern. JAX-RS uses Java annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints. From version 1.1 on, JAX-RS is an official part of Java EE. A notable feature of being an official part of Java EE is that no configuration is necessary to start using JAX-RS.
Java EE 7 with JAX-RS 2.0 brings several useful features, which further simplify the development of microservices. One of the most important new features of JAX-RS 2.0 is the support for hypermedia following the HATEOAS principle of REST. Jersey, a library from Oracle, is probably the most widely known library, which implements this specification.
The Jersey implementation provides a library to implement RESTful web services in a Java servlet container. On the server-side, Jersey provides a servlet implementation which scans predefined classes to identify RESTful resources. Jersey makes it a lot easier to write RESTful services. It abstracts away a lot of the low level coding you will need to do yourself otherwise. Using Jersey, you do it in a declarative way. The servlet, registered in your web.xml file, analyzes the incoming HTTP request and selects the correct class and method to respond to this request. It finds the proper method to execute by looking at the class and method level annotations. Annotated classes can reside in different packages, but you can instruct a Jersey servlet via the web.xml to scan certain packages for annotated classes.
JAX-RS supports the creation of XML and JSON via the Java Architecture for XML Binding (JAXB). The Jersey implementation also provides a client library to communicate with a RESTful web service.
As we have said before, we develop JAX-RS applications using Java annotations. It's easy and pleasant to work with. Let's describe those annotations now.
- UI設(shè)計基礎(chǔ)培訓(xùn)教程
- Node.js Design Patterns
- 無代碼編程:用云表搭建企業(yè)數(shù)字化管理平臺
- Python機器學(xué)習(xí):手把手教你掌握150個精彩案例(微課視頻版)
- Learning Apache Mahout Classification
- PLC編程與調(diào)試技術(shù)(松下系列)
- Express Web Application Development
- Learning YARN
- Web前端應(yīng)用開發(fā)技術(shù)
- Java Web從入門到精通(第3版)
- Go語言從入門到精通
- Less Web Development Cookbook
- Elasticsearch搜索引擎構(gòu)建入門與實戰(zhàn)
- Processing開發(fā)實戰(zhàn)
- Visual FoxPro程序設(shè)計實驗教程