Class OSGiContext

  • All Implemented Interfaces:
    ServiceContext

    @ParametersAreNonnullByDefault
    public class OSGiContext
    extends Object
    implements ServiceContext
    A ServiceContext able to retrieve OSGi Declarative Services from a BundleContext. NOTE: This context is automatically loaded and configured when this bundle is starting under an OSGi environment.
    • Constructor Detail

      • OSGiContext

        public OSGiContext()
    • Method Detail

      • getServices

        @Nonnull
        public <S> Stream<ServiceDefinition<S>> getServices​(Class<S> type)
        Description copied from interface: ServiceContext
        Retrieves all registered services of the specified type.
        Specified by:
        getServices in interface ServiceContext
        Parameters:
        type - the type of services to look for
        Returns:
        a parallel stream of all registered services of the specified type
      • getServices

        @Nonnull
        public <T> Stream<ServiceDefinition<T>> getServices​(Class<T> type,
                                                            @Nullable
                                                            String filter)
        Retrieves all registered services of the specified type.
        Parameters:
        type - the type of services to look for
        filter - the filter to determine if a service should be returned
        Returns:
        a parallel stream of all registered services of the specified type