MoSeS - Moby Services Support

The MoSeS project hopes to give a full support for those who are writing Biomoby services. And because the Biomoby data exchange format is symmetric (data from and to services have the same structure) the support (such as a general XML parser for Biomoby data) can be used also for clients.

The current Moses is for Java services - but not much is missing and Moses can produce also code in Perl (if you think that it would be useful let me know).

MoSeS Components

The documents listed below explain in details the whole Moses project. Because the main purpose of Moses is to support service providers, sometimes documentation focuses more on development ("how to write a code", "how it is done") rather on a randomly walking-in end-users ("how to use it"). If you are the latter you may find most in the sections describing various supporting command-line clients.

The Moses consists of four major parts:


The basic idea is not new - it was already implemented in other languages for Biomoby: take descriptions of Biomoby data types from a registry and generate Java classes for all these data types, keeping in place their hierarchy. Once we have Java representation of all data types, we can generate also code for a Biomoby service that will be using strongly-typed access to all incoming and out-coming data. An implementation of such service will inherit from a generated service skeleton in such way that all processing of Biomoby XML is hidden.

This is an example of a full implementation of a service called HelloBiomobyWorld that does not expect any input and produce a String data type (with a predictable contents) (the code is available in jMoby):

package org.jmoby.tutorial.service;

import net.jmoby.samples.HelloBiomobyWorldSkel;
import org.biomoby.shared.MobyException;
import org.biomoby.shared.parser.MobyPackage;
import org.biomoby.shared.parser.MobyJob;
import org.biomoby.shared.datatypes.*;

public class HelloBiomobyWorldImpl
    extends HelloBiomobyWorldSkel {

    public void processIt (MobyJob request,
			   MobyJob response,
			   MobyPackage outputContext)
	throws MobyException {
	set_greeting (response, new MobyString ("Hello, World!"));

The service was registered in a Biomoby registry as follows:

  <Service authURI=''
This is a cult service, known to an exclusive group of persons sharing an esoteric
interest. One of their believes is that a word started on January, 1 1970.
      <Simple articleName='greeting'>
I have highlighted in both pictures a word greeting. It is an article name in a Biomoby registry, and it became a method name in a service implementation.

The same happens also with data types name, as shown in the second example (here it shows only part of the implementation class but its full version is in jMoby):

     * This is a mandatory method to be implemented.
    public void processIt (MobyJob request,
			   MobyJob response,
			   MobyPackage outputContext)
	throws MobyException {
 	Regex input = get_language (request);
	if (input == null) return;

 	simple_key_value_pair[] output = doBusiness (input);
 	set_helloSet (response, output) ;

     * Here is where the bussines logic is done
    protected simple_key_value_pair[] doBusiness (Regex regex)
	throws MobyException {

	String regExpression = regex.get_regex();
	if (isEmpty (regExpression))
	    return new simple_key_value_pair[] {};

The Regex and simple_key_value_pair are Biomoby data types - and you see that you can manipulate them as any Java object. The other highlighted words are parts of methods - they came either from the article names or from data types names (where article names were missing). The suffix Set in one method indicates that the object will be a Biomoby collection.

Quick start

Details and explanation follow in the next sections. The examples of typing assumes that you have a CVS copy of jMoby and you have already compiled all classes (which is easy to do just by typing ant install.

  1. Register your service (for example, a service named TheService). Select what data types it will consume and what data types it will produce. Register the unless they are already registered. (There is no support in Moses for this step - there are already several ways how to do it by other tools.)

  2. Generate Java classes for all data types, compile them, packed them into a jar file and let javadoc generate their API documentation (note that you must have Internet connection because it explores Biomoby registry):
    ant moses-datatypes
  3. Generate skeleton for your service, compile it, generate its API:
    ant -Dmoses.service=TheService moses-services
  4. Write your own implementation, for example a class TheServiceImpl, that extends skeleton TheServiveSkel, and that contains the business logic you want to have. Compile it, test it (you can test it using the BaseCmdLineClient even before you deploy it to your Tomcat). If you place your source code into src/samples - use whatever package you like - you can compile it using jMoby Ant:
  5. Start your Tomcat and deploy your implementation to your Tomcat (sorry, this is not yet fully implemented):
    ant deploy-services

Main features

The services implemented on top of generated skeletons have implicitly (i.e. without any need to program) the following features:

Some other features are either planned to be added, or to be discussed how useful they would be, some of them can be done by few lines of code:

Martin Senger
Last modified: Thu Feb 14 15:05:21 2008