AutoArchive._infrastructure.service

Support framework for registering and accessing services.

Modules

iservice_component

IServiceComponent interface.

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

Bases: object

Interface for service components.

Parameters:
  • serviceAccessor (IServiceAccessor) – Can be used to get/register services.

  • applicationContext (ApplicationContext) – Application context.

abstractmethod destroyServices()[source]

Destroys all services owned by this component.

iservice

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

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[source]

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)[source]

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[source]

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][source]
registerService(serviceIdentification: type[__ISI], providerClass: type[IService], providerIdentification: str = None)[source]

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])[source]

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.