mop.tools
Class Mop

java.lang.Object
  |
  +--Task
        |
        +--mop.tools.Mop

public class Mop
extends Task

An ant task extension to allow for running the mop compiler. This task requires that the goodshome property be set in the task or that the javamop compiler be accessable via the PATH statement. Below is an example usage:

<taskdef name="mop" classname="hhenson.tools.Mop">
  <classpath/> .. the path to this class
</taskdef>

<mop package="goodsjpi"
     classes="classes.txt"
     srcdir="./src"
     goodshome="/usr/local/goods" >
  <classpath refid="project.class.path"/>
</mop>

Where srcdir is required and must be a directory. The rest of the properties are not required. The classpath property is the standard classpath property as defined by ant.

See Also:
Serialized Form

Constructor Summary
Mop()
          Constructor for Mop.
 
Method Summary
 void addClasspath(Path _classPath)
          Sets the classpath of libraries to include in the mop exercies.
 Path createClasspath()
          Sets the classpath of libraries to include in the mop exercies.
 void execute()
           
 Path getClasspath()
          Sets the classpath of libraries to include in the mop exercies.
 void setClasses(java.io.File _classes)
          The classes option sets the -classes parameter to the goods mop compiler.
 void setClasspath(Path _classPath)
          Sets the classpath of libraries to include in the mop exercies.
 void setClasspathRef(Reference r)
          Adds a reference to a classpath defined elsewhere.
 void setGoodshome(java.io.File _goodsHome)
          The path where goods is installed on the system.
 void setPackage(java.lang.String _package)
          The package option advises the mop compiler what package to add to the import list of the class.
 void setSrcdir(java.io.File _srcDir)
          Sets the directory containing the source files to execute the mop compiler against.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mop

public Mop()
Constructor for Mop.

Method Detail

setPackage

public void setPackage(java.lang.String _package)
The package option advises the mop compiler what package to add to the import list of the class.


setClasses

public void setClasses(java.io.File _classes)
The classes option sets the -classes parameter to the goods mop compiler. From goods java documentation

It is possible to use the existing Java class library without changing sources by putting the list of persistent capable classes in some file and using JavaMOP with the "-classes" option. The following rules should be observed carefully when using this option:

The JavaMOP option -classes allows you to specify a list of classes, which should be controlled by metaobjects. In this case exactly one class with a metaobject instance field should be provided to JavaMOP. This is refered to as the MOP root class. JavaMOP will transform the definition of the classes, specified in the list, modifying them to derived from the MOP root class. The option -classes should be followed by a file name. This file should contain a list of full class names, separated by white space characters (new line, space, tabulation...). The class name should be written in the same format as the Java import statement. For example: goodslib.ArrayOfChar or goodslib.*" If the '*' symbol is placed at the end of a class name, then all classes from the specified package and nested packages are implicitly derived from the MOP root class. Classes specified in the -classes option list should not be archived, otherwise JavaMOP will not be able to preprocess them.

Some notes:

Although this functionality is really powerful, it is probably easier if you are writting you own code to place the extends Persistent in your classes and not make use of this aspect of the functionality.


setSrcdir

public void setSrcdir(java.io.File _srcDir)
Sets the directory containing the source files to execute the mop compiler against. From goods java documentation

You can specify only the name of the root directory, which will be recursively traversed by JavaMOP. Only the files with *.class or *.CLASS extension will be preprocessed by JavaMOP while traversing the tree.

If you want to create archives with persistent capable classes (ZIP or JAR), they should be build without compression (-0 flag for zip or jar) in order to let JavaMOP to read this files. JavaMOP currently is not able to unpack compressed ZIP files. JavaMOP will not patch files extracted from archive. Also JavaMOP adds special string to the preprocessed class file, so it will not patch it next time (in other words it is possible to apply JavaMOP several times to the same file - result will not be changed).

In order for JavaMop to correctly process and insert the correct bytecode in the class files, it is necessary to specify ALL class files which are persistent capable OR access persistent capable objects. That is, don't processes the files individually, this won't work.

Some notes:

Jars containing pre-processed persistent capable classes that are used by the project should be specified as a class path entry in the build script. Note however that the classes must not be compressed as the javaMop cannot read these files.

Note that the implementation here is slightly different to the full usage possible in the javamop. This is in the interests of simplicity and making this feel like the javac tag in the build script.


addClasspath

public void addClasspath(Path _classPath)
Sets the classpath of libraries to include in the mop exercies. This is the list of all jars containing persistence capable classes that are referenced by the classes defined in src directory. Note the jar files must not be compressed!


setClasspath

public void setClasspath(Path _classPath)
Sets the classpath of libraries to include in the mop exercies. This is the list of all jars containing persistence capable classes that are referenced by the classes defined in src directory. Note the jar files must not be compressed!


getClasspath

public Path getClasspath()
Sets the classpath of libraries to include in the mop exercies. This is the list of all jars containing persistence capable classes that are referenced by the classes defined in src directory. Note the jar files must not be compressed!


createClasspath

public Path createClasspath()
Sets the classpath of libraries to include in the mop exercies. This is the list of all jars containing persistence capable classes that are referenced by the classes defined in src directory. Note the jar files must not be compressed!


setClasspathRef

public void setClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere.


setGoodshome

public void setGoodshome(java.io.File _goodsHome)
The path where goods is installed on the system.


execute

public void execute()
             throws BuildException
BuildException
See Also:
org.apache.tools.ant.Task#execute()