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

colesico.framework.rpc.codegen.generator.EnvelopeExtensionKit Maven / Gradle / Ivy

The newest version!
package colesico.framework.rpc.codegen.generator;

import colesico.framework.assist.ServiceLocator;
import colesico.framework.rpc.codegen.model.RpcApiMethodElement;
import com.squareup.javapoet.TypeSpec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

public class EnvelopeExtensionKit {

    protected final Logger logger = LoggerFactory.getLogger(EnvelopeExtensionKit.class);

    protected final List extensions = new ArrayList<>();

    public EnvelopeExtensionKit() {
        lookup();
    }

    public void lookup() {
        logger.debug("Lookup envelops extensions...");
        extensions.clear();
        ServiceLocator locator = ServiceLocator.of(this.getClass(), EnvelopeExtension.class, getClass().getClassLoader());
        for (EnvelopeExtension plg : locator.getProviders()) {
            extensions.add(plg);
            logger.debug("Found envelope extension : " + plg.getClass().getName());
        }
    }

    public List> getRequestExtensions() {
        List> result = new ArrayList<>();
        for (EnvelopeExtension plugin : extensions) {
            result.add(plugin.getRequestExtension());
        }
        return result;
    }

    public List> getResponseExtensions() {
        List> result = new ArrayList<>();
        for (EnvelopeExtension plugin : extensions) {
            result.add(plugin.getResponseExtension());
        }
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy