Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Excerpt
hiddentrue

JEST

JEST: REST on OpenJPA

JEST is a REST style access to any OpenJPA runtime. REST (Representational State Transfer) is a foundational concept in the architecture for World Wide Web. JEST promotes REST style interaction between a client and an application based on OpenJPA. A JEST-enabled OpenJPA runtime embeds a specialized HTTP server such that a client (neither necessarily in Java nor having any definition of the persistent server objects) can send HTTP requests and receive persistent data as response in JSON or XML or other string based format.

Effectively there are three aspects to JEST

  • Protocol of client-server communication
  • Representation of persistent state
  • Transaction semantics

Protocol

The communication protocol is HTTP. The client sends request in standard HTTP URI (Uniform Resource Identifier) e.g. http://www.jpa.com:6789/find?Person;JohnImage Removed to a JEST-enabled OpenJPA runtime. The URI syntax governs the server response. Before describing the syntax in detail, here are few typical example URI and their associated effect on the server.

...

Get name of the persistent unit

...

http://www.jpa.com:6789/

...

List simple name of the domain classes

...

http://www.jpa.com:6789/domain

...

List the key-value properties of the persistent unit

...

http://www.jpa.com:6789/properties

...

Find an instance by key

...

http://www.jpa.com:6789/find?Person;123456789

...

Find an instance by key

...

http://www.jpa.com:6789/find?Person;ssn=123456789;name=John

...

Get the result of the query with no parameter

...

http://www.jpa.com:6789/query?select p from Person p

...

Get the result of the query with single parameter

...

http://www.jpa.com:6789/query?select p from Person p where p.name=:name;name=John

...

Get the result of the query with multiple parameters

...

http://www.jpa.com:6789/query?select p from Person p where p.name=:name and age > :age;name=John;age=20

...

 

...

http://www.jpa.com:6789/query?select p from Person p where p.first=:first and p.last=:last;first=John;last=Doe

...

Get the single result of the query

...

http://www.jpa.com:6789/query/single?select p from Person p where p.name=:name;name=John

...

Get the result of the named query

...

http://www.jpa.com:6789/query/named?QueryPersonByName;name=John

The salient principles of JEST are:

  • non-invasive : Any persistent data managed by OpenJPA can be accessed without any change to POJO classes or to an existing application.
  • language-neutral : A client not necessarily Java-based can access persistent data simply by sending an HTTP request. JEST is URI-based as opposed to API-based.
  • schema-free : The content is self-describing. The client does not require access to persistent Java class definitions.

In REST (Representational State Transfer) terminology,

  • Resource : the resources are customizable graph of persistent objects. The object graph is coherent in the sense that if any entity e of the graph has a reference to another entity r, then r is also belongs to the graph.
  • Representation: the representation of resources are in XML or specialized JSON. JSON is specialized to account for any circular reference in the object graph. However, the JSON representation remains consumable by other standard JSON parsers.
  • Stateless : the life time of any computational resources used by JEST is bound by a single HTTP request-response lifetime.

JEST is further described under the following sections

Children Display
alltrue
excerpttrue

...

Get the single result of the named query

...