org.springframework.core.task.support.TaskExecutorAdapter Java Examples
The following examples show how to use
org.springframework.core.task.support.TaskExecutorAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncExecutionAspectSupport.java From spring-analysis-note with MIT License | 6 votes |
/** * 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) */ @Nullable 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.get(); } if (targetExecutor == null) { return null; } executor = (targetExecutor instanceof AsyncListenableTaskExecutor ? (AsyncListenableTaskExecutor) targetExecutor : new TaskExecutorAdapter(targetExecutor)); this.executors.put(method, executor); } return executor; }
Example #2
Source File: AsyncExecutionAspectSupport.java From java-technology-stack with MIT License | 6 votes |
/** * 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) */ @Nullable 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.get(); } if (targetExecutor == null) { return null; } executor = (targetExecutor instanceof AsyncListenableTaskExecutor ? (AsyncListenableTaskExecutor) targetExecutor : new TaskExecutorAdapter(targetExecutor)); this.executors.put(method, executor); } return executor; }
Example #3
Source File: ConcurrentTaskExecutor.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #4
Source File: AsyncExecutionAspectSupport.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * 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; }
Example #5
Source File: ConcurrentTaskExecutor.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #6
Source File: AsyncExecutionAspectSupport.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #7
Source File: ConcurrentTaskExecutor.java From spring-analysis-note with MIT License | 4 votes |
/** * Create a new ConcurrentTaskExecutor, using a single thread executor as default. * @see java.util.concurrent.Executors#newSingleThreadExecutor() */ public ConcurrentTaskExecutor() { this.concurrentExecutor = Executors.newSingleThreadExecutor(); this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor); }
Example #8
Source File: ConcurrentTaskExecutor.java From spring-analysis-note with MIT License | 4 votes |
private static TaskExecutorAdapter getAdaptedExecutor(Executor concurrentExecutor) { if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) { return new ManagedTaskExecutorAdapter(concurrentExecutor); } return new TaskExecutorAdapter(concurrentExecutor); }
Example #9
Source File: ConcurrentTaskExecutor.java From java-technology-stack with MIT License | 4 votes |
/** * Create a new ConcurrentTaskExecutor, using a single thread executor as default. * @see java.util.concurrent.Executors#newSingleThreadExecutor() */ public ConcurrentTaskExecutor() { this.concurrentExecutor = Executors.newSingleThreadExecutor(); this.adaptedExecutor = new TaskExecutorAdapter(this.concurrentExecutor); }
Example #10
Source File: ConcurrentTaskExecutor.java From java-technology-stack with MIT License | 4 votes |
private static TaskExecutorAdapter getAdaptedExecutor(Executor concurrentExecutor) { if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) { return new ManagedTaskExecutorAdapter(concurrentExecutor); } return new TaskExecutorAdapter(concurrentExecutor); }