...
Introduction
One of the changes in version 4 of Pentaho Data Integration is the introduction of concept of service for repositories. To support this concept the repository API of PDI has changed a little bit. This document describes how you can creates these repository services and register them to repository.
Changes to Repository API
To enable the registering of these repository services, we have added some new methods to the repository API. Details on these method are described below
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public interface IAclManager extends IRepositoryService{ /** * Retrieves the current list of of IRepository Services. /* * @return List of *repository Getservices the Permissions of* a@throws repositoryKettleException object.in case something goes *horribly wrong. */ @param Object Idpublic ofList<Class<? theextends repositoryIRepositoryService>> objectgetServiceInterfaces() throws KettleException; * @param forceParentInheriting/** retrieve the effective* ACLsRetrieves asa ifgiven 'inheritrepository fromservice parent' were true* @param service *class name * @return repository service The permissions. * * @throws KettleException in case something goes horribly wrong. */ public ObjectAclIRepositoryService getAclgetService(ObjectIdClass<? id,extends booleanIRepositoryService> forceParentInheritingclazz) throws KettleException; /** * Set the Permissions of a repository element. Checks whether a given repository service is available or not * * @param Aclrepository service objectclass that needs to be set. * @param Object Id of a file for which the acl are being set.checked for support * * @throws KettleException in case something goes horribly wrong. */ public boolean void setAcl(ObjectId id, ObjectAcl aclObjecthasService(Class<? extends IRepositoryService> clazz) throws KettleException; } |
...
registerRepositoryService(IAclManager.class, aclImpl);
...
Registering services to repository
To add a new service to repository, create an interface for the service and provide an implementation. This new service needs to extend IRepositoryService. This is a marker interface which identifies this new service as a repository service. Once the service is defined, it needs to register itself in the repository implementation. In future we can have this registration done using spring which will even more pluggable.
Adding service in detail
To explain this we will use an example of a repository service that provided management of access control list for the repository objects. We created an interface for this service which is described below
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public interface IAclManager extends IRepositoryService{ /** * RetrievesGet the currentPermissions list of ofa IRepositoryrepository Servicesobject. * * @return List of repository services * @throws@param KettleExceptionObject inId caseof somethingthe goesrepository horriblyobject wrong. */ @param forceParentInheriting publicretrieve List<Class<?the extendseffective IRepositoryService>>ACLs getServiceInterfaces()as throwsif KettleException;'inherit from parent' /** * Retrieves a given repository service * @param service class name were true * * @return repository service *The permissions. * @throws KettleException in case something goes horribly wrong. */ public IRepositoryServiceObjectAcl getServicegetAcl(Class<?ObjectId extendsid, IRepositoryService>boolean clazzforceParentInheriting) throws KettleException; /** * Checks whetherSet the Permissions of a given repository serviceelement. is available or not* * @param Acl object that needs to be set. * @param repository service class that needs to be checked for support Object Id of a file for which the acl are being set. * * @throws KettleException in case something goes horribly wrong. */ public booleanvoid hasServicesetAcl(Class<?ObjectId extendsid, IRepositoryService>ObjectAcl clazzaclObject) throws KettleException; } |
One item to note in this interface that it extends IRepositoryService. This is a marker interface which identifies this service to be a repository service. In a repository's implementation we instantiated the service implementation and register this service with repository. IAclManager aclImpl = new AclManagerImpl();
registerRepositoryService(IAclManager.class, aclImpl);
ResigerRepositoryService is a convenience method, all this is doing is adding the service interface and its implementation in a map. Once the services are registered you can Now you can the retrieve this service by using calling getService method in the Repository interface API
If this new service need a UI Support, you can extend AbstractRepositoryExplorerUISupport class and implement the setup method
...