LinkRest principle scheme

...open-source protocol and framework for flexible model-driven
REST data services

Video

"RESTful Data Services with LinkRest" - a presentation given at WOWODC 2015 in Hamburg.

getting started

<!-- Add Maven Dependency -->

<dependency>
    <groupId>com.nhl.link.rest</groupId>
    <artifactId>link-rest</artifactId>
    <version>1.22</version>
</dependency>
// Load in JAX RS Application

@ApplicationPath("/")
public class JaxRsApplication extends ResourceConfig {
    public JaxRsApplication() {
        ServerRuntime cayenneRuntime = ..
        LinkRestRuntime lrRuntime = LinkRestBuilder.build(cayenneRuntime);
        register(lrRuntime);
    }
}
// Write a JAX-RS Resourcy

@Path("myentity")
@Produces(MediaType.APPLICATION_JSON)
public class MyEntityResource {
    
    @Context
    private Configuration config;

    @GET
    public DataResponse<MyEntity> getAll(@Context UriInfo uriInfo) {
        return LinkRest.select(MyEntity.class, config).uri(uriInfo).select();
    }
}
# Start Sending Requests

curl -i -X GET \
'http://127.0.0.1:8080/myapp/my-entity'

features

Protocol

Client Shapes the Response

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.

GET, POST, PUT, DELETE

Supports reading / modifying data objects, collections and relationships.

Vanilla HTTP / JSON

Based on common REST HTTP interactions. Serves data as JSON.

framework

Java DSL for Building REST APIs for Data Stores

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

Supports relational databases via Cayenne ORM backend provider out of the box.

Pluggable Backend Providers for Other Data Stores

Supports alternative user-defined backends. E.g. for NoSQL stores, analytical queries, LDAP / Active Directory, etc.

Fine Grained Security

Straightforward integration with any Java authorization framework to provide attribute-level and object-level access control.