-
Enhancement
-
Resolution: Done
-
Major
-
28.0.0.Final
-
None
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);