当前位置: 首页>>代码示例>>Java>>正文


Java TaskExecutorAdapter类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:ConcurrentTaskExecutor.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AsyncExecutionAspectSupport.java

示例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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:AsyncExecutionAspectSupport.java

示例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;
}
 
开发者ID:txazo,项目名称:spring,代码行数:34,代码来源:AsyncExecutionAspectSupport.java

示例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);
}
 
开发者ID:EdwardLee03,项目名称:spring-scheduling-sr,代码行数:12,代码来源:ConcurrentTaskExecutor.java

示例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));
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:14,代码来源:AppComponents.java

示例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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:ConcurrentTaskExecutor.java


注:本文中的org.springframework.core.task.support.TaskExecutorAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。