Speedo user manual: Enhancement step

 FinalLogo.jpg
 FinalLogo.jpg

Speedo heavily relies on byte code enhancement as proposed by most of the JDO implementation. Furthermore, it provides its own enhancer mainly for optimization purpose:

Then to enhance persistent classes, Speedo provides an Ant task that allows the enhancement of persistent classes as well as persistent aware classes (i.e., classes that directly access public persistent variables of a persistent class). The first part of this chapter describes how to use/configure the Ant task in build files. The second chapter explains how to use the Eclipse plugin for Speedo, which aims at automating the enhancement process in the overall build process of an Eclipse project.

  1. The Speedo Ant Task
  2. The Speedo Eclipse Plugin

Back to the Speedo documentation



  1. The Speedo Ant Task
  2. Description

    The provided Ant task is used in order to enhance the persistent classes and the persistent aware classes of a Java application that uses the JDO persistence model. This task defines an enhancement target that can be either a directory or an archive file containing the .class files that need to be enhanced (persistent classes and/or persistent aware classes). It also usually requires XML descriptor files that define the classes and the information related to the way they should persist that need to be considered by the enhancer: for instance, this can be .jdo files or persistence.xml files.

    Parameters

    Attribute Description Required
    confFile This is the configuration file of the Speedo enhancer. Usually this file is the speedo-jdo.properties provided in the distribution. It permits to specify the mapper corresponding to the data support. It is not required, because the default mapper is for the relational database. No
    targetdir The path defining the directory where the .class files that are going to be enhanced are located. This is also the location where additional files (mainly additional classes) produced by the Speedo enhancer are written. Yes, but exclusive with targetarchive (only one of these two parameters should be defined at a time).
    targetarchive The path defining the archive that contains the .class files that are going to be enhanced are located. The archive is also complemented with additional files (mainly additional classes) produced by the Speedo enhancer are written. The directory that is considered for enhancement inside this archive is the root of the archive. Yes, but exclusive with targetdir (only one of these two parameters should be defined at a time).
    tracepersistentclass Whether to trace the persistent classes that are actually going to be enhanced. No; defaults to no.
    tracepersistentaware Whether to trace the persistent aware classes that are actually going to be enhanced. No; defaults to no.
    keepsrc Whether to keep sources of Java classes that are generated by the Speedo enhancer. No; defaults to no.
    classpathref The classpath containing Speedo and the configuration files (etc directory). No
    logPropFile The logging configuration file. It permits to choose other Monolog configuration files than the one provided in the etc directory No
    failsonerror Whether to stop the Speedo enhancer after the first error or try to continue. No; defaults to yes.
    expanddir The path of the directory within which temporary files are stored by the Speedo enhancer. It is mainly used to expand archive files in order to enhance them. Thus, it is only used when targetarchive is defined. No; defaults to the directory where the target archive is located.
    mappername The name of the JORM mapper to be used by Speedo when generating mapping classes associated with persistent classes. No; defaults to rdb (i.e., the mapper for relational databases).

    Parameters specified as nested elements


    Examples

    The following example comes from the examples:

    <property name="src" value="${basedir}/src"/>
    <property name="build" value="${basedir}/build"/>
    <property name="speedoDist" value="${basedir}/../.."/>
    ...
    <path id="classpath">
    <pathelement location="${speedoDist}/etc"/>
    <pathelement location="${build}"/>
    <fileset dir="${speedoDist}">
    <include name="speedo-jdo.jar"/>
    <include name="lib/log/log4j.jar"/>
    > <include name="lib/jdbc/postgres_jdbc2.jar"/>
    </fileset>
    </path>
    ...
    <taskdef resource="speedo-jdo.tasks" />
    ...
    <target="generation">
    <delete dir="${build}"/>
    <mkdir dir="${build}"/>
    <javac srcdir="${src}" destdir="${build}" debug="on">
    <classpath refid="classpath"/>
    <include name="**/*.java"/>
    </javac>
    <speedo-jdo src="${src}" output="${build}" classpathref="classpath"/>


  3. The Speedo Eclipse Plugin
  4. Speedo is now compatible with the EclipseJDO plugin. With this plugin you can edit the .jdo files and enhance your persistent classes. To use Speedo with the eclipseJDO plugin, you have to add the plugin org.objectweb.speedo.eclipsejdo in Eclipse. This plugin integrate the speedo-jdo.jar librairy of Speedo. Then if you want to change the Speedo version you simply have to update the speedo-jdo.jar file in the plugin.