com.kuaishou.business.extension.spring.ExtPointBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kbf-spring-extension Show documentation
Show all versions of kbf-spring-extension Show documentation
kwai-business-extension-framwork
The newest version!
package com.kuaishou.business.extension.spring;
import java.util.Optional;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.cglib.proxy.Enhancer;
import com.kuaishou.business.core.Invoker;
import com.kuaishou.business.core.extpoint.ExtPoint;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@RequiredArgsConstructor
public class ExtPointBean implements FactoryBean {
private final Class extPoint;
private final Invoker invoke;
@Setter
private T defaultImpl;
@Override
public T getObject() {
final Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(extPoint);
final ExtPointBeanProxyMethod extPointBeanProxyMethod = new ExtPointBeanProxyMethod<>(extPoint, invoke);
extPointBeanProxyMethod.setDefaultImpl(Optional.ofNullable(defaultImpl));
enhancer.setCallback(extPointBeanProxyMethod);
return (T) enhancer.create();
}
@Override
public Class> getObjectType() {
return extPoint;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy