Upload
robert-munteanu
View
797
Download
1
Embed Size (px)
Citation preview
http://robert.muntea.nu @rombert
Apache Sling as a RESTful API gateway for your NoSQL datastores
Apache Sling as a RESTful API gatewayfor your NoSQL datastores
Robert Munteanu, Adobe SystemsEclipseCon Europe 2015
http://robert.muntea.nu @rombert
Who I am
$DAYJOB Adobe Experience
Manager Apache Sling Apache Jackrabbit Apache Felix
FOSS Apache Sling MantisBT Mylyn Connector for
MantisBT Mylyn Connector for Review
Board
http://robert.muntea.nu @rombert
Agenda
● Quick facts and figures● Meet Barry● Demo● Why is Sling such a good fit for an API gateway● Conclusions, Resources, Q&A
http://robert.muntea.nu @rombert
Apache Sling - History
2007Incubation
2009TLP
2015Version 8
200xPre-Apache
http://robert.muntea.nu @rombert
High-level View of the Code
Source: OpenHub
http://robert.muntea.nu @rombert
Level of activity
Source: OpenHub
Source: status.apache.org
http://robert.muntea.nu @rombert
Conceptual foundations
REST-basedContent-driven
OSGi-powered
Scripting InsideApache
http://robert.muntea.nu @rombert
REST-based
/content/blog/
/content/blog/{0}.html
/
BlogViewController
BlogListController
HomeController
SlingMainServlet//content/content/blog/content/blog/hello-world
http://robert.muntea.nu @rombert
REST-based
//content/content/blog/content/blog/hello-world
[sling/redirect][sling/redirect]
[blog/welcome][blog/page]
http://robert.muntea.nu @rombert
How is everything mapped?
/ ( root )
/content/blog/comments
/content/blog/posts/content/blog/images
http://robert.muntea.nu @rombert
How does Sling manage this?
ResourceProvider
JCR NoSQL FS
Couchbase MongoDB
ResourceProviderFactoryProduces
http://robert.muntea.nu @rombert
SPI → API
ResourceProviderFactory
OSGi Service Registry
ResourceResolver
Registers Gets
http://robert.muntea.nu @rombert
ResourceResolver
Resource getResource(String path);
Iterable<Resource> getChildren(Resource parent);
Iterator<Resource> findResources(String query, String language);
Resource create(Resource parent, String name, Map<String, Object> properties) throws PersistenceException;
void delete(Resource resource) throws PersistenceException;
void commit() throws PersistenceException;
http://robert.muntea.nu @rombert
How do I get to handle a Resource?
1 GET /content/blog/posts/hello_world.json
2 ResourceResolver.resolve(...)
3 ServletResolver.resolveServlet(...)3
4 servlet.doGet(...)
http://robert.muntea.nu @rombert
What do clients see out of this?
Resource res = request.getResource();
// 1. reading ...
ValueMap properties = ↵ res.getValueMap();
String title = properties.get(“jcr:title”,↵ “Missing”);
Post post = res.adaptTo(Post.class);
title = post.getTitle();
http://robert.muntea.nu @rombert
Why do we need adaptTo?
Adaptable
Resource ValueMap
Map<String,Object> Post
http://robert.muntea.nu @rombert
What do clients see out of this?
Resource res = request.getResource();
// 2. writing ...
ValueMap properties = ↵ res.adaptTo(ValueMap.class);
String title = properties.put(“jcr:title”,↵ “Hello, world”);
Post post = res.adaptTo(Post.class);
post.setTitle(“Hello, world”);
res.getResourceResolver().commit();
http://robert.muntea.nu @rombert
Demo time!
http://robert.muntea.nu @rombert
More features
● Eventing, Thread Pooling, Job Management, Caching● Scripting: Groovy, Scala, JSP, Sightly, Java, Ruby, Thymeleaf● Flexible resource rendering with resource types● Very extensible due to being internally powered by OSGi – most extension points available to clients
http://robert.muntea.nu @rombert
Buzzword checklist
✔ RESTful✔ API gateway ✔ NoSQL✔ OSGi
http://robert.muntea.nu @rombert
Resources
● Apache Sling – http://sling.apache.org● Sling NoSQL providers - http://sling.apache.org/documentation/bundles/nosql-resource-providers.html● Apache Jackrabbit Oak - http://jackrabbit.apache.org/oak/