Bundle context.

interface BundleContext {
    addBundleListener(
        listener: string | BundleEventListener,
        scope?: any,
    ): Handle;
    addFrameworkListener(
        listener: string | FrameworkEventListener,
        scope?: any,
    ): Handle;
    addServiceListener(
        filter: undefined | string,
        listener: string | ServiceEventListener,
        scope?: any,
    ): Handle;
    createFilter(filter: string | Filter): Filter;
    getBundle(): Bundle;
    getBundle(id?: number): undefined | Bundle;
    getBundleBySymbolicName(symbolicName: string): undefined | Bundle;
    getBundles(filter?: string | Filter | (b: Bundle) => boolean): Bundle[];
    getCurrentExecutionEnvironment(): readonly ExecutionEnvironmentState[];
    getExecutionEnvironment(): ExecutionEnvironment;
    getProperty<T = unknown>(name: string): undefined | T;
    getResourceURL(path: string, otherBundleName?: string): string;
    getService<T extends ServiceInstance>(
        reference: ServiceReference,
    ): undefined | T;
    getServiceReferences(
        interfaceName?: string,
        filter?: string | Filter,
    ): ServiceReference[];
    installBundle(
        location: string,
        manifest: BundleManifestJson,
        symName?: string,
    ): Bundle;
    installBundle(
        location: string,
        manifest?: undefined,
        symName?: string,
    ): Promise<Bundle>;
    isServiceCreated(reference: ServiceReference): boolean;
    isServiceUsed(reference: ServiceReference): boolean;
    registerService(
        interfaceNames: string | readonly string[],
        service: ServiceInstance,
        properties?: ServiceProperties,
    ): ServiceRegistration;
    removeBundleListener(handle: Handle): void;
    removeFrameworkListener(handle: Handle): void;
    removeServiceListener(handle: Handle): void;
    ungetService(reference: ServiceReference): boolean;
}

Methods

  • Registers a bundle event listener.

    Parameters

    • listener: string | BundleEventListener

      The listener or method name in scope.

    • Optionalscope: any

      If listener is a method name, then scope must have a method with this name.

    Returns Handle

  • Registers a framework event listener.

    Parameters

    • listener: string | FrameworkEventListener

      the listener or method name in scope.

    • Optionalscope: any

      if listener is a method name, then scope must have a method with this name.

    Returns Handle

  • Registers a service event listener.

    Parameters

    • filter: undefined | string

      Optional filter expression to reduce the events the listener will receive.

    • listener: string | ServiceEventListener

      The listener or method name in scope.

    • Optionalscope: any

      If listener is a method name, then scope must have a method with this name.

    Returns Handle

    A handle which can be used to remove the listener.

  • Creates a Filter instance from a string expression. If the filter parameter is already a Filter instance, the provided filter it is returned.

    Parameters

    • filter: string | Filter

      The expression converted to a Filter instance.

    Returns Filter

  • Gets the bundle associated with this context.

    Returns Bundle

  • Gets the bundle with the given id.

    Parameters

    • Optionalid: number

      Id of the bundle to lookup. If undefined, the bundle associated with this context is returned.

    Returns undefined | Bundle

  • Returns the bundle with the given symbolic name or undefined if no bundle could be found.

    Parameters

    • symbolicName: string

      Symbolic name of the bundle to lookup.

    Returns undefined | Bundle

  • Gets all bundles matching a given filter. If filter is undefined, all bundles are returned.

    Parameters

    • Optionalfilter: string | Filter | (b: Bundle) => boolean

      A filter to reduce the bundles returned in the result.

    Returns Bundle[]

  • Provides access to the current browser execution environment. This can be used to inspect some browser features.

    Returns ExecutionEnvironment

  • Resolves a property from the bundle. If a given property name is not specified in this bundle, this method searches framework properties for the given name. Valid property names are defined in WellknownBundleManifestEntries.

    Type Parameters

    • T = unknown

      The type of the returned property.

    Parameters

    • name: string

      The name of the property to lookup.

    Returns undefined | T

    Property value or undefined if property could not be found.

  • Creates a URL from the given path within this or another bundle.

    Parameters

    • path: string

      The path to a resource.

    • OptionalotherBundleName: string

      The name of the bundle where the resource is located (optional). If undefined, the URL is created for this bundle.

    Returns string

    A resolved URL to the given path.

  • Resolves the service instance associated with the given service reference.

    Type Parameters

    Parameters

    Returns undefined | T

    The service instance or undefined if no service could be found.

  • Finds all services matching an interface and/or a given filter. If interfaceName and filter are undefined, all registered services are returned.

    Parameters

    • OptionalinterfaceName: string

      The name of the service interface.

    • Optionalfilter: string | Filter

      reduces matching services by their properties.

    Returns ServiceReference[]

  • Dynamically installs a new bundle by providing manifest metadata.

    Parameters

    • location: string

      URL to the bundle resources.

    • manifest: BundleManifestJson

      manifest metadata.

    • OptionalsymName: string

      (symbolic) name of the bundle

    Returns Bundle

  • Dynamically installs a new bundle by fetching manifest metadata from the given location.

    Parameters

    • location: string

      URL to bundle resources.

    • Optionalmanifest: undefined

      manifest metadata.

    • OptionalsymName: string

      (symbolic) name of the bundle.

    Returns Promise<Bundle>

  • Tests if a service has at least one created instance.

    Parameters

    Returns boolean

  • Tests if a service is used by this or other bundles.

    Parameters

    Returns boolean

  • Removes a registered bundle event listener by using the provided handle.

    Parameters

    • handle: Handle

      the handle.

    Returns void

    use EventHandle.remove

  • Removes a registered framework event listener by using the provided handle.

    Parameters

    • handle: Handle

      the handle.

    Returns void

    use EventHandle.remove

  • Removes a registered service event listener through its handle.

    Parameters

    • handle: Handle

      the handle used to remove the listener.

    Returns void

    use EventHandle.remove

  • Releases a service instance.

    Parameters

    Returns boolean

    true, if service has been released successfully, false otherwise.