use of io.zeebe.servicecontainer.Injector in project zeebe by zeebe-io.
the class EmbeddedBrokerRule method getService.
public <S> S getService(ServiceName<S> serviceName) {
final ServiceContainer serviceContainer = broker.getBrokerContext().getServiceContainer();
final Injector<S> injector = new Injector<>();
final ServiceName<Object> accessorServiceName = ServiceName.newServiceName("serviceAccess" + serviceName.getName(), Object.class);
try {
serviceContainer.createService(accessorServiceName, new NoneService()).dependency(serviceName, injector).install().get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
serviceContainer.removeService(accessorServiceName);
return injector.getValue();
}
Aggregations