Examples of StepContext


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

   */
  public static final String STEP_EXECUTION = "stepExecution";

  @Override
  public Message<?> preSend(Message<?> message, MessageChannel channel) {
    StepContext context = StepSynchronizationManager.getContext();
    if (context == null) {
      return message;
    }
    return MessageBuilder.fromMessage(message).setHeader(STEP_EXECUTION, context.getStepExecution()).build();
  }
View Full Code Here

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

  /**
   * @return the current step execution if there is one
   */
  private StepExecution getStepExecution() {
    StepContext context = StepSynchronizationManager.getContext();
    if (context==null) {
      return null;
    }
    StepExecution stepExecution = context.getStepExecution();
    return stepExecution;
  }
View Full Code Here

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

  @Test
  public void testExecutionInStepScope() throws Exception {
    delegate = new ItemProcessor<String, String>() {
      public String process(String item) throws Exception {
        StepContext context = StepSynchronizationManager.getContext();
        assertTrue(context != null && context.getStepExecution() != null);
        return item + item;
      };
    };
    processor.setDelegate(delegate);
    Future<String> result = StepScopeTestUtils.doInStepScope(MetaDataInstanceFactory.createStepExecution(), new Callable<Future<String>>() {
View Full Code Here

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

  }

  @Test
  public void testGetWithSomethingAlreadyInParentContext() {
    context.setAttribute("foo", "bar");
    StepContext context = StepSynchronizationManager.register(new StepExecution("bar", new JobExecution(0L)));
    Object value = scope.get("foo", new ObjectFactory<Object>() {
      @Override
      public Object getObject() throws BeansException {
        return "spam";
      }
    });
    assertEquals("spam", value);
    assertTrue(context.hasAttribute("foo"));
    StepSynchronizationManager.close();
    assertEquals("bar", scope.get("foo", null));
  }
View Full Code Here

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

  }

  @Test
  public void testParentContextWithSameStepExecution() {
    context.setAttribute("foo", "bar");
    StepContext other = StepSynchronizationManager.register(stepExecution);
    assertSame(other, context);
  }
View Full Code Here

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

        @Override
        public String call() throws Exception {
          StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id);
          ExecutionContext executionContext = stepExecution.getExecutionContext();
          executionContext.put("foo", value);
          StepContext context = StepSynchronizationManager.register(stepExecution);
          logger.debug("Registered: " + context.getStepExecutionContext());
          try {
            return simple.getName();
          }
          finally {
            StepSynchronizationManager.close();
View Full Code Here

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

      FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
        @Override
        public String call() throws Exception {
          ExecutionContext executionContext = stepExecution.getExecutionContext();
          executionContext.put("foo", value);
          StepContext context = StepSynchronizationManager.register(stepExecution);
          logger.debug("Registered: " + context.getStepExecutionContext());
          try {
            return simple.getName();
          }
          finally {
            StepSynchronizationManager.close();
View Full Code Here

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

    if(originalArtifactName.startsWith(SCOPED_TARGET_BEAN_PREFIX)) {
      originalArtifactName = artifactName.substring(SCOPED_TARGET_BEAN_PREFIX.length());
    }

    StepContext stepContext = StepSynchronizationManager.getContext();

    if (stepContext != null) {
      return batchPropertyContext.getStepArtifactProperties(stepContext.getStepName(), originalArtifactName);
    }

    return batchPropertyContext.getArtifactProperties(originalArtifactName);
  }
View Full Code Here

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

   */
  public static final String STEP_EXECUTION = "stepExecution";

  @Override
  public Message<?> preSend(Message<?> message, MessageChannel channel) {
    StepContext context = StepSynchronizationManager.getContext();
    if (context == null) {
      return message;
    }
    return MessageBuilder.fromMessage(message).setHeader(STEP_EXECUTION, context.getStepExecution()).build();
  }
View Full Code Here

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

  /**
   * This will be used to resolve expressions in step-scoped beans.
   */
  @Override
  public Object resolveContextualObject(String key) {
    StepContext context = getContext();
    // TODO: support for attributes as well maybe (setters not exposed yet
    // so not urgent).
    return new BeanWrapperImpl(context).getPropertyValue(key);
  }
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.