Package org.springframework.core.task

Examples of org.springframework.core.task.SimpleAsyncTaskExecutor


    //    server = new TThreadPoolServer(hfactory, serverTransport, new TTransportFactory(), new TTransportFactory(),
    //        new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), options);

    if (executor == null) {
      executor = new SimpleAsyncTaskExecutor(getClass().getSimpleName());
    }
  }
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

      return new MathService();
    }

    @Bean
    public AsyncTaskExecutor exec() {
      SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
      simpleAsyncTaskExecutor.setThreadNamePrefix("exec-");
      return simpleAsyncTaskExecutor;
    }
View Full Code Here

      return new MathService();
    }

    @Bean
    public AsyncTaskExecutor exec() {
      SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
      simpleAsyncTaskExecutor.setThreadNamePrefix("exec-");
      return simpleAsyncTaskExecutor;
    }
View Full Code Here

        when(asyncWebRequest.getNativeRequest(HttpServletRequest.class)).thenReturn(request);
        when(request.getRequestURI()).thenReturn("/");
        filterChain = new MockFilterChain();

        threadFactory = new JoinableThreadFactory();
        SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
        executor.setThreadFactory(threadFactory);

        asyncManager = WebAsyncUtils.getAsyncManager(request);
        asyncManager.setAsyncWebRequest(asyncWebRequest);
        asyncManager.setTaskExecutor(executor);
        when(request.getAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE)).thenReturn(asyncManager);
View Full Code Here

     *
     * @see org.springframework.core.task.SimpleAsyncTaskExecutor#SimpleAsyncTaskExecutor(String)
     */
    protected TaskExecutor createDefaultTaskExecutor() {
        String threadNamePrefix = beanName != null ? beanName + "-" : DEFAULT_THREAD_NAME_PREFIX;
        return new SimpleAsyncTaskExecutor(threadNamePrefix);
    }
View Full Code Here

  public static class ThreadedTasklet implements Tasklet {

    @Override
    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
      SimpleAsyncTaskExecutor asyncTX = new SimpleAsyncTaskExecutor();

      StepContext context = StepSynchronizationManager.getContext();
      final StepExecution stepExecution = (context != null) ? context.getStepExecution() : null;

      final AtomicBoolean done = new AtomicBoolean(false);

      final Thread[] th = new Thread[1];

      asyncTX.execute(new Runnable() {
        @Override
        public void run() {
          th[0] = Thread.currentThread();
          StepSynchronizationManager.register(stepExecution);
          try {
View Full Code Here

     * @see org.springframework.core.task.SimpleAsyncTaskExecutor#SimpleAsyncTaskExecutor(String)
     */
    protected TaskExecutor createDefaultTaskExecutor() {
        String beanName = getBeanName();
        String threadNamePrefix = (beanName != null ? beanName + "-" : DEFAULT_THREAD_NAME_PREFIX);
        return new SimpleAsyncTaskExecutor(threadNamePrefix);
    }
View Full Code Here

   * @see org.springframework.core.task.SimpleAsyncTaskExecutor#SimpleAsyncTaskExecutor(String)
   */
  protected TaskExecutor createDefaultTaskExecutor() {
    String beanName = getBeanName();
    String threadNamePrefix = (beanName != null ? beanName + "-" : DEFAULT_THREAD_NAME_PREFIX);
    return new SimpleAsyncTaskExecutor(threadNamePrefix);
  }
View Full Code Here

    // create thread-pool for starting contexts
    ThreadGroup threadGroup = new ThreadGroup("spring-osgi-extender[" + ObjectUtils.getIdentityHexString(this)
        + "]-threads");
    threadGroup.setDaemon(false);

    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setThreadGroup(threadGroup);
    taskExecutor.setThreadNamePrefix("SpringOsgiExtenderThread-");

    isTaskExecutorManagedInternally = true;

    return taskExecutor;
  }
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.