Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-7226

Add convenience ServiceInstaller.Builder.provides(...) methods accepting ServiceDescriptors

XMLWordPrintable

      When creating a ServiceInstaller (for non-capability use cases), there is only a single Builder.provides(...) accepting a ServiceName.
      For those services described via a ServiceDescriptor, we should add provides(...) methods variants, which adds the benefit of compile-time type checking.
      e.g. the following compiles fine, but would fail when trying to consume this service since the service produces a type not expected by the service descriptor:
      UnaryServiceDescriptor<T> descriptor = ...;
      Supplier<V> factory = ...;
      ServiceInstaller.builder(factory)
      .provides(ServiceNameFactory.resolveServiceName(descriptor, "foo"))
      .build()
      .install(target);

      With the addition of ServiceDescriptor-based provides(...) methods, the following would fail to compile, since the provided service descriptor does not match the type of our factory, unless V extends T:
      UnaryServiceDescriptor<T> descriptor = ...;
      Supplier<V> factory = ...;
      ServiceInstaller.builder(factory)
      .provides(descriptor, "foo")
      .build()
      .install(target);

              pferraro@redhat.com Paul Ferraro
              pferraro@redhat.com Paul Ferraro
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: