Developing new components for ECT

Initial version by Chris Greenhalgh
Most recent update by Stefan Rennick Egglestone 2005-11-15

What is an ECT component?
Developing new components


This document is a brief introduction to the process of adding a new component to ECT, which should not be too difficult if you are a competent Java developer. It assumes that you are already familiar with using ECT, and that you have experimented with a number of pre-written components.

The simplest way to start developing a new component is to obtain the source code for ECT, as this includes a number of template components that can be extended. Read the Building ECT document for instructions on how do do this. Note that source code for a particular ECT release can also be obtained by downloading the full ECT archive (rather than the webstart archive).

Knowledge of using Apache Ant is assumed in the rest of this document. This document also assumes that you are familiar with the JavaBeans concept. If not, you should read up on this. Take a look at Sun's Java Bean information pages and particularly the JavaBeans tutorial.

Once you have worked through this document, you should also read the Component reference for more detailed information about component development, and the Documentation reference for more detailed information about writing documentation for components.

Finally, the best way to learn how to develop ECT components is to look at existing examples, many of which are supplied with ECT. If you have any questions about ECT development, please join our mailing list, as we will be happy to help you resolve them.

What is an ECT component?

At its simplest, an ECT component is just a JavaBean, packaged as a JAR. To take a look at some of the beans included with ECT already, take a look in the webstart/download/java/components directory in your ECT installation - each file you find here (eg template-component.jar will contain at least one bean, and possibly more (eg template-component.jar currently contains two). If you have any pre-written java beans, you should just be able to place them into this directory, and they should become available to ECT the next time you start it. So, if you can develop a JavaBean, then you can develop an ECT component, and all you need to know is how to add such a bean into a particular installation.

In more detail, you'll notice that components in ECT normally define a number of properties. For example, the template component distributed with ECT defines a number of properties called input and output. These are implemented in the source file for the template component as pairs of methods called setInput and getInput, and setOutput and getOutput (see file /src/equip/ect/components/templates/ . When a user uses the graphical interface to modify property input, then the ECT system causes the setInput method on the corresponding component to be called, As well, if ECT ever needs to check the value of this property, is calls getInput to obtain the current propertly value.

Developing new components

Although it is possible to construct a bean outside of ECT, and then to import that bean into ECT, this approach is not recommended. For each bean, as well developing a valid class file conforming to the JavaBean spec (eg you would have to construct a BeanInfo class (eg and a manifest file (eg manifest.mft) and package all these files into the correct structure inside a JAR. This process is slightly tricky, and mistakes can be made which can slow bean development.

As an alternative, the ECT build system provides a number of tools to help with the process of constructing a bean. To a first approximation, all you have to do is write your bean source file (eg, add a new target to the ECT build file (build.xml), and if you have set things up properly, ECT will generate a valid bean info, package up your bean, and copy it to the correct installation automatically. This approach saves a lot of time and errors!

The following instructions assume that you have checked out module ect into directory <ect_home>.
  1. Make a new directory for your component under <ect_home>/ect/java/src/equip/ect/components (eg <ect_home>/ect/java/src/equip/ect/components/new_component)
  2. copy into this directory and modify it so that it does what you want it to (hint - you'll need to change the package directive inside this source file, and you might want to change the name of the file and the class defined in it)
  3. Modify build.xml so that it contains a target to build your components. You might like to copy the "template" target and modify it, as long as your component does not require any additional classpath entries. Alternatively, if you component does need additional classpath entries (eg if it depends on another jar, for example) take a look at target "phidgets". Call your new target something like new_component
  4. to build your component and to install, type the following into a command prompt:

    ant new_component
    ant install
    ant webstart

  5. run ECT, and hopefully your component will have appeared