Version: 1.1.1

org.biomoby.service.generator
Class Generator

java.lang.Object
  extended by org.biomoby.service.generator.Generator
Direct Known Subclasses:
DataTypesGenerator, ServicesGenerator

public abstract class Generator
extends Object

A common superclass to all Moses generators.

It also contains property names (fields started by GPROP_) used by data types and service instances generators. The descriptions of the property names actually describe what will be the value of such properties.

Version:
$Id: Generator.java,v 1.6 2008/03/03 11:34:17 senger Exp $
Author:
Martin Senger

Field Summary
static String GPROP_AUTH
          A regular expression that will be applied against service authority names.
static String GPROP_DOTLOCATION
          A path to a Graphviz program dot.
static String GPROP_FILTER
          A regular expression that will be applied to a data type name.
static String GPROP_NOGEN
          A debugging property: do not generate anything, just print what you would generate.
static String GPROP_NOGRAPHS
          Data type generator will not produce any graphs if this property is set to "true".
static String GPROP_OUTDIR
          A name of a directory where a generator puts its generated results.
static String GPROP_SERVICE
          A regular expression that will be applied against service names.
static String GPROP_VERBOSE
          Generator will print some messages if this property is set to "true".
 
Constructor Summary
Generator()
          Default constructor.
Generator(CentralCached worker)
          Another constructor getting a ready-to-use accessor (the 'worker') to a, hopefully locally cached, BioMoby registry.
Generator(String cacheDir)
          Another constructor pointing to a cache directory where the retrieved data types are stored.
Generator(String registryEndpoint, String registryURI, String cacheDir)
          Another constructor pointing to a cache directory and defining where is a Biomoby registry whoe data types will be generated.
 
Method Summary
abstract  void generate(Properties props)
          Generate "things" from a given Biomoby registry.
abstract  Map<String,File> getTemplateNames()
          Getting names of templates is isolated here so a sub-class can override it (but any new teplate still needs to follow the same patterns as the original template - so it is not too flexible, anyway).
 CentralCached getWorker()
          Return an underlying object (a worker) that does all data types retrieving and caching them.
static File makeDirs(String dirName, String packageName)
          Create all needed sub-directories - as required by given Java package name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GPROP_FILTER

public static final String GPROP_FILTER
A regular expression that will be applied to a data type name. Only those data types that match this expression will be generated. If its value is null or an empty string filtering is ignored.

See Also:
Constant Field Values

GPROP_OUTDIR

public static final String GPROP_OUTDIR
A name of a directory where a generator puts its generated results. The generator may (and often does) create here further hierarchical structure of subdirectories.

See Also:
Constant Field Values

GPROP_AUTH

public static final String GPROP_AUTH
A regular expression that will be applied against service authority names. Only those services that match this expression will be generated (unless restriced also by a service name filter - see GPROP_SERVICE. If its value is null or an empty string filtering is ignored.

See Also:
Constant Field Values

GPROP_SERVICE

public static final String GPROP_SERVICE
A regular expression that will be applied against service names. Only those services that match this expression will be generated (unless restriced by an authority name filter - see GPROP_AUTH. If its value is null or an empty string filtering is ignored.

See Also:
Constant Field Values

GPROP_VERBOSE

public static final String GPROP_VERBOSE
Generator will print some messages if this property is set to "true".

See Also:
Constant Field Values

GPROP_NOGRAPHS

public static final String GPROP_NOGRAPHS
Data type generator will not produce any graphs if this property is set to "true". Such graphs are supposed to be used in the generated API documentation (by javadoc).

See Also:
Constant Field Values

GPROP_DOTLOCATION

public static final String GPROP_DOTLOCATION
A path to a Graphviz program dot. The program can (unless property GPROP_NOGRAPHS is set to false) produce graphs showing place of a generated data type in a tree of other data types. This property is needed only if the dot program is not already on the PATH.

See Also:
Constant Field Values

GPROP_NOGEN

public static final String GPROP_NOGEN
A debugging property: do not generate anything, just print what you would generate.

See Also:
Constant Field Values
Constructor Detail

Generator

public Generator()
Default constructor. It does not use any cache for storing data types retrieved from a Biomoby registry. It uses a default Biomoby registry.


Generator

public Generator(String cacheDir)
          throws MobyException
Another constructor pointing to a cache directory where the retrieved data types are stored. Otherwise, a default Biomoby registry is used.

Parameters:
cacheDir - is a directory where to create or read from a cache; the same directory can be safely shared for various Biomoby registries
Throws:
MobyException - if there is a problem with reading or creating the cache

Generator

public Generator(String registryEndpoint,
                 String registryURI,
                 String cacheDir)
          throws MobyException
Another constructor pointing to a cache directory and defining where is a Biomoby registry whoe data types will be generated.

Parameters:
registryEndpoint - is a URL of a Biomoby registry
registryURI - is a namespace/URI of such registry
cacheDir - is a directory where to create or read from a cache; the same directory can be safely shared for various Biomoby registries
Throws:
MobyException - if there is a problem with reading or creating the cache

Generator

public Generator(CentralCached worker)
Another constructor getting a ready-to-use accessor (the 'worker') to a, hopefully locally cached, BioMoby registry.

Parameters:
worker - is an accessor to a BioMoby registry
Method Detail

getWorker

public CentralCached getWorker()
Return an underlying object (a worker) that does all data types retrieving and caching them. This is useful if you wish to have more control over the cached results (for example if you want to re-read the data types again).

Returns:
a worker giving you a full access to a Biomoby registry

makeDirs

public static File makeDirs(String dirName,
                            String packageName)
                     throws MobyException
Create all needed sub-directories - as required by given Java package name.

Parameters:
dirName - a name of a directory where package-related subdirectories will be created. 'dirName' itself does not need to exist either (will be created - unless file permissions will stop it). If 'dirName' is null, however, its default value will be used - which is defined by System property 'user.dir'.
packageName - a usual Java dot-separated name for which all needed subdirectories will be created starting from the 'dirName'
Returns:
an abstract representation of the created directory
Throws:
MobyException - if 'packageName' is empty, or if some directories could not be created

getTemplateNames

public abstract Map<String,File> getTemplateNames()
Getting names of templates is isolated here so a sub-class can override it (but any new teplate still needs to follow the same patterns as the original template - so it is not too flexible, anyway).

The values of returned Map are files. It their names are relative (which is the best way) then they are looked for in the CLASSPATH (including all jar files there).

Make sure that the returned path is correct for the system where JVM is running.


generate

public abstract void generate(Properties props)
                       throws MobyException
Generate "things" from a given Biomoby registry. This is the main method. What the "things" are depends on the subclass that overrides and implements this method.

Parameters:
props - are properties influencing the generated results (e.g. where to put them)
Throws:
MobyException - if anything goes wrong

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010