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

555 views

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

×