Search in sources :

Example 11 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class YAMLConfigurationProviderTest method testAddPluginRecursively.

@Test
public void testAddPluginRecursively() throws Exception {
    File dir = new File("src/test/resources/multimoduleyaml");
    dir.mkdirs();
    File module0 = new File(dir, "module0");
    module0.mkdir();
    File moduleCfg = new File(module0, "walkmod.yml");
    File file = new File(dir, "walkmod.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    try {
        YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
        Configuration conf = new ConfigurationImpl();
        provider.init(conf);
        provider.addModules(Arrays.asList("module0"));
        PluginConfig pluginCfg = new PluginConfigImpl();
        pluginCfg.setGroupId("org.walkmod");
        pluginCfg.setArtifactId("myplugin");
        pluginCfg.setVersion("1.0");
        provider.addPluginConfig(pluginCfg, true);
        String output = FileUtils.readFileToString(moduleCfg);
        String desiredOutput = "plugins:\n";
        desiredOutput += "- \"org.walkmod:myplugin:1.0\"";
        Assert.assertEquals(desiredOutput, output);
    } finally {
        if (dir.exists()) {
            FileUtils.deleteDirectory(dir);
        }
    }
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) PluginConfigImpl(org.walkmod.conf.entities.impl.PluginConfigImpl) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Example 12 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class WalkModFacade method inspectPlugin.

/**
 * Retrieves the bean definitions that contains an specific plugin.
 *
 * @param plugin
 *            Plugin container of bean definitions.
 * @return List of bean definitions.
 */
public List<BeanDefinition> inspectPlugin(PluginConfig plugin) {
    Configuration conf = new ConfigurationImpl();
    Collection<PluginConfig> plugins = new LinkedList<PluginConfig>();
    plugins.add(plugin);
    conf.setPlugins(plugins);
    ConfigurationManager manager = new ConfigurationManager(conf, false, locateConfigurationProvider());
    manager.executeConfigurationProviders();
    return conf.getAvailableBeans(plugin);
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) ConfigurationManager(org.walkmod.conf.ConfigurationManager) LinkedList(java.util.LinkedList)

Example 13 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class AddPluginCommand method build.

public List<PluginConfig> build() {
    List<PluginConfig> result = new LinkedList<PluginConfig>();
    for (String plugin : plugins) {
        PluginConfig pluginConfig = new PluginConfigImpl(plugin);
        result.add(pluginConfig);
    }
    return result;
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) PluginConfigImpl(org.walkmod.conf.entities.impl.PluginConfigImpl) LinkedList(java.util.LinkedList)

Example 14 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class ConfigurationImpl method preparePlugins.

@Override
public void preparePlugins() {
    Collection<PluginConfig> pluginCfg = getPlugins();
    HashSet<String> plugins = new HashSet<String>();
    HashSet<String> previousPlugins = new HashSet<String>();
    if (pluginCfg == null || pluginCfg.isEmpty()) {
        pluginCfg = new LinkedList<PluginConfig>();
    } else {
        for (PluginConfig pc : pluginCfg) {
            previousPlugins.add(pc.getGroupId() + ":" + pc.getArtifactId());
        }
    }
    Collection<ChainConfig> chains = getChainConfigs();
    if (chains != null) {
        Iterator<ChainConfig> it = chains.iterator();
        while (it.hasNext()) {
            ChainConfig cc = it.next();
            composeName(cc.getReaderConfig().getType(), plugins);
            composeName(cc.getWalkerConfig().getParserConfig().getType(), plugins);
            List<TransformationConfig> trans = cc.getWalkerConfig().getTransformations();
            if (trans != null) {
                for (TransformationConfig transformation : trans) {
                    String type = transformation.getType();
                    if (!type.equals("script") && !type.equals("template")) {
                        composeName(type, plugins);
                    }
                }
            }
            composeName(cc.getWriterConfig().getType(), plugins);
        }
    }
    Collection<ProviderConfig> providers = getProviderConfigurations();
    if (providers != null) {
        for (ProviderConfig provider : providers) {
            String type = provider.getType();
            composeName(type, plugins);
        }
    }
    Collection<InitializerConfig> initializers = getInitializers();
    if (initializers != null) {
        for (InitializerConfig initializer : initializers) {
            plugins.add(initializer.getPluginGroupId() + ":walkmod-" + initializer.getPluginArtifactId() + "-plugin");
        }
    }
    for (String id : plugins) {
        if (!previousPlugins.contains(id)) {
            String[] parts = id.split(":");
            PluginConfig cfg = new PluginConfigImpl();
            cfg.setGroupId(parts[0].trim());
            cfg.setArtifactId(parts[1].trim());
            cfg.setVersion("latest.integration");
            pluginCfg.add(cfg);
        }
    }
    setPlugins(pluginCfg);
}
Also used : ProviderConfig(org.walkmod.conf.entities.ProviderConfig) InitializerConfig(org.walkmod.conf.entities.InitializerConfig) TransformationConfig(org.walkmod.conf.entities.TransformationConfig) ChainConfig(org.walkmod.conf.entities.ChainConfig) PluginConfig(org.walkmod.conf.entities.PluginConfig) HashSet(java.util.HashSet)

Example 15 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class DynamicConfigurationProvider method load.

@Override
public void load() throws ConfigurationException {
    config.prepareInitializers();
    if (chains != null) {
        for (String chain : chains) {
            if (StringUtils.isNotEmpty(chain)) {
                PluginConfig plugin = config.resolvePlugin(chain);
                config.getPlugins().add(plugin);
            }
        }
        config.preparePlugins();
    }
    String path = options.getPath();
    if (chains != null) {
        for (String chain : chains) {
            if (StringUtils.isNotEmpty(chain)) {
                ChainConfig cc = config.getChainConfig(chain);
                if (cc == null) {
                    cc = new ChainConfigImpl(new TransformationConfigImpl(chain));
                    config.addChainConfig(cc);
                }
            }
        }
    }
    if (StringUtils.isNotEmpty(path)) {
        for (ChainConfig cc : config.getChainConfigs()) {
            cc.setPath(path);
        }
    }
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) TransformationConfigImpl(org.walkmod.conf.entities.impl.TransformationConfigImpl) ChainConfigImpl(org.walkmod.conf.entities.impl.ChainConfigImpl) ChainConfig(org.walkmod.conf.entities.ChainConfig)

Aggregations

PluginConfig (org.walkmod.conf.entities.PluginConfig)22 LinkedList (java.util.LinkedList)10 Configuration (org.walkmod.conf.entities.Configuration)10 PluginConfigImpl (org.walkmod.conf.entities.impl.PluginConfigImpl)10 Test (org.junit.Test)9 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)9 File (java.io.File)8 ConfigurationException (org.walkmod.conf.ConfigurationException)4 ChainConfig (org.walkmod.conf.entities.ChainConfig)4 IOException (java.io.IOException)3 URL (java.net.URL)3 NodeList (org.w3c.dom.NodeList)3 WalkModFacade (org.walkmod.WalkModFacade)3 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)3 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2 AddPluginCommand (org.walkmod.commands.AddPluginCommand)2 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)2 ChainConfigImpl (org.walkmod.conf.entities.impl.ChainConfigImpl)2 JSONArray (com.alibaba.fastjson.JSONArray)1