ServiceLoader<ProcessEngineProvider> serviceLoader = ServiceLoader.load(ProcessEngineProvider.class);
Iterator<ProcessEngineProvider> iterator = serviceLoader.iterator();
if(iterator.hasNext()) {
ProcessEngineProvider provider = iterator.next();
if (engineName == null) {
return provider.getDefaultProcessEngine();
} else {
return provider.getProcessEngine(engineName);
}
} else {
throw new RestException(Status.INTERNAL_SERVER_ERROR, "Could not find an implementation of the "+ProcessEngineProvider.class+"- SPI");
}
}