Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.

Plugins

fschoeppl edited this page Aug 2, 2012 · 5 revisions

Setup

To setup the standard plugins, start up the embedded server with the standard profile (mvn -P standard exec:exec) and do following steps:

  • copy all standard-plugins/*.jar into the folder org.backmeup.embedded\autodeploy
  • export your plugins (currently with eclipse) into the folder org.backmeup.embedded\autodeploy
  • example plugins can be found within the folder plugins.

(Note: The autodeploy-folder will be used to deploy OSGi-bundles if you start the embedded server in following way:

cd org.backmeup.embedded
mvn -P standard exec:exec

)

Developing plugins

Try to create your own plugin based on the two basic plugins which are currently available within the folder plugins. To create a new plugin, do following things:

  1. Start Eclipse and create a new Plug-in Project.
  2. Open META-INF/MANIFEST.MF and add Dependencies to:
  • org.backmeup.model
  • org.backmeup.model.spi
  • org.backmeup.plugin.api.connectors
  • org.backmeup.plugin.api.storage
  • org.backmeup.plugin.api.storage.filesystem
  • org.backmeup.plugin.spi
  1. Add your own library dependencies within the MANIFEST. Hint: Take a look at the dropbox example.
  2. Implement the Interface SourceSinkDescribable
  3. Implement the Interface OAuthBased or InputBased depending on your needs (OAuthbased authentication or InputBased authentication).
  4. Implement the Interface Datasource and/or Datasink. If you implement a Datasource, you might extend the class FileSystemLikeDatasource (makes it a bit easier).
  5. Create your spring configurations (META-INF/spring/org.backmeup.project-context.xml + META-INF/spring/org.backmeup.project-osgi-context.xml). Make sure that the name elements contain the same value as the Describable-Implementation returns. [an example can be found in the dropbox-plugin]
  6. Export your plugin as Deployable plug-ins and fragements and copy it into the autodeploy folder.

Dropbox datasource

The classes found in plugins/org.backmeup.dropbox explain how to create an OAuthBased-authenticator (DropboxAuthenticator) and how to create a datasource for dropbox (DropboxDatasource). The service configuration can be found within META-INF/spring/org.backmeup.dropbox-(osgi)-context.xml.

Skydrive datasink

The classes found in plugins/org.backmeup.skydrive explain how to create a OAuthBased datasink (SkyDriveDatasink).

Meta information

To enhance the search quality ("search within your backups") the indexer plugin needs additional information for each item it is going to index. E.g. "when was the item modified for the last time; when was a backup executed; which source was used; which relationship does this element have". This kind of meta information must be provided by the source plugins. To achieve this, a plugin has to add instances of Metainfo to the FilesystemURI object during the download process. Take a look at following example:

public static String DROPBOX = "dropbox";
public List<FilesystemURI> list(Properties items, FilesystemURI uri) {
    ... // initialize the formatter of type SimpleDateFormat here;...
    Entry entry = api.metadata(path, 100, null, true, null);				
    for (Entry e : entry.contents) {
      String encodedURI = e.path.replace(" ", "%20");
      // create a new entry to download
      FilesystemURI furi = new FilesystemURI(new URI(encodedURI), e.isDir);
      // provide metadata for it
      Metainfo meta = new Metainfo();
      // a unique identifier of the resource
      meta.setId(encodedURI);
      if (uri != null)
        // the identifier of the parent (if available)
        meta.setParent(uri.getMetainfo().getId());
      // when happened the last modification
      meta.setModified(formatter.parse(e.modified));
      // start date of the backup
      meta.setBackupDate(new Date());
      // the destination name of this resource
      meta.setDestination(e.path);
      // the name of the source
      meta.setSource(DROPBOX);
      // the mime type of this resource
      meta.setType(e.isDir ? "directory" : new MimetypesFileTypeMap().getContentType(e.path));
      // add the meta information to the filesystemuri object; it will be used by the indexer automatically.

      // you might add more than one meta information to this element if it consists of multiple 
      // data entries.
      furi.addMetainfo(meta);
      uris.add(furi);
    }
  } 
  ...
  return uris;
}

A plugin developer has to create a new Metainfo instance, store all known meta information in it and add it to the FilesystemURI instance. A developer might add any kind of meta information by calling the Metainfo.setAttribute method. These meta information are automatically handled by the backmeup core and forwarded to the indexer plugin.

Clone this wiki locally