/** * Register a context with the current thread - always put a matching * {@link #close()} call in a finally block to ensure that the correct * context is available in the enclosing block. * * @param stepExecution the step context to register * @return a new {@link StepContext} or the current one if it has the same * {@link StepExecution} */ public static StepContext register(StepExecution stepExecution) { if (stepExecution == null) { return null; } getCurrent().push(stepExecution); StepContext context; synchronized (contexts) { context = contexts.get(stepExecution); if (context == null) { context = new StepContext(stepExecution); contexts.put(stepExecution, context); } } increment(); return context; }