Package org.springframework.core.task

Examples of org.springframework.core.task.TaskExecutor


public class PollingTaskSupportTests {

  @Test
  public void testPollingTask() throws InterruptedException {
    TaskScheduler taskScheduler = new ConcurrentTaskScheduler();
    TaskExecutor taskExecutor = new SyncTaskExecutor();
    TestPollingTaskSupport poller = new TestPollingTaskSupport(taskScheduler, taskExecutor,
        TimeUnit.SECONDS, 2);
    poller.init();
    poller.start();
    Thread.sleep(3000);
View Full Code Here


    // if these tests starts to fail or cause other timing
    // problems, we need to find a better way to run
    // test without adding too long sleeps

    TaskScheduler taskScheduler = new ConcurrentTaskScheduler();
    TaskExecutor taskExecutor = new ConcurrentTaskExecutor();
    TestPollingTaskSupport poller = new TestPollingTaskSupport(taskScheduler, taskExecutor);
    IdleTimeoutTrigger trigger = new IdleTimeoutTrigger(1000);
    poller.setTrigger(trigger);
    poller.init();
    poller.start();
View Full Code Here

    assertEquals("999Hello world!:echo", result);
  }

  @Test
  public void testMultiPlex() throws Exception {
    TaskExecutor executor = new SimpleAsyncTaskExecutor();
    final CountDownLatch latch = new CountDownLatch(100);
    final Set<Integer> results = new HashSet<Integer>();
    for (int i = 100; i < 200; i++) {
      results.add(i);
      final int j = i;
      executor.execute(new Runnable() {
        public void run() {
          String result = gw.send(j + "Hello world!"); // first 3 bytes is correlationid
          assertEquals(j + "Hello world!:echo", result);
          results.remove(j);
          latch.countDown();
View Full Code Here

                defContainer.setReceiveTimeout(config.getReceiveTimeout());
            }
            if (config.getRecoveryInterval() >= 0) {
                defContainer.setRecoveryInterval(config.getRecoveryInterval());
            }
            TaskExecutor taskExecutor = config.getTaskExecutor();
            if (taskExecutor != null) {
                defContainer.setTaskExecutor(taskExecutor);
            }
            PlatformTransactionManager tm = config.getTransactionManager();
            if (tm != null) {
View Full Code Here

        String clientId = configuration.getClientId();
        if (clientId != null) {
            clientId += ".Requestor";
            answer.setClientId(clientId);
        }
        TaskExecutor taskExecutor = configuration.getTaskExecutor();
        if (taskExecutor != null) {
            answer.setTaskExecutor(taskExecutor);
        }
        ExceptionListener exceptionListener = configuration.getExceptionListener();
        if (exceptionListener != null) {
View Full Code Here

        String clientId = configuration.getClientId();
        if (clientId != null) {
            clientId += ".Requestor";
            answer.setClientId(clientId);
        }
        TaskExecutor taskExecutor = configuration.getTaskExecutor();
        if (taskExecutor != null) {
            answer.setTaskExecutor(taskExecutor);
        }
        ExceptionListener exceptionListener = configuration.getExceptionListener();
        if (exceptionListener != null) {
View Full Code Here

        String clientId = configuration.getClientId();
        if (clientId != null) {
            clientId += ".Requestor";
            answer.setClientId(clientId);
        }
        TaskExecutor taskExecutor = configuration.getTaskExecutor();
        if (taskExecutor != null) {
            answer.setTaskExecutor(taskExecutor);
        }
        ExceptionListener exceptionListener = configuration.getExceptionListener();
        if (exceptionListener != null) {
View Full Code Here

      }
    };

    // executor used for creating the appCtx
    // chosen based on the sync/async configuration
    TaskExecutor executor = null;

    ApplicationContextConfiguration config = new ApplicationContextConfiguration(bundle);

    String creationType;

    // synch/asynch context creation
    if (config.isCreateAsynchronously()) {
      // for the async stuff use the executor
      executor = taskExecutor;
      creationType = "Asynchronous";
    }
    else {
      // for the sync stuff, use this thread
      executor = sameThreadTaskExecutor;
      creationType = "Synchronous";
    }

    if (debug) {
      log.debug(creationType + " context creation for bundle " + bundleString);
    }

    // wait/no wait for dependencies behaviour
    if (config.isWaitForDependencies()) {
      DependencyWaiterApplicationContextExecutor appCtxExecutor = new DependencyWaiterApplicationContextExecutor(
        localApplicationContext, !config.isCreateAsynchronously(),
        extenderConfiguration.getDependencyFactories());

      appCtxExecutor.setTimeout(config.getTimeout());
      appCtxExecutor.setWatchdog(timer);
      appCtxExecutor.setTaskExecutor(executor);
      appCtxExecutor.setMonitoringCounter(contextsStarted);
      // set events publisher
      appCtxExecutor.setDelegatedMulticaster(this.multicaster);

      contextsStarted.increment();
    }
    else {
      // do nothing; by default contexts do not wait for services.
    }

    executor.execute(contextRefresh);
  }
View Full Code Here

    final TestMessageListener listener = new TestMessageListener();

    this.container.setConnectionFactory(connectionFactory);
    this.container.setDestinationName(DESTINATION_NAME);
    this.container.setMessageListener(listener);
    this.container.setTaskExecutor(new TaskExecutor() {
      public void execute(Runnable task) {
        listener.executorInvoked = true;
        assertFalse(listener.listenerInvoked);
        task.run();
        assertTrue(listener.listenerInvoked);
View Full Code Here

        String clientId = configuration.getClientId();
        if (clientId != null) {
            clientId += ".Requestor";
            answer.setClientId(clientId);
        }
        TaskExecutor taskExecutor = configuration.getTaskExecutor();
        if (taskExecutor != null) {
            answer.setTaskExecutor(taskExecutor);
        }
        ExceptionListener exceptionListener = configuration.getExceptionListener();
        if (exceptionListener != null) {
View Full Code Here

TOP

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

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.