本文整理汇总了Java中org.springframework.core.task.support.TaskExecutorAdapter类的典型用法代码示例。如果您正苦于以下问题:Java TaskExecutorAdapter类的具体用法?Java TaskExecutorAdapter怎么用?Java TaskExecutorAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TaskExecutorAdapter类属于org.springframework.core.task.support包,在下文中一共展示了TaskExecutorAdapter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConcurrentExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
/**
* Specify the {@link java.util.concurrent.Executor} to delegate to.
* <p>Autodetects a JSR-236 {@link javax.enterprise.concurrent.ManagedExecutorService}
* in order to expose {@link javax.enterprise.concurrent.ManagedTask} adapters for it.
*/
public final void setConcurrentExecutor(Executor concurrentExecutor) {
if (concurrentExecutor != null) {
this.concurrentExecutor = concurrentExecutor;
if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) {
this.adaptedExecutor = new ManagedTaskExecutorAdapter(concurrentExecutor);
}
else {
this.adaptedExecutor = new TaskExecutorAdapter(concurrentExecutor);
}
}
else {
this.concurrentExecutor = Executors.newSingleThreadExecutor();
this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor);
}
}
示例2: determineAsyncExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
/**
* Determine the specific executor to use when executing the given method.
* @return the executor to use (or {@code null}, but just if no default executor has been set)
*/
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
AsyncTaskExecutor executor = this.executors.get(method);
if (executor == null) {
Executor executorToUse = this.defaultExecutor;
String qualifier = getExecutorQualifier(method);
if (StringUtils.hasLength(qualifier)) {
Assert.notNull(this.beanFactory, "BeanFactory must be set on " + getClass().getSimpleName() +
" to access qualified executor '" + qualifier + "'");
executorToUse = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
this.beanFactory, Executor.class, qualifier);
}
else if (executorToUse == null) {
return null;
}
executor = (executorToUse instanceof AsyncTaskExecutor ?
(AsyncTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));
this.executors.put(method, executor);
}
return executor;
}
示例3: determineAsyncExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
/**
* Determine the specific executor to use when executing the given method.
* Should preferably return an {@link AsyncListenableTaskExecutor} implementation.
* @return the executor to use (or {@code null}, but just if no default executor has been set)
*/
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
AsyncTaskExecutor executor = this.executors.get(method);
if (executor == null) {
Executor executorToUse = this.defaultExecutor;
String qualifier = getExecutorQualifier(method);
if (StringUtils.hasLength(qualifier)) {
if (this.beanFactory == null) {
throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
" to access qualified executor '" + qualifier + "'");
}
executorToUse = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
this.beanFactory, Executor.class, qualifier);
}
else if (executorToUse == null) {
return null;
}
executor = (executorToUse instanceof AsyncListenableTaskExecutor ?
(AsyncListenableTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));
this.executors.put(method, executor);
}
return executor;
}
示例4: determineAsyncExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
/**
* Determine the specific executor to use when executing the given method.
* Should preferably return an {@link AsyncListenableTaskExecutor} implementation.
* @return the executor to use (or {@code null}, but just if no default executor is available)
*/
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
AsyncTaskExecutor executor = this.executors.get(method);
if (executor == null) {
Executor targetExecutor;
String qualifier = getExecutorQualifier(method);
if (StringUtils.hasLength(qualifier)) {
targetExecutor = findQualifiedExecutor(this.beanFactory, qualifier);
}
else {
targetExecutor = this.defaultExecutor;
if (targetExecutor == null) {
synchronized (this.executors) {
if (this.defaultExecutor == null) {
this.defaultExecutor = getDefaultExecutor(this.beanFactory);
}
targetExecutor = this.defaultExecutor;
}
}
}
if (targetExecutor == null) {
return null;
}
executor = (targetExecutor instanceof AsyncListenableTaskExecutor ?
(AsyncListenableTaskExecutor) targetExecutor : new TaskExecutorAdapter(targetExecutor));
this.executors.put(method, executor);
}
return executor;
}
示例5: setConcurrentExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
/**
* 设置并委托给JDK 1.5的并发执行器。
*
* <p>Specify the JDK 1.5 concurrent executor to delegate to.
*/
public final void setConcurrentExecutor(Executor concurrentExecutor) {
// 默认使用单线程的执行器服务
this.concurrentExecutor =
(concurrentExecutor != null ? concurrentExecutor : Executors.newSingleThreadExecutor());
this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor);
}
示例6: asyncExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
@Bean
public Executor asyncExecutor() {
Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.error("Uncaught exception in thread " + t + ": " + e, e));
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(1 * Runtime.getRuntime().availableProcessors());
executor.setMaxPoolSize(2 * Runtime.getRuntime().availableProcessors());
executor.setQueueCapacity(100000);
executor.setThreadNamePrefix("BoDExecutor-");
executor.initialize();
return new TaskExecutorAdapter(new TransactionAwareExecutor(executor));
}
示例7: setConcurrentExecutor
import org.springframework.core.task.support.TaskExecutorAdapter; //导入依赖的package包/类
/**
* Specify the JDK 1.5 concurrent executor to delegate to.
*/
public final void setConcurrentExecutor(Executor concurrentExecutor) {
this.concurrentExecutor =
(concurrentExecutor != null ? concurrentExecutor : Executors.newSingleThreadExecutor());
this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor);
}