Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

An instance starts and stops in the invalid state.

<IMAGE>Image Added

Lifecycle callback

This handler supports two kinds of callback. The INVALID=>VALID callback are invoked when the instance becomes valid (at starting or when an event allows the instance to become valid). The VALID=>INVALID callback are invoked when the instance becomes invalid (at stopping or when an event invalids the instance).

Image Added

<IMAGE>Image Added

An example

Let's take an example. The following class requires a FooService and has two lifecycle callback start and stop.

Code Block
public class Foo {
              FooService fs;              
              private void start() {
                       // Starting method
                       //...
                       fs.foo();
                       //...
                }                              
                protected void stop() {
                        // Stopping method
			if(fs!=null) { fs.foo(); }
                }
}

...

An instance of an immediate component type is instantiated as soon it becomes valid. It means that, when the instance becomes valid, the constructor of the implementation class is called. This can replace the INVALID=>VALID callback.

<IMAGE>Image Added

However as there is no destructor in Java, the VALID=>INVALID callback is necessary if some actions are needed when stopping.

...