Browse Source

Explicit javadoc references to BeanFactory-based default executor lookup

Issue: SPR-14030
pull/1002/head
Juergen Hoeller 10 years ago
parent
commit
f2f87ff1e0
  1. 6
      spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java
  2. 18
      spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.aj
  3. 13
      spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspect.aj

6
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java

@ -119,6 +119,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
* executor will be looked up at invocation time against the enclosing bean factory * executor will be looked up at invocation time against the enclosing bean factory
* @see #getExecutorQualifier(Method) * @see #getExecutorQualifier(Method)
* @see #setBeanFactory(BeanFactory) * @see #setBeanFactory(BeanFactory)
* @see #getDefaultExecutor(BeanFactory)
*/ */
public void setExecutor(Executor defaultExecutor) { public void setExecutor(Executor defaultExecutor) {
this.defaultExecutor = defaultExecutor; this.defaultExecutor = defaultExecutor;
@ -133,7 +134,10 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
} }
/** /**
* Set the {@link BeanFactory} to be used when looking up executors by qualifier. * Set the {@link BeanFactory} to be used when looking up executors by qualifier
* or when relying on the default executor lookup algorithm.
* @see #findQualifiedExecutor(BeanFactory, String)
* @see #getDefaultExecutor(BeanFactory)
*/ */
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {

18
spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.aj

@ -17,7 +17,6 @@
package org.springframework.scheduling.aspectj; package org.springframework.scheduling.aspectj;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.aspectj.lang.annotation.SuppressAjWarnings; import org.aspectj.lang.annotation.SuppressAjWarnings;
@ -29,27 +28,32 @@ import org.springframework.core.task.AsyncTaskExecutor;
/** /**
* Abstract aspect that routes selected methods asynchronously. * Abstract aspect that routes selected methods asynchronously.
* *
* <p>This aspect needs to be injected with an implementation of * <p>This aspect needs to be injected with an implementation of a task-oriented
* {@link Executor} to activate it for a specific thread pool. * {@link java.util.concurrent.Executor} to activate it for a specific thread pool,
* Otherwise it will simply delegate all calls synchronously. * or with a {@link org.springframework.beans.factory.BeanFactory} for default
* executor lookup. Otherwise it will simply delegate all calls synchronously.
* *
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Chris Beams * @author Chris Beams
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 3.0.5 * @since 3.0.5
* @see #setExecutor
* @see #setBeanFactory
* @see #getDefaultExecutor
*/ */
public abstract aspect AbstractAsyncExecutionAspect extends AsyncExecutionAspectSupport { public abstract aspect AbstractAsyncExecutionAspect extends AsyncExecutionAspectSupport {
/** /**
* Create an {@code AnnotationAsyncExecutionAspect} with a {@code null} default * Create an {@code AnnotationAsyncExecutionAspect} with a {@code null}
* executor, which should instead be set via {@code #aspectOf} and * default executor, which should instead be set via {@code #aspectOf} and
* {@link #setExecutor(Executor)}. The same applies for {@link #setExceptionHandler} * {@link #setExecutor}. The same applies for {@link #setExceptionHandler}.
*/ */
public AbstractAsyncExecutionAspect() { public AbstractAsyncExecutionAspect() {
super(null); super(null);
} }
/** /**
* Apply around advice to methods matching the {@link #asyncMethod()} pointcut, * Apply around advice to methods matching the {@link #asyncMethod()} pointcut,
* submit the actual calling of the method to the correct task executor and return * submit the actual calling of the method to the correct task executor and return

13
spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspect.aj

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -33,9 +33,17 @@ import org.springframework.scheduling.annotation.Async;
* on the return type. If, however, a class marked with {@code @Async} contains a method * on the return type. If, however, a class marked with {@code @Async} contains a method
* that violates this constraint, it produces only a warning. * that violates this constraint, it produces only a warning.
* *
* <p>This aspect needs to be injected with an implementation of a task-oriented
* {@link java.util.concurrent.Executor} to activate it for a specific thread pool,
* or with a {@link org.springframework.beans.factory.BeanFactory} for default
* executor lookup. Otherwise it will simply delegate all calls synchronously.
*
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @author Chris Beams * @author Chris Beams
* @since 3.0.5 * @since 3.0.5
* @see #setExecutor
* @see #setBeanFactory
* @see #getDefaultExecutor
*/ */
public aspect AnnotationAsyncExecutionAspect extends AbstractAsyncExecutionAspect { public aspect AnnotationAsyncExecutionAspect extends AbstractAsyncExecutionAspect {
@ -74,7 +82,6 @@ public aspect AnnotationAsyncExecutionAspect extends AbstractAsyncExecutionAspec
declare warning: declare warning:
execution(!(void || Future+) (@Async *).*(..)): execution(!(void || Future+) (@Async *).*(..)):
"Methods in a class marked with @Async that do not return void or Future will " + "Methods in a class marked with @Async that do not return void or Future will be routed synchronously";
"be routed synchronously";
} }

Loading…
Cancel
Save