/** * Validates the {@link DiagnosisEngineConfiguration}. * * @throws DiagnosisEngineException * If any of the configuration elements is invalid or is missing. */ public void validate() throws DiagnosisEngineException { try { checkArgument(numSessionWorkers > 0, "numSessionWorkers must be at least 1."); checkArgument(shutdownTimeout > 0, "shutdownTimeout must be at least 1."); checkArgument(CollectionUtils.isNotEmpty(ruleClasses), "At least one rule class must be specified."); checkNotNull(resultCollector, "Result collector must not be null."); if (executorService == null) { executorService = Executors.newFixedThreadPool(getNumSessionWorkers()); } } catch (IllegalArgumentException e) { throw new DiagnosisEngineException("Invalid Diagnosis Engine configuration!", e); } }
public void analyze(I input, Map<String, ?> variables) throws DiagnosisEngineException { if (isShutdown()) { throw new DiagnosisEngineException("Analysis failed! Diagnosis Engine has been shut down."); session = sessionPool.borrowObject(input, variables); } catch (Exception e) { throw new DiagnosisEngineException("Failed to borrow Object from SessionPool.", e);
private void returnSession() { try { sessionPool.returnObject(session); } catch (Exception e) { for (ISessionCallback<R> handler : configuration.getSessionCallbacks()) { handler.onFailure(new DiagnosisEngineException("Failed to return Session to ObjectPool.", e)); } } } });