Package org.springframework.batch.item

Examples of org.springframework.batch.item.ExecutionContext


   * is needed. If the provided keys are empty defaults to copy all keys in
   * the {@link JobParameters}.
   */
  @Override
  public void beforeStep(StepExecution stepExecution) {
    ExecutionContext stepContext = stepExecution.getExecutionContext();
    JobParameters jobParameters = stepExecution.getJobParameters();
    Collection<String> keys = this.keys;
    if (keys == null) {
      keys = jobParameters.getParameters().keySet();
    }
    for (String key : keys) {
      if (!stepContext.containsKey(key)) {
        stepContext.put(key, jobParameters.getParameters().get(key).getValue());
      }
    }
  }
View Full Code Here


        new ExecutionContextRowMapper(), executionId);
    if (results.size() > 0) {
      return results.get(0);
    }
    else {
      return new ExecutionContext();
    }
  }
View Full Code Here

        new ExecutionContextRowMapper(), executionId);
    if (results.size() > 0) {
      return results.get(0);
    }
    else {
      return new ExecutionContext();
    }
  }
View Full Code Here

  }

  @Override
  public void updateExecutionContext(final JobExecution jobExecution) {
    Long executionId = jobExecution.getId();
    ExecutionContext executionContext = jobExecution.getExecutionContext();
    Assert.notNull(executionId, "ExecutionId must not be null.");
    Assert.notNull(executionContext, "The ExecutionContext must not be null.");

    String serializedContext = serializeContext(executionContext);
View Full Code Here

  public void updateExecutionContext(final StepExecution stepExecution) {
    // Attempt to prevent concurrent modification errors by blocking here if
    // someone is already trying to do it.
    synchronized (stepExecution) {
      Long executionId = stepExecution.getId();
      ExecutionContext executionContext = stepExecution.getExecutionContext();
      Assert.notNull(executionId, "ExecutionId must not be null.");
      Assert.notNull(executionContext, "The ExecutionContext must not be null.");

      String serializedContext = serializeContext(executionContext);
View Full Code Here

  @Override
  public void saveExecutionContext(JobExecution jobExecution) {

    Long executionId = jobExecution.getId();
    ExecutionContext executionContext = jobExecution.getExecutionContext();
    Assert.notNull(executionId, "ExecutionId must not be null.");
    Assert.notNull(executionContext, "The ExecutionContext must not be null.");

    String serializedContext = serializeContext(executionContext);
View Full Code Here

  }

  @Override
  public void saveExecutionContext(StepExecution stepExecution) {
    Long executionId = stepExecution.getId();
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    Assert.notNull(executionId, "ExecutionId must not be null.");
    Assert.notNull(executionContext, "The ExecutionContext must not be null.");

    String serializedContext = serializeContext(executionContext);
View Full Code Here

  public void saveExecutionContexts(Collection<StepExecution> stepExecutions) {
    Assert.notNull(stepExecutions, "Attempt to save an null collection of step executions");
    Map<Long, String> serializedContexts = new HashMap<Long, String>(stepExecutions.size());
    for (StepExecution stepExecution : stepExecutions) {
      Long executionId = stepExecution.getId();
      ExecutionContext executionContext = stepExecution.getExecutionContext();
      Assert.notNull(executionId, "ExecutionId must not be null.");
      Assert.notNull(executionContext, "The ExecutionContext must not be null.");
      serializedContexts.put(executionId, serializeContext(executionContext));
    }
    persistSerializedContexts(serializedContexts, INSERT_STEP_EXECUTION_CONTEXT);
View Full Code Here

  private class ExecutionContextRowMapper implements ParameterizedRowMapper<ExecutionContext> {

    @Override
    public ExecutionContext mapRow(ResultSet rs, int i) throws SQLException {
      ExecutionContext executionContext = new ExecutionContext();
      String serializedContext = rs.getString("SERIALIZED_CONTEXT");
      if (serializedContext == null) {
        serializedContext = rs.getString("SHORT_CONTEXT");
      }

      Map<String, Object> map;
      try {
        ByteArrayInputStream in = new ByteArrayInputStream(serializedContext.getBytes("ISO-8859-1"));
        map = serializer.deserialize(in);
      }
      catch (IOException ioe) {
        throw new IllegalArgumentException("Unable to deserialize the execution context", ioe);
      }
      for (Map.Entry<String, Object> entry : map.entrySet()) {
        executionContext.put(entry.getKey(), entry.getValue());
      }
      return executionContext;
    }
View Full Code Here

  public void start() {

    JobSynchronizationManager.close();
    jobExecution = new JobExecution(123L);

    ExecutionContext executionContext = new ExecutionContext();
    executionContext.put("foo", "bar");

    jobExecution.setExecutionContext(executionContext);
    JobSynchronizationManager.register(jobExecution);

    beanCount = beanFactory.getBeanDefinitionCount();
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.ExecutionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.