com.daiyc.extension.boot.ExtensionFactoryBean Maven / Gradle / Ivy
package com.daiyc.extension.boot;
import com.daiyc.extension.core.ExtensionContext;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.FactoryBean;
/**
* @author daiyc
* @since 2024/8/5
*/
public class ExtensionFactoryBean implements FactoryBean {
@Setter
@Getter
private Class extensionPointType;
@Setter
private ExtensionContext extensionContext;
public ExtensionFactoryBean() {
}
public ExtensionFactoryBean(Class extensionPointType) {
this.extensionPointType = extensionPointType;
}
@Override
public T getObject() throws Exception {
return extensionContext.getExtensionLoader(extensionPointType).getExtension();
}
@Override
public Class> getObjectType() {
return extensionPointType;
}
@Override
public boolean isSingleton() {
return true;
}
}