AutoArchive._services.archiver._archiver_service_component — AutoArchive Developer Manual (ver. 2.1.0.dev20260309)

# Source code for AutoArchive._services.archiver._archiver_service_component

    # archiver_service_component.py
    #
    # Project: AutoArchive
    # License: GNU GPLv3
    #
    # Copyright (C) 2003 - 2026 Róbert Čerňanský

    from AutoArchive._infrastructure.service import IServiceComponent
    from AutoArchive._infrastructure.service._service_accessor import ServiceAccessor
    from . import ArchiverServiceProviderIDs, ArchiverServiceIdentification
    from ._external_tar_archiver_provider.external_tar_archiver_provider import ExternalTarArchiverProvider
    from ._internal_tar_archiver_provider import _InternalTarArchiverProvider

    class ArchiverServiceComponent(IServiceComponent):
        """Service component for archiver services.

        Registers service identified by :class:`.ArchiverServiceIdentification` with two providers identified
        via ArchiverServiceProviderIDs."""

        def __init__(self, applicationContext, serviceAccessor: ServiceAccessor):
            self.__serviceAccessor = serviceAccessor

            serviceAccessor.registerService(ArchiverServiceIdentification, _InternalTarArchiverProvider,
                                            ArchiverServiceProviderIDs.TarInternal)
            serviceAccessor.registerService(ArchiverServiceIdentification, ExternalTarArchiverProvider,
                                            ArchiverServiceProviderIDs.TarExternal)

        def destroyServices(self):
            "See: :meth:`IServiceComponent.destroyServices()`"

            self.__serviceAccessor.unregisterService(ArchiverServiceIdentification)