Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
6.0.0.Alpha4
-
None
Description
Capabilities provided by service are installed with org.jboss.as.controller.CapabilityServiceTarget#addCapability that uses the deprecated org.jboss.msc.service.Service API.
It is not possible to provide a capability provided by the new org.jboss.msc.Service API.
In particular, there is a chicken and egg issue between org.jboss.as.controller.CapabilityServiceTarget#addCapability that needs an instance of the service(and returns a CapabilityServiceBuilder) and org.jboss.msc.service.ServiceBuilder#provides that creates a Consumer instance to pass to the service instance before this one is set with org.jboss.msc.service.ServiceBuilder#setInstance.
new workflow should be:
CapabilityServiceBuilder serviceBuilder = context.getCapabilityServiceTarget().addCapability(CAP_NAME);
Consumer<MyValue> consumer = serviceBuilder.provides(CAP_NAME);
Service myService = new MyService(consumer);
serviceBuilder.setInstance(myService)
.install();