Package org.springframework.core.task

Examples of org.springframework.core.task.SimpleAsyncTaskExecutor


  private List<String> writtenItems;
  private TaskExecutor taskExecutor;

  @Before
  public void setup() {
    taskExecutor = new SimpleAsyncTaskExecutor();
    writtenItems = new ArrayList<String>();
    writer = new AsyncItemWriter<String>();
    writer.setDelegate(new ListItemWriter(writtenItems));
  }
View Full Code Here


  private ItemProcessor<String, String> delegate;

  @Test @Ignore // TODO: Need to figure out why the Rule doesn't work with Spring 4
  public void testMultiExecution() throws Exception {
    processor.setDelegate(delegate);
    processor.setTaskExecutor(new SimpleAsyncTaskExecutor());
    List<Future<String>> list = new ArrayList<Future<String>>();
    for (int count = 0; count < 10; count++) {
      list.add(processor.process("foo" + count));
    }
    for (Future<String> future : list) {
View Full Code Here

  private ItemProcessor<String, String> delegate;

  @Test
  public void testMultiExecution() throws Exception {
    processor.setDelegate(delegate);
    processor.setTaskExecutor(new SimpleAsyncTaskExecutor());
    List<Future<String>> list = new ArrayList<Future<String>>();
    for (int count = 0; count < 10; count++) {
      list.add(processor.process("foo" + count));
    }
    for (Future<String> future : list) {
View Full Code Here

  @Test
  public void testOneJobContextPerThread() throws Exception {
    List<Future<JobContext>> jobContexts = new ArrayList<Future<JobContext>>();

    AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();

    for(int i = 0; i < 4; i++) {
      final long count = i;
      jobContexts.add(executor.submit(new Callable<JobContext>() {

        @Override
        public JobContext call() throws Exception {
          try {
            StepSynchronizationManager.register(new StepExecution("step" + count, new JobExecution(count)));
View Full Code Here

    PropertyValue propertyValue;

    if (hasBeanDefinition(beanDefinitionRegistry, JSR_352_SPLIT_TASK_EXECUTOR_BEAN_NAME)) {
      propertyValue = new PropertyValue(TASK_EXECUTOR_PROPERTY_NAME, new RuntimeBeanReference(JSR_352_SPLIT_TASK_EXECUTOR_BEAN_NAME));
    } else {
      propertyValue = new PropertyValue(TASK_EXECUTOR_PROPERTY_NAME, new SimpleAsyncTaskExecutor());
    }

    return propertyValue;
  }
View Full Code Here

  @Test
  public void testSimpleConcurrentJob() throws Exception {

    SimpleStepFactoryBean<String, String> factory = getStepFactory("foo", "bar");
    factory.setTaskExecutor(new SimpleAsyncTaskExecutor());
    factory.setThrottleLimit(1);

    AbstractStep step = (AbstractStep) factory.getObject();
    step.setName("step1");
View Full Code Here

    StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
    fb.setName("step");
    fb.setTransactionManager(new ResourcelessTransactionManager());
    fb.setJobRepository(new JobRepositorySupport());
    fb.setTasklet(new DummyTasklet());
    fb.setTaskExecutor(new SimpleAsyncTaskExecutor());
    Object step = fb.getObject();
    assertTrue(step instanceof TaskletStep);
    Object stepOperations = ReflectionTestUtils.getField(step, "stepOperations");
    assertTrue(stepOperations instanceof TaskExecutorRepeatTemplate);
  }
View Full Code Here

  @Test
  public void getObjectMultiThread() throws Exception {
    List<Future<StepContext>> stepContexts = new ArrayList<Future<StepContext>>();

    AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();

    for(int i = 0; i < 4; i++) {
      final long count = i;
      stepContexts.add(executor.submit(new Callable<StepContext>() {

        @Override
        public StepContext call() throws Exception {
          try {
            StepSynchronizationManager.register(new StepExecution("step" + count, new JobExecution(count)));
View Full Code Here

      when(propertyContext.getStepProperties("step" + i)).thenReturn(props);
    }

    List<Future<StepContext>> stepContexts = new ArrayList<Future<StepContext>>();

    AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();

    for(int i = 0; i < 4; i++) {
      final long count = i;
      stepContexts.add(executor.submit(new Callable<StepContext>() {

        @Override
        public StepContext call() throws Exception {
          try {
            StepSynchronizationManager.register(new StepExecution("step" + count, new JobExecution(count)));
View Full Code Here

    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    MapJobRepositoryFactoryBean repositoryFactory = new MapJobRepositoryFactoryBean();
    repositoryFactory.afterPropertiesSet();
    JobRepository jobRepository = repositoryFactory.getObject();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    jobLauncher.afterPropertiesSet();

    SimpleJob job = new SimpleJob("job");
    TaskletStep step = new TaskletStep("step");
    step.setTasklet(new Tasklet() {
View Full Code Here

TOP

Related Classes of org.springframework.core.task.SimpleAsyncTaskExecutor

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.