Entity Provider and Broker Usage

Information

This explains how to use the entity broker and entity provider system in Sakai

Usage of the Entity Broker

  • EntityBroker gives you access to all entities in Sakai including the legacy ones. It also provides methods for searching for entities using things like properties and tags.
  • Use the EntityBroker like any other Sakai component bean. You can inject it into any services and beans OR look it up manually using the Sakai ComponentManager.
    • Inject it into a spring bean by creating a setter and adding the proeprty to your bean (normal Spring)
      <bean id="yourBean" class="org.place.YourClass">
            <property name="entityBroker" ref="org.sakaiproject.entitybroker.EntityBroker" />
      </bean>
      
    • Get it from the Sakai component manager using a call to the ComponentManager cover
      EntityBroker entityBroker = (EntityBroker) ComponentManager.get(EntityBroker.class);
  • Add the needed maven dependendencies to the your maven files
    • Maven 1 users will need soemthing like this in the project.xml:
      <dependency>
      	<groupId>sakaiproject</groupId>
      	<artifactId>sakai-entitybroker-api</artifactId>
      	<version>${sakai.version}</version>
      </dependency>
      
    • Maven 2 users will need something like this in the pom.xml:
      <dependency>
          <groupId>org.sakaiproject.entitybroker</groupId>
          <artifactId>entitybroker-api</artifactId>
          <version>1.3.3</version>
          <scope>provided</scope>
      </dependency>
      
  • Now you can access the various methods on the EntityBroker like:
    User user = (User) entityBroker.fetchEntity("/user/admin");
    Site site = (Site) entityBroker.fetchEntity("/site/DG73G3GE33-3FJ3HR4RF-F3FJF3JF4H-F3R4FR4HH");

Defining EntityProviders

  • Explains how to define your own entity providers

Helper code

DeveloperHelperService

  • Makes it easier to work with Sakai in general and think of everything as entities

BeanCollector

  • Allows developers to look up beans by an interface type and have them injected without having to do manual lookups

ReloadableComponentProxy

  • Allows for exposing a service from a webapp to the Sakai component manager/central Spring context
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.