A Strolch agent can be easily extended with arbitrary components. An agent is basically a container for classes extending StrolchComponent. Theses classes mostly implement an interface which describes the operations that are supported by the component.

The following represents a list of the most used components:

A component has a life-cycle, which is governed by the Agent's own life-cycle. The life-cycle is as follows:

    setup -> initialize -> start <-> stop -> destroy

The setup step is used to instantiate the component, the initialize step is used to validate configuration parameters, and the run step is used to start the component, i.e. start threads, etc. The stop step stops these threads and also allows the component to be started again. The destroy step destroys the instance and makes it unusable anymore, i.e. shutdown of the agent.

Each component has its own configuration parameters. A component is registered in the StrolchConfiguration.xml file with a

The dependencies is an important feature as the dependencies of a component are always started before the actual component.

By example of the MailHandler we shall show how a strolch component would be implemented.

First define an interface:

    public interface MailHandler {
      public void sendMail(String subject, String text, String recipient);

Then implement a concrete MailHandler:

public class SmtpMailHandler extends StrolchComponent implements MailHandler {

  // instance fields with configuration properties to send the mail

  public SmtpMailHandler(ComponentContainer container, String componentName) {
    super(container, componentName);

  public void initialize(ComponentConfiguration configuration) throws Exception {

    // store any properties needed from the configuration


  public void sendMail(String subject, String text, String recipient) {

    // send the e-mail using SMTP, or store in stack to send by thread

Now that the component is written, it must be registered on the component, so that it is loaded when the agent is started. For this the StrolchConfiguration.xml file must be modified to include a component element:

  <env id="dev">

Now when the agent is started, the component can be retrieved and used. E.g from inside a Service:

MailHandler mailHandler = getComponent(MailHandler.class);
mailHandler.sendMail("My Subject", "Hello World", "test@test.ch");