遇见lambda 表达式想转成jdk1.7,如下图:
AgentBuilder.Transformer transformer2 =
(builder, typeDescription, classLoader, javaModule) ->
// 拦截 doDispatch builder.method(ElementMatchers.isProtected().and((ElementMatchers.nameEndsWith("doDispatch"))))
// 拦截后交给 SpringDispatchInterceptor 处理
.intercept(MethodDelegation.to(SpringDispatchInterceptor.class));
可以直接先写出
new AgentBuilder.Transformer();
利用idea等工具,然后直接弹出他的实现
最终如下:
AgentBuilder.Transformer transformer = new AgentBuilder.Transformer() {
@Override
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader, JavaModule module) {
DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition<?> doDispatch = builder.method(ElementMatchers.isProtected().and((ElementMatchers.nameEndsWith("doDispatch"))))
.intercept(MethodDelegation.to(SpringDispatchInterceptor.class));
return doDispatch;
}};