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

net.n2oapp.framework.config.selective.SelectiveMetadataLoader Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.config.selective;

import net.n2oapp.framework.api.metadata.SourceMetadata;
import net.n2oapp.framework.api.metadata.aware.NamespaceUriAware;
import net.n2oapp.framework.api.metadata.io.NamespaceIO;
import net.n2oapp.framework.api.metadata.io.ProxyNamespaceIO;
import net.n2oapp.framework.api.metadata.reader.NamespaceReader;
import net.n2oapp.framework.api.metadata.reader.NamespaceReaderFactory;
import net.n2oapp.framework.api.reader.SourceLoader;
import net.n2oapp.framework.config.io.MetadataParamHolder;
import net.n2oapp.framework.config.register.route.RouteUtil;
import net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap;

/**
 * Считыватель тестовых метаданных из xml
 */
public class SelectiveMetadataLoader implements SourceLoader {
    protected NamespaceReaderFactory readerFactory;

    public SelectiveMetadataLoader(NamespaceReaderFactory readerFactory) {
        this.readerFactory = readerFactory;
    }

    public SelectiveMetadataLoader() {
        readerFactory = new ReaderFactoryByMap();
    }

    public SelectiveMetadataLoader add(NamespaceReader reader) {
        readerFactory.add(reader);
        return this;
    }

    public SelectiveMetadataLoader add(NamespaceIO io) {
        readerFactory.add(new ProxyNamespaceIO(io));
        return this;
    }

    @Override
    public  S load(CompileInfo info, String params) {
        try {
            MetadataParamHolder.setParams(RouteUtil.parseQueryParams(params));
            return SelectiveUtil.readByPath(info.getId(), info.getPath(), readerFactory);
        } finally {
            MetadataParamHolder.setParams(null);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy