Interface RdiServiceContainer


  • public interface RdiServiceContainer
    Service container that is capable of managing services in a reactive fashion. Services are initialized at subscription time, and instances may or may not be cached for subsequent accesses depending on the provided configuration. The container is able to execute the dependency resolution and injection when a service requiring dependencies is requested. It is also in charge of checking for circular dependencies and infinite instantiation loops.
    See Also:
    create(RdiConfig)
    • Method Detail

      • getService

        <S> reactor.core.publisher.Mono<S> getService​(ServiceReference<S> serviceRef)
        Gets the service for the given reference. Dependency injection is performed upon subscribing to the returned Mono. Given that no errors happen, the returned Mono is guaranteed to emit the service with all dependencies properly injected. Subscribing multiple times may either return a new instance each time or a singleton, depending on how the service was configured. In the latter case, the singleton creation is safe to trigger by concurrent subscriptions to the mono.
        Type Parameters:
        S - the type of service
        Parameters:
        serviceRef - the service reference
        Returns:
        a Mono emitting the Service instance. If the instantiation of the service fails, it will error with ServiceInstantiationException. If a circular dependency is found when injecting setter dependencies, it will error with RdiException.
      • hasService

        boolean hasService​(ServiceReference<?> serviceRef)
        Checks if this container contains a service with the given reference. It does not check whether the service is initialized or not, it only checks for its existence in the configuration.
        Parameters:
        serviceRef - the reference to test
        Returns:
        true if present, else false