Component Development References

Created by Chris Greenhalgh 2005-04-22
Last update by Stefan Rennick Egglestone 2006-06-21

Introduction
Component creation
Component destruction
Components with two-stage lifecycles
ECT-aware components
Available datatypes for properties
Developing factory components
Dynamic properties

Introduction

This document gives additional details about developing new ECT components that were not included in the simple Developing new components for ECT document, which you should read first.

Component creation

All components must have a public no-args constructor, which will be used to create instances. This should leave the component in a usable state.

Component destruction

If the component makes use of resources that need to be released (e.g. if it has opened a window or is controlling a COM port), then it must implement a method with signature public void stop() which will be called by the ECT system when the component needs to be destroyed for some reason (eg a user has requested the destruction of a component, or ECT is being shutdown)

Components with two-stage lifecycles

When writing components to control physical devices, it is common for these components to have a two-stage lifecycle

If this is the case for your component, then any properties associated with gathering configuration to perform stage one should have names starting with the string config (eg configPortNumber), and should provide a boolean-typed property called configured which a user should set to true to indicate that they have provided sufficient configuration for the component to attempt to establish a connection. This is because ECT can save and recreate component states to a file, and when recreating such states, it has to know if some property values should be recreated first in order to trigger a reconnection to a device.

See equip.ect.components.phidgets.PhidgetInterfaceKit for an example of a component that has a two-stage lifecycle.

ECT-aware components

If a component wishes to interact directly with ECT or the installation dataspace, or to be aware of property link requests applied to it, then it can implement the interface equip.ect.IActiveComponent. When created the initialise method will be calling, giving the component a reference to the container installation dataspace client and the container manager.

Additional methods are also called when the component is linked to or is about to be updated because of a link. This is used e.g. in the dictionaryarraymerge component to merge incoming values (this may become default behaviour for array-type properties in the future).

Available datatypes for properties

The available datatypes for a component property are constrained. In particular, you can use:

It should be noted that DictionaryImpl is similar to a hashtable, (eg it stores a set of key->value mappings) and can be used to construct a structured data value. See equip.ect.components.email.EmailReceiver

Developing factory components

It is possible to develop ECT components that can construct and destroy other components. These are referred to as factory components, and the components that they create are referred to as subcomponents. Factory components might be useful if you wish to be able to automatically construct a component to interface to a particular hardware device when your system detects that such a device has just been plugged in (eg create new web-cam component when new web-cam is plugged into a system).

To see an example of a factory component, take a look at source files in package equip.ect.components.subcomponenttest

Dynamic Properties

In some situations, it may be necessary to develop a component that can have a varying number of properties. For example, on connection to a device with multiple physical ports, a component might construct one property to represent each port. To do this in ECT, you should develop a component implementing the equip.ect.DynamicProperties interface, perhaps making use of the equip.ect.DynamicPropertiesSupport class. This interface provides you with methods to dynamically add and remove properties of all types. See the equip.ect.components.dynamicbsh.DynamicBeanShell component for an example of a component making use of dynamic properties.