IServiceStarter

The IServiceStarter interface is used to define a starting point for the classes in a JAVA package. In addition, the class that implements this interface is usually the only class in a package that is not package private. This means that all other classes are hidden in the package.

The interface is registered to the service registry as a starter. It defines a list of dependencies that the classes in the package have. If the dependencies are fulfilled, that means if all required interfaces have been started in the service registry, then this package will also be started. Conversely, the package will be stopped should a required service be stopped in the registry.

The interface offers 3 methods.

The dependencies

The following method fills a list with dependencies of the package.

void getDependencies(@NotNull IServiceDependencyList aDependencyList);

An implementation might look like this:

public void addDependencies(@NotNull final IServiceDependencyList aDependencyList)
{
    aDependencyList.add(INameDb.class);
    aDependencyList.add(IMessageSender.class);
    aDependencyList.add(INamespace.class,
                        "nid=SYSTEM");
}

Here the singletons INameDb and IMessageSender are required. Additionally, a namespace with the property "nid=SYSTEM" is required, which is the system namespace. Namespaces are therefore not singletons. For the distinction they define a property nid (= namespace ID).

Start of a Package

This method is used to start the package by the system. At this point, all dependencies are registered in the service registry.

void start(@NotNull IServiceRegistry aServiceRegistry) throws Exception;

Stop of a Package

This method is used to stop the package by the system. The method is called when a dependency is removed from the service registry.

void stop(@NotNull IServiceRegistry aServiceRegistry) throws Exception;

nyssr.net - Innovative Distributed System