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:
objectInterface for service components.
- Parameters
serviceAccessor (
IServiceAccessor) – Can be used to get/register services.applicationContext (
ApplicationContext) – Application context.
iservice¶
IService interface.
- class AutoArchive._infrastructure.service.iservice.IService[source]¶
Bases:
objectInterface for component’s services.
See also:
ServiceAccessor.
iservice_identification¶
IServiceIdentification interface.
- class AutoArchive._infrastructure.service.iservice_identification.IServiceIdentification[source]¶
Bases:
objectIdentifies a service.
Note
Implementations should be static classes.
- abstract property interface¶
Gets interface type of the service.
- Return type
type{``object}
- abstract property providerIdentificationInterface¶
Gets interface type for accessing information about providers of this service.
- Return type
type{``object}
_service_accessor¶
- class AutoArchive._infrastructure.service._service_accessor.ServiceAccessor[source]¶
Bases:
objectAccess to services.
A service can be made available by registering via this interface. Registered classes has to implement
IService.- getOrCreateService(serviceIdentification, providerIdentification, *args)[source]¶
Provides access to registered services interfaces.
See also:
registerInterface().- Parameters
serviceIdentification (
IServiceIdentification) – Identification of the service that shall be created.providerIdentification (
serviceIdentification.providerIdentificationInterface) – Corresponding service provider identification object. It should be one of the instances returned bygetProvidersIdentifications(). For services with a single provider (implementation) it can beNone.args – Service specific arguments.
- Returns
Instance of a service provider of the particular service.
- Return type
serviceIdentification.interface- Raises
KeyError – If
serviceIdentificationis not registered.
- getProvidersIdentifications(serviceIdentification)[source]¶
Returns providers identifications for the given service.
- Parameters
serviceIdentification (
IServiceIdentification) – Identification of the service.- Returns
Service providers.
- Return type
iterable<serviceIdentification.providerIdentificationInterface>- Raises
KeyError – If
serviceIdentificationis not registered.
- registerService(serviceIdentification, providerClass, providerIdentification=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
providerClassdoes not implementserviceIdentification.interface. IfproviderIdentificationdoes not implementserviceIdentification.providerIdentificationInterface.KeyError – If
serviceIdentificationis already registered withproviderClassorproviderIdentification.
- unregisterService(serviceIdentification)[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
serviceIdentificationis not registered.