EntityBroker and REST Aaron Zeckoski [email protected] (Steve Githens) Creative Commons AttributionNonCommercial-ShareAlike 2.5 License Sakai Programmer's Café What is EntityBroker? • System to support flexible entities which make development of integrated Sakai tools easier for developers (easier to use and understand) and more powerful (easier to extend and improve). • The concept of an entity is very flexible. It can be a POJO, persistent object, string, etc. – Entities do not have to be backed by database data or even real data at all. • Each entity type (as defined by a unique prefix) has a set of capabilities associated with it. – These are fine-grained and defined by the developer who writes the EntityProvider for that entity type. – An EntityProvider can reside in a Sakai component or a webapp and can implement as few as one interface with one method or as many methods as the developer desires. 2 What is REST? • Representational state transfer (REST) is a style of software architecture for distributed systems (web). REST strictly refers to a collection of network architecture principles which outline how resources are defined and addressed. Often used in a looser sense to describe any simple interface which transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. 3 REST better defined • REST microformat – Conventions based on Ruby On Rails – Uses http semantics to work with data • • • • POST - Create a resource within a given collection GET - Retrieve a resource PUT - Update a resource DELETE - Delete a resource – Defines the URL formatting, data formats, and http responses 4 En francais svp. (In english please) • Allows developers to define and expose their data as they like (entities) – Can use RESTful URLs to access entity data • Allows them to control those entities be implementing interfaces (provider) • Allows them to define what their entities are capable of (capabilities) 5 What is it made of? • Sakai Service API – Use some and implement others • Sakai Service Impl (component) – Uses Spring, XStream, etc. • Utilities – Bean reflection, reloadable service proxy, etc. – You might use this also • Developer Helper Service – You might use this as well • Direct servlet (/direct) 6 How do I define entities? • Just implement an entity provider – Define the entity prefix, e.g. user, evaluation – org.sakaiproject.entitybroker.entityprovider.EntityProvider • Add in the capabilities you want – E.g. RESTful, CRUDable, Taggable • Register with the EntityProviderManager – Or use AutoRegisterEntityProvider • If you are using a component • Build, deploy, and restart Sakai 7 Sample Entity public class WebAppEntity { @EntityId private String id; private String title; private String text; private String owner; private boolean flagged; private int number; public WebAppEntity() {} public WebAppEntity(String title, String text, String owner) { this.title = title; this.text = text; this.owner = owner; } … 8 Sample EntityProvider public class WebappEntityProvider extends AbstractEntityProvider implements RESTful { private MemoryDao dao; public void setDao(MemoryDao dao) { this.dao = dao; } public static String PREFIX = "webapp-entity"; public String getEntityPrefix() { return PREFIX; } … Sample WebappEntityProvider 9 Why do I care? • This allows you to provide information about your entities to Sakai and to systems outside Sakai • It allows your entity data to be accessed and manipulated without hard dependencies • REST and client side development becomes easy 10 EntityBroker Diagram Capability RESTful EntityProvider API MyService MyDAO Entity Data Taggable Resolveable EntityProvider myentity blog XML JSON Interweb PHP, Ajax, Python CRUDable EntityProviderManager REST EntityBroker My code API API POJO POJO POJO SomeService POJO POJO POJO My entity code Not my code OtherService XML XML 11 Questions? URL: Entity+Provider+and+Broker 12
© Copyright 2024