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);
}
}
}
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);
}
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;
}
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);
}
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);
}
}
}
Aggregations