This commit is contained in:
zhangxin 2016-12-06 21:53:10 +08:00
parent a9c14f85e8
commit 29fa490b4c
2 changed files with 5 additions and 13 deletions

View File

@ -65,6 +65,11 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
/**
* 2. enhance constructors
*/
newClassBuilder = newClassBuilder.constructor(ElementMatchers.<MethodDescription>any())
.intercept(SuperMethodCall.INSTANCE.andThen(
MethodDelegation.to(new DefaultClassConstructorInterceptor())
.appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
if (existedConstructorInterceptPoint) {
for (ConstructorInterceptPoint constructorInterceptPoint : constructorInterceptPoints) {
newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher())
@ -72,13 +77,6 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
MethodDelegation.to(new ClassConstructorInterceptor(constructorInterceptPoint.getConstructorInterceptor()))
.appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
}
} else {
for (ConstructorInterceptPoint constructorInterceptPoint : constructorInterceptPoints) {
newClassBuilder = newClassBuilder.constructor(ElementMatchers.<MethodDescription>any())
.intercept(SuperMethodCall.INSTANCE.andThen(
MethodDelegation.to(new DefaultClassConstructorInterceptor(constructorInterceptPoint.getConstructorInterceptor()))
.appendParameterBinder(FieldProxy.Binder.install(FieldGetter.class, FieldSetter.class))));
}
}

View File

@ -15,12 +15,6 @@ public class DefaultClassConstructorInterceptor {
private static ILog logger = LogManager
.getLogger(ClassConstructorInterceptor.class);
private String instanceMethodsAroundInterceptorClassName;
public DefaultClassConstructorInterceptor(String instanceMethodsAroundInterceptorClassName) {
this.instanceMethodsAroundInterceptorClassName = instanceMethodsAroundInterceptorClassName;
}
@RuntimeType
public void intercept(
@This Object obj,