Restful Java with JAX-RS

Restful Java with JAX-RS

RESTful java with JAX-RS HOM,DOS,SBK Intro Motivation RESTful java with JAX-RS Sockets and socket exercise reviewed API’s everywhere. Tooling API console Tooling Netbeans Tooling curl Pieter van den Hombergh Tooling curl Thijs Dorssers Basic understanding Stefan Sobek Uniform constrained interface JAX-RS Fontys Hogeschool voor Techniek en Logistiek JAX-RS Service April 12, 2018 Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 1/27 RESTful java with Topics JAX-RS HOM,DOS,SBK Motivation Intro Look back at the client-server socket example Motivation Sockets and socket exercise API’s everywhere. reviewed API’s everywhere. Tooling Tooling API console Basics Tooling Netbeans Tooling curl Example Tooling curl Basic Exercise understanding Uniform constrained interface JAX-RS JAX-RS Service Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 2/27 RESTful java with Motivation JAX-RS HOM,DOS,SBK To build distributed services. Intro To use the web to realize access to data sources. Motivation Sockets and socket exercise Divide and conquer simplifies complex systems. reviewed API’s everywhere. Tooling API console Replaces complex solutions like SOAP, CORBA and Java RMI. Tooling Netbeans Tooling curl It is a modern protocol that is used in contemporary websites and in Tooling curl communication between apps and servers. Basic understanding Uniform constrained interface JAX-RS JAX-RS Service Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 3/27 RESTful java with Sockets reviewed JAX-RS HOM,DOS,SBK Server and client are applications which both own a socket. Intro Motivation Sockets and socket exercise 1 ServerSocket Socket reviewed 2 API’s everywhere. Connection request Tooling API console P Listen P Tooling Netbeans O O Tooling curl Server Client R R Tooling curl T T Basic understanding 3 Accept… Uniform constrained interface JAX-RS Listen P 4 P JAX-RS O O Server Client Service R R Service T T Protocol Socket Be Lazy, Not Slow Enabling postgres in payara Exercise Simple RESTapi like protocol: More on PostgreSQL Exercise https://java2.fontysvenlo.org/pdf/simplerestapiprotocol.pdf Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 4/27 RESTful java with Some nice applications of RESTful api’s in the evil outside world. JAX-RS HOM,DOS,SBK Youtube video Published on Jul 14, 2014. This video introduces the viewer to some API concepts by making example calls Intro Motivation to Facebook’s Graph API, Google Maps’ API, Instagram’s Media Search API, Sockets and socket exercise reviewed and Twitter’s Status Update API. API’s everywhere. Tooling API console https://www.youtube.com/watch?v=7YcW25PHnAA&feature=youtu.be Tooling Netbeans Apart from the access tokens you have to get familiar with the addressed Tooling curl Tooling curl subjects. Basic understanding Uniform constrained interface JAX-RS JAX-RS Service Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 5/27 RESTful java with API console JAX-RS HOM,DOS,SBK In the previous video an api console was used. Instead we are going to use the app, Advanced REST Client, which is based Intro Motivation on the same technology as Atom, VS-Code: electron-js Sockets and socket exercise reviewed installation guide: API’s everywhere. Tooling API console visit https://install.advancedrestclient.com/ and press the install Tooling Netbeans Tooling curl button if you are on Mac or Windows. (You will want the dmg or exe file) Tooling curl Basic If you are on a Linux (like me) do NOT press the install button, but instead understanding Uniform constrained select Other Platforms and choose the package for you distro. For me, with interface my debian based Ubuntu it is arc-linux-12.1.2-amd64.deb. If you are on JAX-RS JAX-RS Redhat or derivative, choose the appropriate rpm package. Service You will use ARC to test your own RESTful api service. Stack overflow (actually Service Protocol stackexchange) has a rest API: Be Lazy, Not Slow http://api.stackexchange.com/2.2/search?order=desc&sort=activity&tagged=javafx&site= Enabling postgres stackoverflow. in payara More on PostgreSQL If you use the URL on the command line, make sure to escape the & Exercise (ampersand) characters, because they otherwise have a special meaning in the Q&A command shell. HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 6/27 RESTful java with Application server and Netbeans JAX-RS HOM,DOS,SBK Like a website needs a webserver to be hosted, RESTful api’s need a so called application server. We are going to use Payara Server version 5. This is the Intro Motivation improved version of Glassfish, which is the reference implementation of the Java Sockets and socket exercise reviewed EE standard. Brief installation guide: API’s everywhere. Tooling API console Download Payara Server from http://www.payara.fish, unzip it in some Tooling Netbeans Tooling curl folder, NOT like “Program Files” in Windows. Path with spaces are Tooling curl problematic. On Linux you would place in /opt so C backslash opt might Basic understanding be a good place too. Uniform constrained interface In Netbeans, select ”Service” tab ->”Servers” JAX-RS JAX-RS If present delete the current GlassFish Server Service Service Next right click on ”Servers” and select ”Add Server” and find the payara5 Protocol folder. Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 7/27 RESTful java with Curl JAX-RS HOM,DOS,SBK curl is a command line tool for transfering data with URL’s and very handy for testing rest api requests. Intro Motivation Mac and linux have curl preinstalled. Window users should google for Sockets and socket exercise reviewed curl-7.40.0-openssl-libssh2-zlib-x64. API’s everywhere. Tooling API console Take https://sourceforge.net/ to download a copy. Tooling Netbeans Tooling curl Tooling curl Basic understanding Uniform constrained interface JAX-RS JAX-RS Service Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 8/27 RESTful java with Friendlier CURL: Meet HTTPIE JAX-RS HOM,DOS,SBK More user friendly then curl is httpie. I will demo that. You can find it at https://httpie.org/ Intro Motivation Sockets and socket exercise reviewed API’s everywhere. Tooling API console Tooling Netbeans Tooling curl Tooling curl Basic understanding Uniform constrained interface JAX-RS JAX-RS Service It is probably curl on dreadlocks. Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 9/27 RESTful java with curl examples JAX-RS HOM,DOS,SBK skip this frame, target website is not maintained. get only one item: Intro Motivation curl −X GET https dosdemo mybluemix net api CoffeeShops Sockets and socket exercise :// . / / /1 reviewed API’s everywhere. Tooling API console get all items: Tooling Netbeans Tooling curl curl −X GET https :// dosdemo . mybluemix . net / api / CoffeeShops Tooling curl Basic understanding post an item: Uniform constrained interface JAX-RS curl −XPOST −−header ' Content−Type : application /json ' n −−header ' Accept : application /json ' n JAX-RS −d f "name" "AB" "city" "Venlo" "country" "NL" g n ' : , : , : ' Service https :// dosdemo . mybluemix . net / api / CoffeeShops Service Protocol Curl is the standard. Same for wget Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 10/27 RESTful java with Basic understanding JAX-RS HOM,DOS,SBK The architectural principles of REpresentational State Transfer are defined as below in Roy Fielding’s PhD thesis: Intro Motivation Addressable resources, addressable through a specific URI. Sockets and socket exercise reviewed API’s everywhere. A uniform constrained interface Tooling API console Tooling Netbeans Representation-oriented: Representations are exchanged between client and Tooling curl service, think about current state of a resource. Format of this Tooling curl Basic representations could be XML, JSON etc. understanding Uniform constrained Communicate statelessly, no client session data stored on the server. interface JAX-RS Hypermedia As The Engine Of Application State (HATEOAS) JAX-RS Service Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 11/27 RESTful java with Uniform constrained interface JAX-RS HOM,DOS,SBK Which sticks to a small set of operations, the most important are: GET(like sql-select) safe and idempotent Intro Motivation Sockets and socket exercise PUT(like sql-update) idempotent reviewed API’s everywhere. DELETE(like sql-delete) idempotent Tooling API console Tooling Netbeans POST(like sql-insert) not idempotent Tooling curl Tooling curl Idempotent means that no matter how many times you apply the operation, Basic understanding the result is always the same. Uniform constrained interface Safe means invoking does not change the state of the server. JAX-RS JAX-RS Service Service Protocol Be Lazy, Not Slow Enabling postgres in payara More on PostgreSQL Exercise Q&A HOM,DOS,SBK/FHTenL RESTful java with JAX-RS April 12, 2018 12/27 RESTful java with JAX-RS JAX-RS HOM,DOS,SBK JAX-RS is a framework that focuses on applying Java annotations to plain java objects.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us