Class TwoPhaseBootstrap<T extends ADEPT2Service>

Type Parameters:
T - The type of the initial service which is provided after the first phase of bootstrapping.
All Implemented Interfaces:
GlobalInvocationResolver, GlobalRegistryServiceProvider, ConfMgrRegistry, ADEPT2Service, AuthenticatingService, LogService, NameResolution, ServiceThreadHandling

public class TwoPhaseBootstrap<T extends ADEPT2Service> extends BootstrapRegistry
A bootstrap registry that bootstraps and shuts down in two phases. First the registry is only bootstrapped to retrieve the initial service provided in the constructor. Afterwards the second phase of bootstrapping may continue at any time. Note that the second phase is required before accessing the registry.
The first phase just starts the initial service as well as its required services. Note that the registry cannot be accessed in the first phase since it is not (completely) started. So only basic services may be started in the first phase.
Shutting down may also consist of two inverse phases by using shutdownToInitialService() and BootstrapRegistry.shutdown(boolean). Shutting down may also be done in one step by just calling BootstrapRegistry.shutdown(boolean). Be sure to call BootstrapRegistry.shutdown(boolean) in a finally-clause so that it will be done under all circumstances.

If no initial service is provided, this registry will just act like the BootstrapRegistry, that is first and second phase will be one phase.

  • Field Details

    • initialServiceCls

      protected final Class<T extends ADEPT2Service> initialServiceCls
      The class of the initial service.
    • initialServiceType

      protected final String initialServiceType
      The type name of the initial service.
  • Constructor Details

    • TwoPhaseBootstrap

      public TwoPhaseBootstrap(Class<T> initialServiceCls, String initialServiceType, UrlConfigurationManager confMgr, Class<? extends BootstrapRegistry> bootstrapClass) throws AbortServiceException
      Creates a new bootstrap registry having the designated configuration manager. Before creating the registry, the root configuration will be validated against the designated class. If an initial service is provided (via its class and component type name), this registry bootstraps in two phases. In the first phase only the initial service will be retrieved. This will start all services required by the initial service but not the registry itself.
      Parameters:
      initialServiceCls - The class of the initial service. If this is null, this registry will act like the normal BootstrapRegistry.
      initialServiceType - The type name of the initial service. If this is null or the empty string, this registry will act like the normal BootstrapRegistry.
      confMgr - The initial configuration manager that provides the root configuration and configurations for the loaded component instances.
      bootstrapClass - The class the root configuration is validated against the configuration description. Use this class unless you have a subclass that has its own configuration description.
      Throws:
      AbortServiceException - If the initialisation or starting of the registry fails, an AbortServiceException will be thrown. If the registry configuration is invalid, a ConfigurationExceptionwill be thrown.
  • Method Details

    • autoStartServices

      protected void autoStartServices() throws AbortServiceException
      Description copied from class: LocalServiceRegistry
      Prepares the global security manager, authenticates this registry, provides the data sources for the runtime configurations to the configuration manager if appropriate, and starts all services to be automatically started at startup of this registry.
      Overrides:
      autoStartServices in class ServiceRegistry
      Throws:
      AbortServiceException - If there are problems preparing the security manager or starting one of the services to be automatically started, an AbortServiceException will be thrown.
    • getInitialService

      protected T getInitialService()
      Gets the initial service that is provided in the first phase of bootstrapping.
      Returns:
      The initial service that is provided in the first phase of bootstrapping or null if no initial service is specified.
    • bootstrap

      protected void bootstrap() throws AbortServiceException
      Description copied from class: BootstrapRegistry
      Bootstraps this registry and therefore the platform. The registry is initialised with either the configured URI or a local URI with the instance name. Afterwards the registry is started.
      Overrides:
      bootstrap in class BootstrapRegistry
      Throws:
      AbortServiceException - If the initialisation or starting of the registry fails, an AbortServiceException will be thrown.
    • continueBootstrap

      protected GlobalRegistry continueBootstrap() throws AbortServiceException
      Continues the bootstrap. This will autostart the services of the superclass.
      Returns:
      The global registry which provides access to public services.
      Throws:
      AbortServiceException - If there are problems preparing the security manager or starting one of the services to be automatically started, an AbortServiceException will be thrown.
      See Also:
    • shutdownToInitialService

      public void shutdownToInitialService()
      Shuts down all services until the initial service. This can then be used before shutting down completely.