Class NanoServices<T extends NanoServices<T>>

Type Parameters:
T - The type of the NanoServices implementation, used for method chaining.
Direct Known Subclasses:
Nano

public abstract class NanoServices<T extends NanoServices<T>> extends NanoThreads<T>
The abstract base class for Nano framework providing Service handling functionalities.
  • Field Details

  • Constructor Details

    • NanoServices

      protected NanoServices(Map<Object,Object> config, String... args)
      Initializes NanoServices with configurations and command-line arguments.
      Parameters:
      config - Configuration parameters for the NanoServices instance.
      args - Command-line arguments passed during the application start.
  • Method Details

    • service

      public <S extends Service> S service(Class<S> serviceClass)
      Retrieves a Service of a specified type.
      Type Parameters:
      S - The type of the service to retrieve, which extends Service.
      Parameters:
      serviceClass - The class of the Service to retrieve.
      Returns:
      The first instance of the specified Service, or null if not found.
    • services

      public <S extends Service> List<S> services(Class<S> serviceClass)
      Retrieves a list of services of a specified type.
      Type Parameters:
      S - The type of the service to retrieve, which extends Service.
      Parameters:
      serviceClass - The class of the service to retrieve.
      Returns:
      A list of services of the specified type. If no services of this type are found, an empty list is returned.
    • services

      public List<Service> services()
      Provides an unmodifiable list of all registered Service.
      Returns:
      An unmodifiable list of Service instances.
    • shutdownServices

      protected void shutdownServices(Context context)
      Shuts down all registered Service gracefully.
      Parameters:
      context - The Context in which the services are shut down.
    • registerService

      protected T registerService(Service service)
      Registers a new service in the Nano framework.
      Parameters:
      service - The Service to register.
      Returns:
      Self for chaining
    • unregisterService

      protected T unregisterService(Context context, Service service)
      Unregisters a Service from the Nano framework and stops it.
      Parameters:
      context - The Context in which the Service is unregistered and stopped.
      service - The Service to unregister and stop.
      Returns:
      Self for chaining