@SuppressWarnings("unchecked")
@Override
public ModuleSpec findModule(ModuleIdentifier identifier) throws ModuleLoadException {
ServiceController<ModuleSpec> controller = (ServiceController<ModuleSpec>) serviceContainer.getService(moduleSpecServiceName(identifier));
if (controller == null) {
throw new ModuleLoadException("Could not load module " + identifier + " as corresponding module spec service " + identifier + " was not found");
}
ModuleSpecLoadListener listener = new ModuleSpecLoadListener(identifier);
controller.addListener(listener);
return listener.getModuleSpec();
}