Skip to content
jutaro edited this page Oct 3, 2011 · 9 revisions

Plugins (billeksah-main & billeksah-main-static)

We currently don't want to support a reconfigure of plugins without restart, as we can easily live with a restart after a change to the plugin configuration.

A plugin exposes an interface and we want to use Haskell for the definition of this interface. And we don't want to restrict this interface in any way, so the best we can do is to use a standard Haskell module or a Cabal Haskell package as plugin entity. We get a defined Haskell interface for free. So we decided:

A plugin is simply a Cabal library package. So what? Well, it is a cabal library package with some special properties, it has to expose a special function. But this is further explained in Section Services.

Plugin registration

Every plugin needs a configuration file, which is named with name-version.lkshp (E.g. billeksah-pane-1.0.0.lkshp) .

Beside the name and the version (remember that this should equal the name and version of the corresponding cabal package) the file gives a module name Module and a function name Interface, which are used to dynamically load the PluginInterface.

The prerequisites are a bit like the build-depends field of a cabal package description. The differences are:

  • only list plugins, and no other library packages
  • version bounds are specified simply with a possible upper and lower bound. (TODO: change to Cabals VersionRange?)
  • different syntax,

An example plugin specification file looks like:

Name of the plugin: leksah-main
Version:            1.0.0
Module:             Leksah
Interface:          leksahPluginInterface
Prerequisite list:  [(billeksah-pane,1.0,any)]
Synopsis:           

Finally a plugin configuration file with the extension .lkshc needs to be specified. This file gives (beside a name and a version of the configuration) a list of plugins with possible version restrictions, which shall be loaded when starting up the application. It may e.g. look like this:

Name of the config: LeksahStandard
Version:       1.0.0
Plugin list:   [(billeksah-forms,1,1.1),(billeksah-pane,1,1.1),(leksah-main,1,1.1),(leksah-plugin-pane,1,1.1)]
Synopsis:      The standard Leksah plugin config

Before loading the plugins, all needed plugins specs are collected recursively from the specified packages and its prerequisites and then the list gets sorted, so that for every plugin, its prerequisites precede them in the list. So the order in the plugins field doesn't matter. For every plugin the highest possible version number gets selected from the version restrictions. (TODO: check for inconsistencies) (TODO: specifying need zero to n of a set, need 1 to n of a set, need exactly 1 of a set)

You can start your application by typing

billeksah-main path-to-config/config-name.lkshc

It requires, that

  • the cabal packages of the plugins are installed
  • spec files for the plugins are provided (in the same folder as the config file)
  • the config file lists the plugins to load

Static Plugins

As an alternative you can use the plugin system in a statically linked environment. To do this you have to

  1. Add all your plugin cabal packages to the prerequisites of billeksah-main-static
  2. Add the name and the interface to the plugin Table in module Main:
    pluginTable ∷  Map String GenInterfaceM
    pluginTable = Map.fromList [("billeksah-forms", GenInterfaceM formsPluginInterface),...]
  1. Build and install the package
  2. Replace billeksah-main with billeksah-main-static when launching the application
Clone this wiki locally