safe loading of calculator engine

This commit is contained in:
Solovyev_S 2013-07-02 13:23:44 +04:00
parent 4dae4bbca4
commit b7b32b1002

View File

@ -179,13 +179,26 @@ public class CalculatorEngineImpl implements CalculatorEngine {
@Override
public void reset() {
synchronized (lock) {
varsRegistry.load();
functionsRegistry.load();
operatorsRegistry.load();
postfixFunctionsRegistry.load();
safeLoadRegistry(varsRegistry);
safeLoadRegistry(functionsRegistry);
safeLoadRegistry(operatorsRegistry);
safeLoadRegistry(postfixFunctionsRegistry);
}
}
private void safeLoadRegistry(@Nonnull CalculatorMathRegistry<?> registry) {
try {
registry.load();
} catch (Exception e) {
logException(e);
}
}
private void logException(@Nonnull Exception e) {
final CalculatorLogger logger = Locator.getInstance().getLogger();
logger.error("Engine", e.getMessage(), e);
}
@Override
public void softReset() {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.engine_preferences_changed, null);