evcgen 0.0.10

A source code generator which generates java classes and XML schemes from an XML description of a class (including "since" and "deprecated" tags). The classes are backward compatible with all older versions. The main purpose of this is to allow the modification of a distributed application (without modifying all clients at the same time). Since the interface of older clients remains compatible you can track the versions of clients still in use and keep your business logic compatible with older releases.

Another frequently suggested way to prevent versioning problems is to use a common class repository for RMI and load required classes from this repository. In my opinion this creates an unncessary dependency for the runtime environment of your application and may break the application if the repository is modified or simply not available. If the application on the other side is not under your control the situation is even worse.

With evcgen you can nicely fold different versions of an interface specification into a single code base and you have a computer readable documentation for new or deprecated fields or methods at the same time. Distributing the xml specifications of you interface allows your peers to understand modifications of your interface much better than distributing (e.g.) a javadoc with "deprecated" tags.

future enhancements

intended network formats

sourceforge project page

related projects

download

format example

<?xml version="1.0" encoding="UTF-8"?>
<evcgen version="0" name="test">
  <group package="test.hello" super="java.lang.Object">
    <class name="AnotherClass" version="3.1.4" remote="true">
      <comment>A test class.</comment>
      <interface name="java.util.EventListener"/>
      <method name="test" result="int" since="0.0" until="2.0">
            <param name="all" type="boolean"/>
	    <exception type="java.lang.IllegalStateException"/>
      </method>
      <method name="flush"/>
      <field name="foo" type="int2" since="0.0" until="2.0">
            <comment>A 2-byte integer, a short in Java.</comment>
      </field>
      <field name="bar" type="int4" since="0.0" until="2.0">
            <comment>A 4-byte integer, an int in Java.</comment>
      </field>
      <field name="baz" type="int8" since="0.0" until="2.0">
            <comment>A 8-byte integer, a long in Java.</comment>
      </field>
      <field name="bonk" type="String" since="0.0" until="2.0">
            <comment>A character string, encoded in a modified UTF8 format.</comment>
      </field>
      <field name="oif" type="double" since="0.0" until="2.0">
            <comment>A 8-byte float, a double in Java.</comment>
      </field>
    </class>
  </group>
</evcgen>

/* generated by evcgen 0.0.9 */

package test.hello;

import java.lang.IllegalStateException;
import jp2.evcgen.AbstractDatatype;
import jp2.evcgen.Version;

/** A test class.
 */
public class AnotherClass extends AbstractDatatype
{

    /** A 2-byte integer, a short in Java.
     */
    short foo;

    /** A 4-byte integer, an int in Java.
     */
    int bar;

    /** A 8-byte integer, a long in Java.
     */
    long baz;

    /** A character string, encoded in a modified UTF8 format.
     */
    String bonk;

    /** A 8-byte float, a double in Java.
     */
    double oif;

    public void writeExternal (ObjectOutput out) throws IOException
    {
        out.writeByte (1)
        out.writeByte (3);
        out.writeByte (1);
        out.writeByte (4);
        out.writeShort (foo);
        out.writeInt (bar);
        out.writeLong (baz);
        out.writeUTF (bonk);
        out.writeDouble (oif);
    }

    public void readExternal (ObjectInput in) throws IOException, ClassNotFoundException
    {
        byte format = out.readByte ();
        byte major  = out.readByte ();
        byte minor  = out.readByte ();
        byte patch  = out.readByte ();
        Version v = new Version (major, minor, patch)
        foo =  in.readShort ();
        bar =  in.readInt ();
        baz =  in.readLong ();
        bonk =  in.readUTF ();
        oif =  in.readDouble ();
    }

    int test (boolean all) throws 
            IllegalStateException
    {
    }

    void flush () {
    }

}

credits

Author: Bernhard Fastenrath
SourceForge.net Logo