Rifidi:loading

From RifidiWiki

Jump to: navigation, search

Problem

Right now each part of Rifidi (Emulator, Designer, TagStreamer) loads and initializes its objects individually.
If one of the parts of Rifidi reuses classes from other parts of Rifidi we currently replicate the functionality for loading and initializing.

Aims of this proposal

  • move loading code into a separate bundle
  • allow the bundle to initialize classes by delegating the initialization to the appropriate parts of Rifidi
  • Use JAXB without adding custom extensions
  • Each part of Rifidi still needs to be able to run separately

Prerequisites

  • JAXB is capable of loading XML files with unresolvable tags.
    • verified: JAXB will skip tags that it doesn't know (Note: @XmlAnyElement annotations might still trip it over)

Approach

Create a base container class

We need to create a basic Rifidi-container-class that works as the root of our XML file.
This container class contains all items that are shared between all parts of rifidi (so far this would be readers and tags).
It also contains a list of RifidiAppContainers.

Application specific containers

RifidiAppContainer is an abstract class that is used by the different parts of Rifidi to store their specific elements (entities in the case of designer, traveltimes in the case of tagstreamer).

Create an extension point for initalizing application specific classes

JAXB will be loading our XML files. If for example we are loading a file in emulator that got saved in designer we will most likely only have the classes from emulator on our classpath. The RifidiAppcontainer-Tag in the xml file will be skipped as the classfile is not on the classpath.
If designer was on the classpath we would need to initialize the application specific classes inside the RifidiAppContainer for Designer.
To solve this problem I would suggest an extension based approach.

The init extension point

The init extension point is provided by our loading bundle.
A bundle implementing this extension point will provide the following information:

  • Name of a service that is used to initialize the classes.
  • A list of classes this extension point is responsible for initializing.

So each time the loader is asked to load a new file it first loads it and then starts checking what classes got loaded and delegates the initialization to the different bundles.

Personal tools