AutoArchive._infrastructure.service — AutoArchive Developer Manual (ver. 2.1.0.dev20260309)

# AutoArchive._infrastructure.service

Support framework for registering and accessing services.

## Modules

### iservice_component

`IServiceComponent` interface.

class AutoArchive._infrastructure.service.iservice_component.IServiceComponent(applicationContext, serviceAccessor)

  Bases: `object`

  Interface for service components.

  Parameters:

    - serviceAccessor (`IServiceAccessor`) – Can be used to get/register services.

    - applicationContext (`ApplicationContext`) – Application context.

  abstractmethod destroyServices()

    Destroys all services owned by this component.

### iservice

class AutoArchive._infrastructure.service.iservice.IService(wokDir: str = None)

  Bases: `object`

  Interface for component’s services.

  See also: `ServiceAccessor`.

  Parameters:

    workDir – Path to a writable directory which shall be used as a persistent storage.

### iservice_identification

`IServiceIdentification` interface.

class AutoArchive._infrastructure.service.iservice_identification.IServiceIdentification

  Bases: `object`

  Identifies a service.

  Note

  Implementations should be static classes.

  abstract property interface: type

    Gets interface type of the service.

    Return type:

      `type{``object``}`

### _service_accessor

class AutoArchive._infrastructure.service._service_accessor.ServiceAccessor(workDir: str)

  Bases: `object`

  Access to services.

  A service can be made available by registering via this interface. Registered classes has to implement `IService`.

  Parameters:

    workDir – Path to a writable directory which shall be used as a persistent storage.

  getOrCreateService(serviceIdentification: type[IServiceIdentification], providerIdentification: str | None) → IService

    Provides access to registered services interfaces.

    See also: `registerInterface()`.

    Parameters:

      - serviceIdentification (`IServiceIdentification`) – Identification of the service that shall be created.

      - providerIdentification (`str`) – Service provider identification under which it was registered. For services with single provider which were registered with service provider identification `None` it shall be `None`.

    Returns:

      Instance of a service provider of the particular service.

    Return type:

      `serviceIdentification.interface`

    Raises:

      KeyError – If `serviceIdentification` is not registered.

  getOrCreateServices(serviceIdentification: type[IServiceIdentification]) → Iterator[IService]
  getProviderIdentification(serviceIdentification: type[IServiceIdentification], providerClass: type[IService]) → str

    Returns identification of a service provider represented by `providerClass`.

  registerService(serviceIdentification: type[__ISI], providerClass: type[IService], providerIdentification: str = None)

    Registers a service.

    See also: `unregisterService()`, `getOrCreateService()`.

    Parameters:

      - serviceIdentification (`IServiceIdentification`) – Identification of the service that shall be registered.

      - providerClass (`type{` `serviceIdentification.interface`, `IService``}`) – Provider of the service.

      - providerIdentification (`serviceIdentification.providerIdentificationInterface`) – Corresponding service provider identification object.

    Raises:

      - TypeError – If `providerClass` does not implement `serviceIdentification.interface`. If `providerIdentification` does not implement `serviceIdentification.providerIdentificationInterface`.

      - KeyError – If `serviceIdentification` is already registered with `providerClass` or `providerIdentification`.

  unregisterService(serviceIdentification: type[IServiceIdentification])

    Unregisters a service with all its providers.

    All serviceType instances all destroyed first.

    See also: `registerService()`, `getOrCreateService()`.

    Parameters:

      serviceIdentification (`IServiceIdentification`) – Identification of the service that shall be registered.

    Raises:

      KeyError – If `serviceIdentification` is not registered.