protected StepThreadExecutionEntity createStepExecutionIfStepShouldBeExecuted ( ) throws DoNotRestartStepThreadException { StepThreadExecutionEntity newStepExecution = null ; StepThreadInstanceKey stepThreadInstanceKey = getStepThreadInstanceKey ( ) ; stepThreadInstance = getPersistenceManagerService ( ) . getStepThreadInstance ( stepThreadInstanceKey ) ; // Note that for a partition thread, we're assuming we won't find a partition-level step thread instance // in the case that the top-level step is restarting after completing (i.e. in the allow-start-if-complete="true" case). // We assume that something at the top-level will remove these step thread instances so that we don't see them. if ( stepThreadInstance == null ) { logger . finer ( "No existing step instance found. Create new step execution and proceed to execution." ) ; newStepExecution = stepThreadHelper . createStepThreadInstanceAndFirstExecution ( stepThreadInstanceKey , runtimeWorkUnitExecution . isRemotePartitionDispatch ( ) ) ; stepThreadInstance = getPersistenceManagerService ( ) . getStepThreadInstance ( stepThreadInstanceKey ) ; if ( stepThreadInstance == null ) { throw new IllegalStateException ( "Should have just created step thread instance." ) ; } } else { logger . finer ( "Existing step instance found." ) ; newStepExecution = stepThreadHelper . setupStepThreadExecutionForRestartIfNecessary ( runtimeWorkUnitExecution . isRemotePartitionDispatch ( ) ) ; } return newStepExecution ; }
stepThreadInstance and stepThreadExecution are either retrieved from the DB or if they don t exist yet they re created .