SOCKET

Sunday Jun 04, 2006

Writing new tools for Bodington

I've written a couple of tools for Bodington - the Peer Marker and the SOCKET Link. I thought it might be useful to document how this is done because as far as I'm aware it is not documented anywhere else. The easiest way to write a new tool is to download the latest Bodington code from Sourceforge and copy/edit the code for an existing tool. Each tool has the following components:

    A unique tool ID number.
    A tool class that extends org.bodington.server.resources.Resource. This class contains get/set methods for the tool's properties and also methods that allow the tool object to be retrieved from the database using various keys.
    A session interface that extends org.bodington.server.BuildingSession. This interface specifies methods that represent a user's session with a specific tool.
    A session class that implements the session interface.
    A facility class that extends org.bodington.servlet.facilities.Facility. This class implements the user interface using the tool's templates. All input/output code is confined to this class.
    An SQL script that is used to create the table and fields needed to store persistent information about the tool.
    A set of resources that contain the localised strings for the code and templates
    A set of HTML and/or XHTML templates containing tags which will be replaced by interactive content generated by the methods in the facility class.
The SQL script is written in the dialect of Microsoft SQL Server. It will be automatically translated into the dialect of other supported database manager products if necessary. In addition to creating the tool's table, it must register the tool's ID, table name and tool class by recording them in the Bodington CLASSES table. It must also record in the Bodington FIELDS table, the name of each field in the tool class that is to be recorded in the database, together with the names of its get/set methods and the types that the methods expect/return. Be VERY careful about specifying the primary key. This is one of the fields in the FIELDS table. Get it wrong and you will produce a bug that is almost impossible to debug. (I speak from bitter experience.) Having written the classes, interface, SQL script, resources and templates, you then need to integrate them into Bodington. This is done as follows:
    Add the sql script to the String[] array tables_sql_in_order in org.bodington.installation.Installer.java. The first entry should be the name of the tool's table and the second should be the full path to the SQL script.
    Add the tool ID to the list at the beginning of Resource.java
    Add the tool ID to the list in the method Resource.mapHttpFacilityNoToResourceType()
    Add the tool ID to the list in the method Resource.getResourceTypeName()
    Add the tool's nickname to the comma-separated list in bodington-defaults.properties. The nickname should be the same as the name of the directory containing the tool's templates.
    Add an entry to bodington-defaults.properties of the form: bodington.facility.<tool nickname> = <tool facility class>
    Add an entry to org.bodington.server.resources.ResourceTypeNames.properties
    Create create_tool.html and confirmcreate_tool.html templates in the style_default/default directory
    Add a section to the creationmenu.html in the appropriate template directories so that the option to create your tool appears in the list of tools.
Now recompile Bodington and test your tool. (It is probably best to generate a quickstart war for this testing process.)

Comments:

Aggie,

Couple of comments:
1/ this would be good to go in the wiki as a guide to wriiting new tools, I've put a link to your blog, but other people may like to chip in with comments
2/ You should point out that the logbook is a good example of a tool - it is in its own package
3/ You could also point out about the shift to JSP's

adam

Posted by adam m on June 08, 2006 at 03:32 PM BST #

Post a Comment:
Comments are closed for this entry.

Calendar

Feeds

Search

Links

Navigation

Referers