@Override public void onApplicationEvent(ApplicationReadyEvent event) { ConditionEvaluationReport report = event.getApplicationContext() .getBean(ConditionEvaluationReport.class); if (previousReport != null) { ConditionEvaluationReport delta = report.getDelta(previousReport); if (!delta.getConditionAndOutcomesBySource().isEmpty() || !delta.getExclusions().isEmpty() || !delta.getUnconditionalClasses().isEmpty()) { if (this.logger.isInfoEnabled()) { this.logger.info("Condition evaluation delta:" + new ConditionEvaluationReportMessage(delta, "CONDITION EVALUATION DELTA")); } } else { this.logger.info("Condition evaluation unchanged"); } } previousReport = report; }
public ContextConditionEvaluation(ConfigurableApplicationContext context) { ConditionEvaluationReport report = ConditionEvaluationReport .get(context.getBeanFactory()); this.positiveMatches = new LinkedMultiValueMap<>(); this.negativeMatches = new LinkedHashMap<>(); this.exclusions = report.getExclusions(); this.unconditionalClasses = report.getUnconditionalClasses(); report.getConditionAndOutcomesBySource().forEach(this::add); this.parentId = (context.getParent() != null) ? context.getParent().getId() : null; }
private void outputConditionEvaluationReport(TestContext testContext) { try { ApplicationContext context = testContext.getApplicationContext(); if (context instanceof ConfigurableApplicationContext) { ConditionEvaluationReport report = ConditionEvaluationReport .get(((ConfigurableApplicationContext) context).getBeanFactory()); System.err.println(new ConditionEvaluationReportMessage(report)); } } catch (Exception ex) { // Allow original failure to be reported } }
@RequestMapping("/conditional") public String conditonal() { StringBuilder sb = new StringBuilder(); ConditionEvaluationReport conditionEvaluationReport = beanFactory.getBean("autoConfigurationReport", ConditionEvaluationReport.class); Map<String, ConditionEvaluationReport.ConditionAndOutcomes> result = conditionEvaluationReport.getConditionAndOutcomesBySource(); for(String key : result.keySet()) { ConditionEvaluationReport.ConditionAndOutcomes conditionAndOutcomes = result.get(key); Iterator<ConditionEvaluationReport.ConditionAndOutcome> iterator = conditionAndOutcomes.iterator(); while(iterator.hasNext()) { ConditionEvaluationReport.ConditionAndOutcome conditionAndOutcome = iterator.next(); sb.append(key + " -- " + conditionAndOutcome.getCondition().getClass().getSimpleName() + " -- " + conditionAndOutcome.getOutcome() + "<br/>"); } } return sb.toString(); }
providedBeans.put( AUTO_CONFIGURATION_REPORT_BEAN_NAME, ConditionEvaluationReport.get( (ConfigurableListableBeanFactory) context.getParentApplicationContext() .getAutowireCapableBeanFactory() )