pb.addSubBlock(ComputationTaskStopPolicyFactory.COMPTASK, this);
// It is necessary to consult the registry here (so that it, e.g., can
// document which stop policy was chosen)
pb.setValue(config.getStopPolicyFactoryClass().getCanonicalName());
ComputationTaskStopPolicyFactory stopPolicyFactory =
SimSystem.getRegistry().getFactory(
AbstractComputationTaskStopPolicyFactory.class, pb);
// In case the selection of the intended factory fails, choose the one that
// was configured originally
if (!stopPolicyFactory.getClass()
.equals(config.getStopPolicyFactoryClass())) {
try {
stopPolicyFactory = config.getStopPolicyFactoryClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
SimSystem.report(Level.SEVERE,
"Could not initialize stop policy factory.", e);
}
}
simRunStopPolicy = stopPolicyFactory.create(pb, SimSystem.getRegistry().createContext());
}