A service reference provides access to service metadata.

interface ServiceReference {
    compareTo(that: ServiceReference): number;
    equals(that: ServiceReference): boolean;
    getBundle(): Bundle;
    getId(): number;
    getOCs(): readonly string[];
    getProperties(): ServiceProperties;
    getProperty<T = unknown>(key: string, ignoreCase?: boolean): undefined | T;
    getPropertyKeys(): readonly string[];
    getRanking(): number;
    getUsingBundles(): readonly Bundle[];
    isUnregistered(): boolean;
    ocs: readonly string[];
}

Properties

ocs: readonly string[]

The interfaces provided by this service.

Methods

  • Compares this reference to another.

    Parameters

    Returns number

    A number whose sign indicates the relative order of the two services: negative if this service is less than that service, positive if this service is greater than that service, and zero if they are equal.

  • Tests wether this reference is equal to another.

    Parameters

    Returns boolean

  • Gets the bundle which registered this service reference.

    Returns Bundle

  • The id of the service.

    Returns number

  • The interfaces provided by this service.

    Returns readonly string[]

  • Provides a single service metadata entry.

    Type Parameters

    • T = unknown

      The type of the entry.

    Parameters

    • key: string

      The key of the entry.

    • OptionalignoreCase: boolean

      If true, the key is compared case insensitive.

    Returns undefined | T

  • Gets all service metadata keys.

    Returns readonly string[]

  • The ranking of this service. If services provide the same interfaces, the ranking specifies which will be preferred. A higher ranking is preferred over a lower ranking. The default ranking value is 0. In case that that services have the same interface and the same ranking value, the service registered first is preferred.

    Returns number

  • Provides access to all bundles currently using the service.

    Returns readonly Bundle[]

  • Returns true if the service is no longer available, false otherwise.

    Returns boolean