Optimize REST interactions. Avoid excessive requests to server when navigating backend data graphs.
<dependency>
<groupId>io.agrest</groupId>
<artifactId>agrest</artifactId>
<version>3.3</version>
</dependency>
@ApplicationPath("/")
public class JaxRsApplication extends ResourceConfig {
public JaxRsApplication() {
ServerRuntime cayenneRuntime = ..
AgRuntime agRuntime = AgBuilder.build(cayenneRuntime);
register(agRuntime);
}
}
@Path("myentity")
@Produces(MediaType.APPLICATION_JSON)
public class MyEntityResource {
@Context
private Configuration config;
@GET
public DataResponse<MyEntity> getAll(@Context UriInfo uriInfo) {
return Ag.select(MyEntity.class, config).uri(uriInfo).get();
}
}
curl -i -X GET \
'http://127.0.0.1:8080/myapp/my-entity'
Read full documentation in Docs section
Features easy-to-use fluent Java API to build customized processors for entity web methods. API works on top of JAX-RS standard. Reuses / extends entity model of a pluggable backend provider.
Supports relational databases via Cayenne ORM backend provider out of the box.
Supports alternative user-defined backends. E.g. for NoSQL stores, analytical queries, LDAP / Active Directory, etc.
Straightforward integration with any Java authorization framework to provide attribute-level and object-level access control.
Provides REST API that allows client to filter, sort, paginate the response. Client can request specific properties of "root" entity and recursively include data of related entities.
Supports reading / modifying data objects, collections and relationships.
Based on common REST HTTP interactions. Serves data as JSON.