Overview
Installation
VTL reference
Configuration
Java reference
Velosurf FAQ

Java Reference

Defining custom entity classes

You can easily use a custom instance class for an entity.

Just inherit your class from velosurf.context.Instance and specify its full qualified name in the 'class' attribute of the target entity in the configuration file.

Please note that this class must provide the same constructor than velosurf.context.Instance, that is:
public MyCustomInstance(Entity inEntity)
(and of course call super(inEntity) from within it).

Standalone usage

If you are not using the velocity-tools project, you can easily populate a Velocity context with a code as simple as this one:

import org.apache.velocity.Context;
import velosurf.standalone.Velosurf;
[...]

context.put("db",new Velosurf());

Some remarks, thought:

  • You should initialize Velosurf Logger if you want to log to somewhere else than System.err.
  • You must ensure that Velosurf will find its configuration file (velosurf.xml), according to this documentation.

Alternatively, you can handle yourself the initialization process:

    import velosurf.context.DBReference;
    import velosurf.sql.DBConnection;
    [...]
    // static initialisation (do it once)
    InputStream is = inServletContext.getResourceAsStream("./path/to/velosurf.xml");
    DBConnection connection = DBConnection.getInstance(is);
    [...]
    // context initialisation (for each new context)
    DBReference db = new DBReference(connection);
    context.put("db",db);

Javadoc

You can build the javadoc using the 'javadoc' ant target.

Using Velosurf from within Java

Velosurf can be used from Java as easily as from VTL.

It can be more convenient than using the jdbc classes and methods, especially if you want to re-use from Java the attributes you have defined in velosurf.xml.