Interface ServiceFactory<ExpectedServiceType>

A factory for creating services.

A service factory is a way to create different service instances for different bundles. For this instead of registering a service instance register a ServiceFactory implementation.

interface ServiceFactory<
    ExpectedServiceType extends ServiceInstance = ServiceInstance,
> {
    getService(
        bundle: Bundle,
        registration: ServiceRegistration,
    ): ExpectedServiceType;
    isServiceCreated(
        bundle: Bundle,
        registration: ServiceRegistration,
    ): boolean;
    ungetService(
        bundle: Bundle,
        registration: ServiceRegistration,
        instance: ExpectedServiceType,
    ): void;
}

Type Parameters

Methods

  • Returns true if a service has already been created, or false otherwise.

    Parameters

    • bundle: Bundle

      The bundle which like to use the service.

    • registration: ServiceRegistration

      The service registration information.

    Returns boolean