MobyCentralModel Java library

MobyCentralModel library provides a basic BioMoby Registry model that can be used by other applications that need a coherent model to work with BioMoby repositories. The library contains a several singleton based models and a simple cache system based on XML files.

There are two packages in the library:
org.inb.biomoby.central.cache.* This package contains a simple XML file based cache implementation.
org.inb.biomoby.central.model.* Package contains basic BioMoby model singletons.

MobyCentralModel cache

The cache is implemented using a JAXB API and accessed through a CacheConfig class. It is possible programmatically change a cache source providing a custom implementation of IMobyCentralCache interface. The default file based implementation MobyCentralFileCache stores a cache in a $HOME/.MobyCentralCache/ directory.

MobyCentralModel model

There are several singleton based models available for developer. All they are implemented an abstract AbstractModel so share the same basic methods to work with.

public Collection<T> getElements(); Get all model elements
public T getElement(T element) Get an element providing a given one as a reference (it uses equals() method, what in our case refer to a name/authority)
public boolean addElement(T element); Adds a new element to the model
public boolean removeElement(T element); Removes an element from the model
public boolean updateElement(T element1, T element2); Updates an element referenced by element1 with information from element2.

There are three singleton models provided: NamespacesModel, DatatypesModel and ServicesModel. While retrieving an information from BioMoby Registry, models automatically update an internal cache (could be disabled).

Somewhat a special model is a MobyCentralModel given that is does not connect to the BioMoby registry, but rather read a META-INF/MobyCentralList.xml configuration file. Also this model contains a currently selected BioMoby Registry notifying other models when changed (there may be only one active BioMoby Registry at a time).

Also there is a simple event system that provides a notification about a model changes. To recieve event messages one should implement a ModelListener class and register it with a model using addListener(ModelListener listener) method.

These three lines would give all services provided by an "INB" repository:

MobyCentral central = new MobyCentral("", "");
List<Service> services = ServicesModel().instance().getElements();

If this is a first time the application launches, it would load all the services from the repository filling a cache. Consequent calls will load the information from a cache. To completely reload the cache there is a reload() method.

Even the models contain methods to modify BioMoby Registry they are NOT IMPLEMENTED so it is impossible to harm the registry by misusing the library.

Dmitry Repchevsky