Warning
This page is located in archive.

Glassfish Debugging, Caching, HATEOAS, RESTEasy

Glassfish application debugging

See how to debug an app on Glassfish: Glassfish Application Debug IntelliJ Tutorial

RESTEasy

Another JAX-RS implementation except Jersey JBoss: http://www.jboss.org/resteasy

Uses the same API and package javax.ws.rs.*

Simple dependencies with JSON for Maven:

<dependencies>
	<dependency>
		<groupId>org.jboss.resteasy</groupId>
		<artifactId>resteasy-jaxrs</artifactId>
		<version>2.2.1.GA</version>
	</dependency>

	<dependency>
		<groupId>org.jboss.resteasy</groupId>
		<artifactId>resteasy-jackson-provider</artifactId>
		<version>2.2.1.GA</version>
	</dependency>
</dependencies>

<repositories>
	<repository>
		<id>JBOSS_NEXUS</id>
		<url>http://repository.jboss.org/nexus/content/groups/public</url>
	</repository>
</repositories>

REST architecture constraints

  • Client-Server
  • Stateless
  • Cacheable
  • Layered system
  • Code on demand (optional)
  • Uniform interface

Talk on the topic given by doc. Ing. Tomáš Vitvar, Ph.D (FIT): HATEOAS-Vitvar

Caching

HTTP Headers Cache-Control, Last-Modified, ETag, If-Modified-Since, If-None-Match

Cache-Control

Defines caching setting for client, proxy

  • private proxy can't cache, client can
  • public both client and proxy can cache
  • no-cache should not be cached
  • no-store cache should not be persistent
  • no-transform no data transformation (compression)
  • max-age cache validity
  • s-maxage cache validity for proxy
Last-Modified

Response header, defines when the resource was last modified.

If-Modified-Since

Request header, defines that the resource returns ok (200), if modified since the given date, 304 otherwise.

ETag

Response header, defines the tag (hash) of the returned resource.

If-None-Match

Request header, defines, that the resource should be returned if the tag was modified, otherwise returns 304

Example

Concurrency Control

Lze možné tyto caching headers použít i pro Concurrency Control?

If-Unmodified-Since

Request header (for Last-Modified response header) - if holds, 200 / 204, otherwise 412 Precondition Failed

If-Match

Request header (for ETag response header) - if holds, 200 / 204, otherwise 412 Precondition Failed

HATEOAS

Hypertext as the Engine for Application State

  • How is the state of the stateful application stored?
  • How can we achieve the same behavior in stateless application?

HATEOAS - using links and headers we can store the state of the application.

Stateless ordering system design

Download the RESTEasy project: HATEOAS

Resources:

  • POST /orders Creates a new order and returns URI of the order in the Location header
  • GET /orders/id Returns an order with given ID
  • POST /orders/id {“name”:“car”} Creates a new item in the order
  • GET /orders/id/itemId Returns an item of the order with given ID
  • PUT /orders/id/itemId {“name”:“car”} Modifies the item in the order
  • DELETE /orders/id/itemId Deletes item of the order with given ID.
courses/a4m36aos/cviceni/class_23_10_2015.txt · Last modified: 2015/10/22 08:49 by kopriste