Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Apache Sling as an OSGi-powered REST middleware - Robert Munteau


Published on

OSGi Community Event 2015

Apache Sling is an innovative web framework built on top of the Java Content Repository (JCR), that uses OSGi for its component model and fosters RESTful application design.</p>
Apache Sling is designed as a set of loosely coupled OSGi bundles aggregated into a single jar or war launcher. Extensibility is internally achieved by using OSGi services. Even though Sling was initially designed for JSR-283 content repositories, building on top of the OSGi service registry allows plugging in multiple data sources - resource providers in Sling parlance.

In this talk we will showcase the usage of OSGi extension points in Apache Sling which allows usage of multiple resource providers, from simple filesystem-based providers to complex ones like MongoDB or Cassandra. Running all providers at the same time allows Apache Sling to be used as a REST-based middleware for multiple data sources.

This talk will present how this extensibility allows plugging in multiple data sources.

Published in: Technology
  • Be the first to comment

Apache Sling as an OSGi-powered REST middleware - Robert Munteau

  1. 1. @rombert Apache Sling as a RESTful API gateway for your NoSQL datastores Apache Sling as a RESTful API gateway for your NoSQL datastores Robert Munteanu, Adobe Systems EclipseCon Europe 2015
  2. 2. @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
  3. 3. @rombert Agenda ● Quick facts and figures ● Meet Barry ● Demo ● Why is Sling such a good fit for an API gateway ● Conclusions, Resources, Q&A
  4. 4. @rombert Apache Sling - History 2007 Incubation 2009 TLP 2015 Version 8 200x Pre-Apache
  5. 5. @rombert High-level View of the Code Source: OpenHub
  6. 6. @rombert Level of activity Source: OpenHub Source:
  7. 7. @rombert Conceptual foundations REST-based Content-driven OSGi-powered Scripting InsideApache
  8. 8. @rombert REST-based /content/blog/ /content/blog/{0}.html / BlogViewController BlogListController HomeController SlingMainServlet / /content /content/blog /content/blog/hello-world
  9. 9. @rombert REST-based / /content /content/blog /content/blog/hello-world [sling/redirect] [sling/redirect] [blog/welcome] [blog/page]
  10. 10. @rombert Barry – Senior Buzzword Deliverer
  11. 11. @rombert Demo time!
  12. 12. @rombert How is everything mapped? / ( root ) /content/blog/comments /content/blog/posts /content/blog/images
  13. 13. @rombert How does Sling manage this? ResourceProvider JCR NoSQL FS Couchbase MongoDB ResourceProviderFactory Produces
  14. 14. @rombert SPI → API ResourceProviderFactory OSGi Service Registry ResourceResolver Registers Gets
  15. 15. @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;
  16. 16. @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(...)
  17. 17. @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();
  18. 18. @rombert Why do we need adaptTo? Adaptable Resource ValueMap Map<String,Object> Post
  19. 19. @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();
  20. 20. @rombert Demo time!
  21. 21. @rombert Oh, but there's more
  22. 22. @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
  23. 23. @rombert Beyond the NoSQL datastores
  24. 24. @rombert Buzzword checklist ✔ RESTful ✔ API gateway ✔ NoSQL ✔ OSGi
  25. 25. @rombert Resources ● Apache Sling – ● Sling NoSQL providers - sql-resource-providers.html ● Apache Jackrabbit Oak -
  26. 26. @rombert Resources