#Elide
##What Is Elide?
Elide is a Java library that let's you stand up a JSON API web service with minimal effort starting from a JPA annotated data model. Elide is designed to quickly build and deploy production quality web services that expose databases as services. Beyond the basics, elide provides:
- Access to JPA entities via JSON API CRUD operations. Entities can be explicitly included or excluded via annotations.
- Patch Extension Elide supports the JSON API Patch extension allowing multiple create, edit, and delete operations in a single request.
- Atomic Requests All requests to the library (including the patch extension) can be embedded in transactions to ensure operational integrity.
- Authorization All operations on entities and their fields can be assigned custom permission checks limiting who has access to your data.
- Audit Logging can be customized for any operation on any entity.
- Extension Elide allows the ability to add custom business logic and to changeout the default JPA provider (Hibernate)
- Client API Elide is developed in conjunction with a Javascript client library that insulates developers from changes to the specification.
##Getting Started
###Prerequisites
###Code The first step is to create a JPA data model and mark which beans to expose via Elide. The following directive exposes everything in a package:
@Include(rootLevel=true)
package example;
The second step is to create a DatabaseManager
. It is an interface that binds to a JPA provider. Elide ships with a default implementation for
Hibernate. The default HibernateManager
will discover all of the JPA beans in your deployment and expose those that have been annotated to do so.
/* Takes a hibernate session factory */
DatabaseManager db = new HibernateManager(sessionFactory);
The third step is to create an AuditLogger
. It is an interface that does something with Audit messages. Elide ships with a default that
dumps them to slf4j:
AuditLogger logger = new Slf4jLogger();
Create an Elide class
. It is the entry point for handling requests from your web server/container.
Elide elide = new Elide(logger, db);
Elide
has methods for get
, patch
, post
, and delete
. These methods generally take:
- An opaque user
Object
- An HTTP path as a
String
- A JSON API document as a
String
representing the request entity body (if one is required).
It returns a ElideResponse
which contains the HTTP response status code and a String
which contains the response entity body.
ElideResponse response = elide.post(path, requestBody, user)
Wire up the four HTTP verbs to your container and you will have a functioning JSON API server.
##License
The use and distribution terms for this software are covered by the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).