當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleAsyncTaskExecutor類代碼示例

本文整理匯總了Java中org.springframework.core.task.SimpleAsyncTaskExecutor的典型用法代碼示例。如果您正苦於以下問題:Java SimpleAsyncTaskExecutor類的具體用法?Java SimpleAsyncTaskExecutor怎麽用?Java SimpleAsyncTaskExecutor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleAsyncTaskExecutor類屬於org.springframework.core.task包,在下文中一共展示了SimpleAsyncTaskExecutor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteFiles

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
/**
 * 根據文件訪問URL列表, 將文件從雲存儲或應用係統Context路徑下的文件刪除
 * <p>
 * 調用帶有返回值的多線程(實現callable接口),也是同步的。參考:http://blueram.iteye.com/blog/1583117
 *
 * @param fileUrls
 * @return 返回存儲路徑
 */
public Integer deleteFiles(Collection<String> fileUrls) {
    int count = 0;
    AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
    for (String url : fileUrls) {
        final String fileUrl = StringUtils.substringAfterLast(url, coreConfig.getValue("bae.bcs.bucket") + "/");
        try {
            Future<Integer> future = executor.submit(new Callable<Integer>() {
                @Override
                public Integer call() throws Exception {
                    deleteFile(fileUrl);
                    return 1;
                }
            });
            count += future.get();
        } catch (InterruptedException | ExecutionException e) {
            Exceptions.printException(e);
        }
    }
    return count;
}
 
開發者ID:simbest,項目名稱:simbest-cores,代碼行數:29,代碼來源:AppFileUtils.java

示例2: taskExecutor

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Bean
    public TaskExecutor taskExecutor() {
        //https://jira.spring.io/browse/BATCH-2269
        final SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor() {
            @Override
            protected void doExecute(Runnable task) {
                //gets the jobExecution of the configuration thread
                final JobExecution jobExecution = JobSynchronizationManager.getContext().getJobExecution();
                super.doExecute(() -> {
                    JobSynchronizationManager.register(jobExecution);
                    try {
                        task.run();
                    } finally {
//                        JobSynchronizationManager.release();
                        JobSynchronizationManager.close();
                    }
                });
            }
        };
        simpleAsyncTaskExecutor.setConcurrencyLimit(20);
        return simpleAsyncTaskExecutor;
    }
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-data,代碼行數:23,代碼來源:SuggestKeywordsFromNameJobConfiguration.java

示例3: getAsyncExecutor

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Override
public Executor getAsyncExecutor() {
    if (properties.isEnabled()) {
        ThreadPoolTaskExecutor executor = null;
        try {
            executor = beanFactory.getBean(ThreadPoolTaskExecutor.class);
        } catch (NoUniqueBeanDefinitionException e) {
            executor = beanFactory.getBean(DEFAULT_TASK_EXECUTOR_BEAN_NAME, ThreadPoolTaskExecutor.class);
        } catch (NoSuchBeanDefinitionException ex) {
        }
        if (executor != null) {
            log.info("use default TaskExecutor ...");
            return executor;
        } else {
            throw new BeanCreationException("Expecting a 'ThreadPoolTaskExecutor' exists, but was 'null'");
        }
    } else {
        log.info(
                "'AsyncExecutorConfiguration' is disabled, so create 'SimpleAsyncTaskExecutor' with 'threadNamePrefix' - '{}'",
                properties.getThreadNamePrefix());
        return new SimpleAsyncTaskExecutor(properties.getThreadNamePrefix());
    }
}
 
開發者ID:zalando-stups,項目名稱:booties,代碼行數:24,代碼來源:AsyncExecutorConfiguration.java

示例4: setUp

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Before
public void setUp() {
    ReflectionTestUtils.setField(
            instance2Test, 
            "hwAdapter_Rest", 
            mk_hwAdapter); 
    
    //~ INIT ONCE ~~~~~~~~~~~~~~
    if(initialized)return ;
    initialized = true;
    ReflectionTestUtils.setField(
            instance2Test, 
            "asyncExecutor", 
            new SimpleAsyncTaskExecutor("testBulbsHwService_")); 

    ReflectionTestUtils.setField(new BulbsCoreEventProcessor(), "eventStore", 
            mk_eventStore);
    serviceLocator = new DomainServiceLocator();
    ReflectionTestUtils.setField(serviceLocator, "instance", mk_domainServiceLocator);
}
 
開發者ID:datenstrudel,項目名稱:bulbs-core,代碼行數:21,代碼來源:BulbsHwServiceImplTest.java

示例5: taskExecutor

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
/**
 * Create the task executor which will be used for multi-threading
 *
 * @return TaskExecutor
 */
@Bean
public TaskExecutor taskExecutor() {
    SimpleAsyncTaskExecutor asyncTaskExecutor = new SimpleAsyncTaskExecutor("spring_batch");
    asyncTaskExecutor.setConcurrencyLimit(SimpleAsyncTaskExecutor.NO_CONCURRENCY);
    return asyncTaskExecutor;
}
 
開發者ID:blackducksoftware,項目名稱:hub-fortify-ssc-integration-service,代碼行數:12,代碼來源:SpringConfiguration.java

示例6: taskExecutor

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Test
public void taskExecutor() throws Exception {

	URI uri = new URI("ws://localhost/abc");
	this.wsClient.setTaskExecutor(new SimpleAsyncTaskExecutor());
	WebSocketSession session = this.wsClient.doHandshake(this.wsHandler, this.headers, uri).get();

	assertNotNull(session);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:10,代碼來源:StandardWebSocketClientTests.java

示例7: doHandshakeWithTaskExecutor

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Test
public void doHandshakeWithTaskExecutor() throws Exception {

	WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
	headers.setSecWebSocketProtocol(Arrays.asList("echo"));

	this.client.setTaskExecutor(new SimpleAsyncTaskExecutor());
	this.wsSession = this.client.doHandshake(new TextWebSocketHandler(), headers, new URI(this.wsUrl)).get();

	assertEquals(this.wsUrl, this.wsSession.getUri().toString());
	assertEquals("echo", this.wsSession.getAcceptedProtocol());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:13,代碼來源:JettyWebSocketClientTests.java

示例8: createRequestFactory

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Override
protected AsyncClientHttpRequestFactory createRequestFactory() {
	SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
	AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
	requestFactory.setTaskExecutor(taskExecutor);
	return requestFactory;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:8,代碼來源:BufferedSimpleAsyncHttpRequestFactoryTests.java

示例9: step1

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Bean
public Step step1() {
	return stepBuilderFactory.get("step1")
			.<Bracket, Bracket>chunk(10000)
			.reader(itemReader())
			.processor(itemProcessor())
			.writer(itemWriter(null))
			.taskExecutor(new SimpleAsyncTaskExecutor())
			.build();
}
 
開發者ID:mminella,項目名稱:TaskMadness,代碼行數:11,代碼來源:JobConfiguration.java

示例10: setup

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Before
public void setup() {
    executor = new SimpleAsyncTaskExecutor();
    recorder = LogbackRecorder.forClass(MockEnvironment.class).reset().capture("ALL");
    environment = new MockEnvironment();
    recorder.release();
    config = spy(new TestAsyncSpringLiquibase(executor, environment));
    recorder = LogbackRecorder.forClass(AsyncSpringLiquibase.class).reset().capture("ALL");
}
 
開發者ID:jhipster,項目名稱:jhipster,代碼行數:10,代碼來源:AsyncSpringLiquibaseTest.java

示例11: taskExecutor

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
/**
 * @return task executor
 *
 * @see https://jira.spring.io/browse/BATCH-2269
 */
@Bean
public TaskExecutor taskExecutor() {
    return new SimpleAsyncTaskExecutor() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void doExecute(Runnable task) {

            /* Gets the jobExecution of the configuration thread */
            JobExecution jobExecution = JobSynchronizationManager
                    .getContext()
                    .getJobExecution();

            super.doExecute(new Runnable() {
                @Override
                public void run() {
                    JobSynchronizationManager.register(jobExecution);

                    try {
                        task.run();
                    } finally {
                        JobSynchronizationManager.release();
                    }
                }
            });
        }
    };
}
 
開發者ID:hosuaby,項目名稱:signature-processing,代碼行數:34,代碼來源:BatchConfig.java

示例12: afterPropertiesSet

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
/**
 * Initializes the task executor adapter. Expects the delegate to be set. If no
 * {@link #setTaskExecutor(org.springframework.core.task.TaskExecutor) taskExecutor} is
 * provided will create a default one using {@link org.springframework.core.task.SimpleAsyncTaskExecutor}. 
 */
public void afterPropertiesSet() throws Exception {
    Assert.notNull(delegate, "delegate SpaceDataEventListener must not be null");
    if (taskExecutor == null) {
        SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
        simpleAsyncTaskExecutor.setDaemon(true);
        taskExecutor = simpleAsyncTaskExecutor;
    }
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:14,代碼來源:TaskExecutorEventListenerAdapter.java

示例13: networkPool

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
@Bean(name = "networkPool")
public SimpleAsyncTaskExecutor networkPool()
{
  SimpleAsyncTaskExecutor pool = new SimpleAsyncTaskExecutor();
  pool.setThreadPriority(Thread.NORM_PRIORITY + 1);
  return pool;
}
 
開發者ID:de-luxe,項目名稱:burstcoin-jminer,代碼行數:8,代碼來源:CoreConfig.java

示例14: getAsyncRestTemplate

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
private AsyncRestTemplate getAsyncRestTemplate() {
    SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
    factory.setTaskExecutor(new SimpleAsyncTaskExecutor());
    factory.setConnectTimeout(gorouterProperties.getConnectTimeout());
    factory.setReadTimeout(gorouterProperties.getReadTimeout());

    return new AsyncRestTemplate(factory);
}
 
開發者ID:trustedanalytics,項目名稱:router-metrics-provider,代碼行數:9,代碼來源:GatheringConfig.java

示例15: CSVSerializerTest

import org.springframework.core.task.SimpleAsyncTaskExecutor; //導入依賴的package包/類
public CSVSerializerTest() {
    this.serializer = new CSVSerializer();
    TaskExecutor executor = new SimpleAsyncTaskExecutor();
    ReflectionTestUtils.setField(serializer, "executor", executor);
    ReflectionTestUtils.setField(serializer, "defaultTextEnclosure", "\"");
    ReflectionTestUtils.setField(serializer, "defaultEscapeChar", "\u0000");

}
 
開發者ID:Talend,項目名稱:data-prep,代碼行數:9,代碼來源:CSVSerializerTest.java


注:本文中的org.springframework.core.task.SimpleAsyncTaskExecutor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。