All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.daiyc.extension.boot.ExtensionFactoryBean Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy