Examples of StepContext


Examples of org.springframework.batch.core.scope.context.StepContext

  /**
   * @see Scope#get(String, ObjectFactory)
   */
  @Override
  public Object get(String name, ObjectFactory<?> objectFactory) {
    StepContext context = getContext();
    Object scopedObject = context.getAttribute(name);

    if (scopedObject == null) {

      synchronized (mutex) {
        scopedObject = context.getAttribute(name);
        if (scopedObject == null) {

          logger.debug(String.format("Creating object in scope=%s, name=%s", this.getName(), name));

          scopedObject = objectFactory.getObject();
          context.setAttribute(name, scopedObject);

        }

      }

View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

  /**
   * @see Scope#getConversationId()
   */
  @Override
  public String getConversationId() {
    StepContext context = getContext();
    return context.getId();
  }
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

  /**
   * @see Scope#registerDestructionCallback(String, Runnable)
   */
  @Override
  public void registerDestructionCallback(String name, Runnable callback) {
    StepContext context = getContext();
    logger.debug(String.format("Registered destruction callback in scope=%s, name=%s", this.getName(), name));
    context.registerDestructionCallback(name, callback);
  }
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

  /**
   * @see Scope#remove(String)
   */
  @Override
  public Object remove(String name) {
    StepContext context = getContext();
    logger.debug(String.format("Removing from scope=%s, name=%s", this.getName(), name));
    return context.removeAttribute(name);
  }
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

   *
   * @return the current step context which we can use as a scope storage
   * medium
   */
  private StepContext getContext() {
    StepContext context = StepSynchronizationManager.getContext();
    if (context == null) {
      throw new IllegalStateException("No context holder available for step scope");
    }
    return context;
  }
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

  @Test
  public void testDefaultStepContext() throws Exception {
    TestContext testContext = getTestContext(new Object());
    listener.prepareTestInstance(testContext);
    listener.beforeTestMethod(testContext);
    StepContext context = StepSynchronizationManager.getContext();
    assertNotNull(context);
    listener.afterTestMethod(testContext);
    assertNull(StepSynchronizationManager.getContext());
  }
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

  private void testExecutionContext(Object target) throws Exception {
    TestContext testContext = getTestContext(target);
    listener.prepareTestInstance(testContext);
    try {
      listener.beforeTestMethod(testContext);
      StepContext context = StepSynchronizationManager.getContext();
      assertNotNull(context);
      assertEquals("bar", context.getStepExecutionContext().get("foo"));
    }
    finally {
      listener.afterTestMethod(testContext);
    }
    assertNull(StepSynchronizationManager.getContext());
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

  private void testJobParameters(Object target) throws Exception {
    TestContext testContext = getTestContext(target);
    listener.prepareTestInstance(testContext);
    try {
      listener.beforeTestMethod(testContext);
      StepContext context = StepSynchronizationManager.getContext();
      assertNotNull(context);
      assertEquals("spam", context.getJobParameters().get("foo"));
    }
    finally {
      listener.afterTestMethod(testContext);
    }
    assertNull(StepSynchronizationManager.getContext());
View Full Code Here

Examples of org.springframework.batch.core.scope.context.StepContext

    StepExecution stepExecution = new StepExecution("foo", null);
    ExecutionContext stepExecutionContext = new ExecutionContext();
    stepExecutionContext.putString("filePath", "foo.txt");
    stepExecution.setExecutionContext(stepExecutionContext);
    StepContext stepContext = new StepContext(stepExecution);
    ChunkContext chunkContext = new ChunkContext(stepContext);

    RemoteFileTemplate template = new RemoteFileTemplate(factory);
    template.setBeanFactory(mock(BeanFactory.class));
    template.afterPropertiesSet();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.