Sha256: 3afa4ed0bb76d08f9b0edf47411d8accec7b589366b8527038f987eaa14e9bf3

Contents?: true

Size: 1.97 KB

Versions: 4

Compression:

Stored size: 1.97 KB

Contents

package org.embulk.output.tester;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.embulk.EmbulkEmbed;
import org.embulk.EmbulkEmbed.Bootstrap;
import org.embulk.config.ConfigSource;
import org.embulk.plugin.InjectedPluginSource;

import com.google.inject.Binder;
import com.google.inject.Module;

public class EmbulkPluginTester
{
    private static class PluginDefinition
    {
        public final Class<?> iface;
        public final String name;
        public final Class<?> impl;


        public PluginDefinition(Class<?> iface, String name, Class<?> impl)
        {
            this.iface = iface;
            this.name = name;
            this.impl = impl;
        }

    }

    private final List<PluginDefinition> plugins = new ArrayList<PluginDefinition>();

    private EmbulkEmbed embulk;

    public EmbulkPluginTester()
    {
    }

    public EmbulkPluginTester(Class<?> iface, String name, Class<?> impl)
    {
        addPlugin(iface, name, impl);
    }

    public void addPlugin(Class<?> iface, String name, Class<?> impl)
    {
        plugins.add(new PluginDefinition(iface, name, impl));
    }

    public void run(String ymlPath) throws Exception
    {
        if (embulk == null) {
            Bootstrap bootstrap = new EmbulkEmbed.Bootstrap();
            bootstrap.addModules(new Module()
            {
                @Override
                public void configure(Binder binder)
                {
                    for (PluginDefinition plugin : plugins) {
                        InjectedPluginSource.registerPluginTo(binder, plugin.iface, plugin.name, plugin.impl);
                    }
                }
            });
            embulk = bootstrap.initializeCloseable();
        }

        ConfigSource config = embulk.newConfigLoader().fromYamlFile(new File(ymlPath));
        embulk.run(config);
    }

    public void destroy() {
        if (embulk != null) {
            embulk.destroy();
            embulk = null;
        }
    }

}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
embulk-output-oracle-0.4.5 src/test/java/org/embulk/output/tester/EmbulkPluginTester.java
embulk-output-oracle-0.4.4 src/test/java/org/embulk/output/tester/EmbulkPluginTester.java
embulk-output-oracle-0.4.3 src/test/java/org/embulk/output/tester/EmbulkPluginTester.java
embulk-output-oracle-0.4.2 src/test/java/org/embulk/output/tester/EmbulkPluginTester.java