Spring---异步任务---@Async
/**
* 【@Async】
* Annotation that marks a method as a candidate for asynchronous execution. 标记一个方法 作为一个 候选的异步任务执行;
* Can also be used at the type level, in which case all of the type's methods are considered as asynchronous. 也可以用于 类级别,类内所有的方法 都为异步任务;
* Note, however, that @Async is not supported on methods declared within a @Configuration class. 【注意】 @Configuration类 内的方法 不支持 使用@Async;
*
* In terms of target method signatures, any parameter types are supported. 目标方法,支持任务参数类型;
* However, the return type is constrained to either void or java.util.concurrent.Future. 但是,返回值 需要考虑 void 还是 Future;
* In the latter case, you may declare the more specific org.springframework.util.concurrent.ListenableFuture or java.util.concurrent.CompletableFuture types 带有返回值的情况,你可以声明ListenableFuture 或 CompletableFuture 返回值类型
* which allow for richer interaction with the asynchronous task and for immediate composition with further processing steps. 与异步任务可以更深层的交互 ;
*
* A Future handle returned from the proxy will be an actual asynchronous Future that can be used to track the result of the asynchronous method execution. 从代理对象返回的Future结果 就是异步任务执行结果;
* However, since the target method needs to implement the same signature, it will have to return a temporary Future handle that just passes a value through: 但是,尽管方法名相同,但是 需要一个临时Future接收值:
* e.g. Spring's AsyncResult, EJB 3.1's javax.ejb.AsyncResult,or java.util.concurrent.CompletableFuture#completedFuture(Object). Spring的AsyncResult...
*
* public @interface Async {
*
* // A qualifier value for the specified asynchronous operation(s). 异步任务执行的修饰符;
* // May be used to determine the target executor to be used when executing the asynchronous operation(s), 用作 执行异步任务的目标 executor
* // matching the qualifier value (or the bean name) of a specific java.util.concurrent.Executor Executor or org.springframework.core.task.TaskExecutor TaskExecutor bean definition. 与value值匹配的 Executor 或 TaskExecutor;
* // When specified on a class-level @Async annotation, indicates that the given executor should be used for all methods within the class. 类级别 指定executor,表示 类中所有方法 都使用指定executor;
* // Method-level use of Async#value always overrides any value set at the class level. 方法级别executor 优先级高于 类级别;
* String value() default "";
* }
*/
原始Class
package com.an.service.impl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import java.util.concurrent.Future;
/**
* @author apy
* @description
* @date 2022/3/11 15:08
*/
@Service
public class AsyncServiceImpl {
public void init(){
System.out.println(Thread.currentThread().getName() + " : AsyncServiceImpl.init");
}
void say(){
}
@Async
public void test(){
System.out.println(Thread.currentThread().getName() + " : AsyncServiceImpl.test");
}
@Async(value = "threadPoolTaskExecutor2")
public Future testAsyncResult(){
System.out.println(Thread.currentThread().getName() + " : AsyncServiceImpl.testAsyncResult");
return new AsyncResult<>("ss");
}
@Async
void testDefault(){
}
@Async
protected void testProtected(){
}
@Async
private void testPrivate(){
}
}
CGLB代理后的Class
package com.an.service.impl;
/**
* @author apy
* @description
* @date 2022/3/21 16:04
*/
import java.lang.reflect.Method;
import java.util.concurrent.Future;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Advisor;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.TargetClassAware;
import org.springframework.aop.TargetSource;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.cglib.core.ReflectUtils;
import org.springframework.cglib.core.Signature;
import org.springframework.cglib.proxy.Callback;
import org.springframework.cglib.proxy.Dispatcher;
import org.springframework.cglib.proxy.Factory;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;
import org.springframework.cglib.proxy.NoOp;
public class AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3 extends AsyncServiceImpl implements SpringProxy, Advised, Factory {
private boolean CGLIB$BOUND;
public static Object CGLIB$FACTORY_DATA;
private static final ThreadLocal CGLIB$THREAD_CALLBACKS;
private static final Callback[] CGLIB$STATIC_CALLBACKS;
private MethodInterceptor CGLIB$CALLBACK_0;
private MethodInterceptor CGLIB$CALLBACK_1;
private NoOp CGLIB$CALLBACK_2;
private Dispatcher CGLIB$CALLBACK_3;
private Dispatcher CGLIB$CALLBACK_4;
private MethodInterceptor CGLIB$CALLBACK_5;
private MethodInterceptor CGLIB$CALLBACK_6;
private static Object CGLIB$CALLBACK_FILTER;
private static final Method CGLIB$say$0$Method;
private static final MethodProxy CGLIB$say$0$Proxy;
private static final Object[] CGLIB$emptyArgs;
private static final Method CGLIB$testAsyncResult$1$Method;
private static final MethodProxy CGLIB$testAsyncResult$1$Proxy;
private static final Method CGLIB$testDefault$2$Method;
private static final MethodProxy CGLIB$testDefault$2$Proxy;
private static final Method CGLIB$testProtected$3$Method;
private static final MethodProxy CGLIB$testProtected$3$Proxy;
private static final Method CGLIB$init$4$Method;
private static final MethodProxy CGLIB$init$4$Proxy;
private static final Method CGLIB$test$5$Method;
private static final MethodProxy CGLIB$test$5$Proxy;
private static final Method CGLIB$equals$6$Method;
private static final MethodProxy CGLIB$equals$6$Proxy;
private static final Method CGLIB$toString$7$Method;
private static final MethodProxy CGLIB$toString$7$Proxy;
private static final Method CGLIB$hashCode$8$Method;
private static final MethodProxy CGLIB$hashCode$8$Proxy;
private static final Method CGLIB$clone$9$Method;
private static final MethodProxy CGLIB$clone$9$Proxy;
final void CGLIB$say$0() {
super.say();
}
final void say() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
if (var10000 != null) {
var10000.intercept(this, CGLIB$say$0$Method, CGLIB$emptyArgs, CGLIB$say$0$Proxy);
} else {
super.say();
}
}
final Future CGLIB$testAsyncResult$1() {
return super.testAsyncResult();
}
public final Future testAsyncResult() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
return var10000 != null ? (Future)var10000.intercept(this, CGLIB$testAsyncResult$1$Method, CGLIB$emptyArgs, CGLIB$testAsyncResult$1$Proxy) : super.testAsyncResult();
}
final void CGLIB$testDefault$2() {
super.testDefault();
}
final void testDefault() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
if (var10000 != null) {
var10000.intercept(this, CGLIB$testDefault$2$Method, CGLIB$emptyArgs, CGLIB$testDefault$2$Proxy);
} else {
super.testDefault();
}
}
final void CGLIB$testProtected$3() {
super.testProtected();
}
protected final void testProtected() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
if (var10000 != null) {
var10000.intercept(this, CGLIB$testProtected$3$Method, CGLIB$emptyArgs, CGLIB$testProtected$3$Proxy);
} else {
super.testProtected();
}
}
final void CGLIB$init$4() {
super.init();
}
public final void init() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
if (var10000 != null) {
var10000.intercept(this, CGLIB$init$4$Method, CGLIB$emptyArgs, CGLIB$init$4$Proxy);
} else {
super.init();
}
}
final void CGLIB$test$5() {
super.test();
}
public final void test() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
if (var10000 != null) {
var10000.intercept(this, CGLIB$test$5$Method, CGLIB$emptyArgs, CGLIB$test$5$Proxy);
} else {
super.test();
}
}
static void CGLIB$STATICHOOK14() {
CGLIB$THREAD_CALLBACKS = new ThreadLocal();
CGLIB$emptyArgs = new Object[0];
Class var0 = Class.forName("com.an.service.impl.AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3");
Class var1;
Method[] var10000 = ReflectUtils.findMethods(new String[]{"equals", "(Ljava/lang/Object;)Z", "toString", "()Ljava/lang/String;", "hashCode", "()I", "clone", "()Ljava/lang/Object;"}, (var1 = Class.forName("java.lang.Object")).getDeclaredMethods());
CGLIB$equals$6$Method = var10000[0];
CGLIB$equals$6$Proxy = MethodProxy.create(var1, var0, "(Ljava/lang/Object;)Z", "equals", "CGLIB$equals$6");
CGLIB$toString$7$Method = var10000[1];
CGLIB$toString$7$Proxy = MethodProxy.create(var1, var0, "()Ljava/lang/String;", "toString", "CGLIB$toString$7");
CGLIB$hashCode$8$Method = var10000[2];
CGLIB$hashCode$8$Proxy = MethodProxy.create(var1, var0, "()I", "hashCode", "CGLIB$hashCode$8");
CGLIB$clone$9$Method = var10000[3];
CGLIB$clone$9$Proxy = MethodProxy.create(var1, var0, "()Ljava/lang/Object;", "clone", "CGLIB$clone$9");
var10000 = ReflectUtils.findMethods(new String[]{"say", "()V", "testAsyncResult", "()Ljava/util/concurrent/Future;", "testDefault", "()V", "testProtected", "()V", "init", "()V", "test", "()V"}, (var1 = Class.forName("com.an.service.impl.AsyncServiceImpl")).getDeclaredMethods());
CGLIB$say$0$Method = var10000[0];
CGLIB$say$0$Proxy = MethodProxy.create(var1, var0, "()V", "say", "CGLIB$say$0");
CGLIB$testAsyncResult$1$Method = var10000[1];
CGLIB$testAsyncResult$1$Proxy = MethodProxy.create(var1, var0, "()Ljava/util/concurrent/Future;", "testAsyncResult", "CGLIB$testAsyncResult$1");
CGLIB$testDefault$2$Method = var10000[2];
CGLIB$testDefault$2$Proxy = MethodProxy.create(var1, var0, "()V", "testDefault", "CGLIB$testDefault$2");
CGLIB$testProtected$3$Method = var10000[3];
CGLIB$testProtected$3$Proxy = MethodProxy.create(var1, var0, "()V", "testProtected", "CGLIB$testProtected$3");
CGLIB$init$4$Method = var10000[4];
CGLIB$init$4$Proxy = MethodProxy.create(var1, var0, "()V", "init", "CGLIB$init$4");
CGLIB$test$5$Method = var10000[5];
CGLIB$test$5$Proxy = MethodProxy.create(var1, var0, "()V", "test", "CGLIB$test$5");
}
final boolean CGLIB$equals$6(Object var1) {
return super.equals(var1);
}
public final boolean equals(Object var1) {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_5;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_5;
}
if (var10000 != null) {
Object var2 = var10000.intercept(this, CGLIB$equals$6$Method, new Object[]{var1}, CGLIB$equals$6$Proxy);
return var2 == null ? false : (Boolean)var2;
} else {
return super.equals(var1);
}
}
final String CGLIB$toString$7() {
return super.toString();
}
public final String toString() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
return var10000 != null ? (String)var10000.intercept(this, CGLIB$toString$7$Method, CGLIB$emptyArgs, CGLIB$toString$7$Proxy) : super.toString();
}
final int CGLIB$hashCode$8() {
return super.hashCode();
}
public final int hashCode() {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_6;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_6;
}
if (var10000 != null) {
Object var1 = var10000.intercept(this, CGLIB$hashCode$8$Method, CGLIB$emptyArgs, CGLIB$hashCode$8$Proxy);
return var1 == null ? 0 : ((Number)var1).intValue();
} else {
return super.hashCode();
}
}
final Object CGLIB$clone$9() throws CloneNotSupportedException {
return super.clone();
}
protected final Object clone() throws CloneNotSupportedException {
MethodInterceptor var10000 = this.CGLIB$CALLBACK_0;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_0;
}
return var10000 != null ? var10000.intercept(this, CGLIB$clone$9$Method, CGLIB$emptyArgs, CGLIB$clone$9$Proxy) : super.clone();
}
public static MethodProxy CGLIB$findMethodProxy(Signature var0) {
String var10000 = var0.toString();
switch(var10000.hashCode()) {
case -1422510685:
if (var10000.equals("test()V")) {
return CGLIB$test$5$Proxy;
}
break;
case -909388886:
if (var10000.equals("say()V")) {
return CGLIB$say$0$Proxy;
}
break;
case -508378822:
if (var10000.equals("clone()Ljava/lang/Object;")) {
return CGLIB$clone$9$Proxy;
}
break;
case -35413050:
if (var10000.equals("testDefault()V")) {
return CGLIB$testDefault$2$Proxy;
}
break;
case 1080997561:
if (var10000.equals("testProtected()V")) {
return CGLIB$testProtected$3$Proxy;
}
break;
case 1596494564:
if (var10000.equals("testAsyncResult()Ljava/util/concurrent/Future;")) {
return CGLIB$testAsyncResult$1$Proxy;
}
break;
case 1826985398:
if (var10000.equals("equals(Ljava/lang/Object;)Z")) {
return CGLIB$equals$6$Proxy;
}
break;
case 1913648695:
if (var10000.equals("toString()Ljava/lang/String;")) {
return CGLIB$toString$7$Proxy;
}
break;
case 1948277861:
if (var10000.equals("init()V")) {
return CGLIB$init$4$Proxy;
}
break;
case 1984935277:
if (var10000.equals("hashCode()I")) {
return CGLIB$hashCode$8$Proxy;
}
}
return null;
}
public final int indexOf(Advice var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).indexOf(var1);
}
public final int indexOf(Advisor var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).indexOf(var1);
}
public final boolean isFrozen() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).isFrozen();
}
public final boolean isProxyTargetClass() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).isProxyTargetClass();
}
public final void setTargetSource(TargetSource var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).setTargetSource(var1);
}
public final void setExposeProxy(boolean var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).setExposeProxy(var1);
}
public final boolean isExposeProxy() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).isExposeProxy();
}
public final void setPreFiltered(boolean var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).setPreFiltered(var1);
}
public final boolean isPreFiltered() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).isPreFiltered();
}
public final void addAdvisor(Advisor var1) throws AopConfigException {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).addAdvisor(var1);
}
public final void addAdvisor(int var1, Advisor var2) throws AopConfigException {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).addAdvisor(var1, var2);
}
public final void removeAdvisor(int var1) throws AopConfigException {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).removeAdvisor(var1);
}
public final boolean removeAdvisor(Advisor var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).removeAdvisor(var1);
}
public final boolean replaceAdvisor(Advisor var1, Advisor var2) throws AopConfigException {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).replaceAdvisor(var1, var2);
}
public final void addAdvice(int var1, Advice var2) throws AopConfigException {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).addAdvice(var1, var2);
}
public final void addAdvice(Advice var1) throws AopConfigException {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
((Advised)var10000.loadObject()).addAdvice(var1);
}
public final boolean removeAdvice(Advice var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).removeAdvice(var1);
}
public final String toProxyConfigString() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).toProxyConfigString();
}
public final TargetSource getTargetSource() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).getTargetSource();
}
public final Class[] getProxiedInterfaces() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).getProxiedInterfaces();
}
public final boolean isInterfaceProxied(Class var1) {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).isInterfaceProxied(var1);
}
public final Advisor[] getAdvisors() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((Advised)var10000.loadObject()).getAdvisors();
}
public final Class getTargetClass() {
Dispatcher var10000 = this.CGLIB$CALLBACK_4;
if (var10000 == null) {
CGLIB$BIND_CALLBACKS(this);
var10000 = this.CGLIB$CALLBACK_4;
}
return ((TargetClassAware)var10000.loadObject()).getTargetClass();
}
public AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3() {
CGLIB$BIND_CALLBACKS(this);
}
public static void CGLIB$SET_THREAD_CALLBACKS(Callback[] var0) {
CGLIB$THREAD_CALLBACKS.set(var0);
}
public static void CGLIB$SET_STATIC_CALLBACKS(Callback[] var0) {
CGLIB$STATIC_CALLBACKS = var0;
}
private static final void CGLIB$BIND_CALLBACKS(Object var0) {
AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3 var1 = (AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3)var0;
if (!var1.CGLIB$BOUND) {
var1.CGLIB$BOUND = true;
Object var10000 = CGLIB$THREAD_CALLBACKS.get();
if (var10000 == null) {
var10000 = CGLIB$STATIC_CALLBACKS;
if (var10000 == null) {
return;
}
}
Callback[] var10001 = (Callback[])var10000;
var1.CGLIB$CALLBACK_6 = (MethodInterceptor)((Callback[])var10000)[6];
var1.CGLIB$CALLBACK_5 = (MethodInterceptor)var10001[5];
var1.CGLIB$CALLBACK_4 = (Dispatcher)var10001[4];
var1.CGLIB$CALLBACK_3 = (Dispatcher)var10001[3];
var1.CGLIB$CALLBACK_2 = (NoOp)var10001[2];
var1.CGLIB$CALLBACK_1 = (MethodInterceptor)var10001[1];
var1.CGLIB$CALLBACK_0 = (MethodInterceptor)var10001[0];
}
}
public Object newInstance(Callback[] var1) {
CGLIB$SET_THREAD_CALLBACKS(var1);
AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3 var10000 = new AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3();
CGLIB$SET_THREAD_CALLBACKS((Callback[])null);
return var10000;
}
public Object newInstance(Callback var1) {
throw new IllegalStateException("More than one callback object required");
}
public Object newInstance(Class[] var1, Object[] var2, Callback[] var3) {
CGLIB$SET_THREAD_CALLBACKS(var3);
AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3 var10000 = new AsyncServiceImpl$$EnhancerBySpringCGLIB$$da7142d3;
switch(var1.length) {
case 0:
var10000.();
CGLIB$SET_THREAD_CALLBACKS((Callback[])null);
return var10000;
default:
throw new IllegalArgumentException("Constructor not found");
}
}
public Callback getCallback(int var1) {
CGLIB$BIND_CALLBACKS(this);
Object var10000;
switch(var1) {
case 0:
var10000 = this.CGLIB$CALLBACK_0;
break;
case 1:
var10000 = this.CGLIB$CALLBACK_1;
break;
case 2:
var10000 = this.CGLIB$CALLBACK_2;
break;
case 3:
var10000 = this.CGLIB$CALLBACK_3;
break;
case 4:
var10000 = this.CGLIB$CALLBACK_4;
break;
case 5:
var10000 = this.CGLIB$CALLBACK_5;
break;
case 6:
var10000 = this.CGLIB$CALLBACK_6;
break;
default:
var10000 = null;
}
return (Callback)var10000;
}
public void setCallback(int var1, Callback var2) {
switch(var1) {
case 0:
this.CGLIB$CALLBACK_0 = (MethodInterceptor)var2;
break;
case 1:
this.CGLIB$CALLBACK_1 = (MethodInterceptor)var2;
break;
case 2:
this.CGLIB$CALLBACK_2 = (NoOp)var2;
break;
case 3:
this.CGLIB$CALLBACK_3 = (Dispatcher)var2;
break;
case 4:
this.CGLIB$CALLBACK_4 = (Dispatcher)var2;
break;
case 5:
this.CGLIB$CALLBACK_5 = (MethodInterceptor)var2;
break;
case 6:
this.CGLIB$CALLBACK_6 = (MethodInterceptor)var2;
}
}
public Callback[] getCallbacks() {
CGLIB$BIND_CALLBACKS(this);
return new Callback[]{this.CGLIB$CALLBACK_0, this.CGLIB$CALLBACK_1, this.CGLIB$CALLBACK_2, this.CGLIB$CALLBACK_3, this.CGLIB$CALLBACK_4, this.CGLIB$CALLBACK_5, this.CGLIB$CALLBACK_6};
}
public void setCallbacks(Callback[] var1) {
this.CGLIB$CALLBACK_0 = (MethodInterceptor)var1[0];
this.CGLIB$CALLBACK_1 = (MethodInterceptor)var1[1];
this.CGLIB$CALLBACK_2 = (NoOp)var1[2];
this.CGLIB$CALLBACK_3 = (Dispatcher)var1[3];
this.CGLIB$CALLBACK_4 = (Dispatcher)var1[4];
this.CGLIB$CALLBACK_5 = (MethodInterceptor)var1[5];
this.CGLIB$CALLBACK_6 = (MethodInterceptor)var1[6];
}
static {
CGLIB$STATICHOOK14();
}
}
/**
* 【@Async---使用】
* 1、只要类中 任一方法(private, protected, default ,public)被 @Async 修饰,类中所有方法将被增强;
*
*/
/**
* 【@Async---advice】
* Spring对@Async 使用org.springframework.scheduling.annotation.AsyncAnnotationAdvisor;
*
* org.springframework.scheduling.annotation.AsyncAnnotationAdvisor
* Advisor that activates asynchronous method execution through the Async annotation. 通过@Async激活异步任务执行;
* This advisor detects the EJB 3.1 javax.ejb.Asynchronous annotation as well, treating it exactly like Spring's own Async. 该advice 也检测EJB的异步注解;
* Furthermore, a custom async annotation type may get specified through the #setAsyncAnnotationType "asyncAnnotationType" property. 自定义异步注解 可以通过 setAsyncAnnotationType设置;
*/
/**
* 【调用过程】
* 当 调用代理对象的目标方法时,会调用 org.springframework.cglib.proxy.MethodInterceptor的intercept方法,
* 实际调用 实现了org.springframework.cglib.proxy.MethodInterceptor的intercept方法 的 org.springframework.aop.framework.CglibAopProxy 的advice;
*
* public interface MethodInterceptor extends Callback {
* Object intercept(Object var1, Method var2, Object[] var3, MethodProxy var4) throws Throwable;
* }
*
* import org.springframework.cglib.proxy.MethodInterceptor;
*
* class CglibAopProxy implements AopProxy, Serializable {
*
* private static class DynamicUnadvisedInterceptor implements MethodInterceptor, Serializable {
* public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {}
* }
*
* ...
* }
*/
/**
* 【代理对象创建】
*
* 创建思路:BeanPostProcessor#postProcessAfterInitialization
*
* org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#initializeBean
*
* ->
*
* org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsAfterInitialization
*
* ->
*
* org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor#postProcessAfterInitialization{
* ...
* if (isEligible(bean, beanName)) {
* ProxyFactory proxyFactory = prepareProxyFactory(bean, beanName);
* ...
* proxyFactory.addAdvisor(this.advisor);
* return proxyFactory.getProxy(getProxyClassLoader());
* }
* ...
* }
*
*
* BeanPostProcessor :org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor
*
* advisor: org.springframework.scheduling.annotation.AsyncAnnotationAdvisor
*
*/