Fork me on GitHub

Incarnation

The incarnation of a service covers the creation and configuration of a service

The following methods are invoked:

  • Constructor()
  • LogEnabled.enableLogging(Logger)
  • Contextualizable.contextualize(Context)
  • Serviceable.service(ServiceManager)
  • Configurable.configure(Configuration)
  • Parameterizable.parameterize(Parameters)
  • Initializable.initialize()
  • Executable.execute()
  • Startable.start()

The good news are that you don't have to implement all these interfaces if you have a simple service. The bad news are that you might need all of this interfaces in a complex application ... :-)

Constructor()

This doesn't come as a surprise

LogEnabled.enableLogging(Logger)

Here you get the logger for your service implementation. This is again an interface to an implementation of a logger provided by the caller of the service framework. You can skip this interface if you use org.apache.avalon.framework.logger.AbstractLogEnabled as base class for your service.

Contextualizable.contextualize(Context)

The context contains information about your application environment including the current working directory and the temporary directory. YAAFI provides you with different context entries depending on the component type, e.g. "phoenix" or "fortress".

Serviceable.service(ServiceManager)

At this point you get a reference to the ServiceManager. This is the right moment to lookup all dependent services just to make sure that everything is fine.

Configurable.configure(Configuration)

A common task is to access configuration information whereas the Configuration instance is a light-weight XML DOM tree. This means you can use nested XML files for the configuration of your service.

Parameterizable.parameterize(Parameters)

Quite frankly I'm not sure why this method is needed. The only reason I can think of is a command-line application ...

Initializable.initialize()

This method is used for initializing your service implementation since you have all your configuration information by now,

Executable.execute()

If the component implements Executable the execute method will be invoked before the component instance is exposed to any other component.

Startable.start()

The Startable interface is used by any component that is constantly running for the duration of its life. This is the method to go if you want to start a worker thread in the background.