当前位置: 首页>>代码示例>>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;未经允许,请勿转载。