use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.
the class PluginsConfigurationProvider method load.
@Override
public void load() throws ConfigurationException {
Collection<PluginConfig> plugins = configuration.getPlugins();
if (plugins == null) {
plugins = new LinkedList<PluginConfig>();
configuration.setPlugins(plugins);
}
Element rootElement = document.getDocumentElement();
NodeList childNodes = rootElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
if ((childNode.getNodeType() == Node.ELEMENT_NODE) && "plugin".equals(childNode.getNodeName())) {
Element paramElement = (Element) childNode;
String groupId = paramElement.getAttribute("groupId");
String artifactId = paramElement.getAttribute("artifactId");
String version = paramElement.getAttribute("version");
PluginConfig defaultPlugin = new PluginConfigImpl();
defaultPlugin.setGroupId(groupId);
defaultPlugin.setArtifactId(artifactId);
defaultPlugin.setVersion(version);
plugins.add(defaultPlugin);
}
}
}
use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.
the class SpringConfigurationProvider method loadBeanFactory.
@Override
public void loadBeanFactory() throws ConfigurationException {
GenericApplicationContext ctx = new GenericApplicationContext();
ClassLoader currentClassLoader = configuration.getClassLoader();
if (currentClassLoader != Thread.currentThread().getContextClassLoader()) {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
reader.setBeanClassLoader(currentClassLoader);
reader.loadBeanDefinitions(new ClassPathResource(config, currentClassLoader));
Collection<PluginConfig> plugins = configuration.getPlugins();
if (plugins != null) {
for (PluginConfig plugin : plugins) {
String descriptorName = plugin.getArtifactId();
if (!descriptorName.startsWith("walkmod-")) {
descriptorName = "walkmod-" + descriptorName;
}
if (!descriptorName.endsWith("-plugin")) {
descriptorName = descriptorName + "-plugin";
}
reader.loadBeanDefinitions(new ClassPathResource("META-INF/walkmod/" + descriptorName + ".xml", configuration.getClassLoader()));
URL url = currentClassLoader.getResource("META-INF/walkmod2/" + descriptorName + ".xml");
if (url != null) {
reader.loadBeanDefinitions(new ClassPathResource("META-INF/walkmod2/" + descriptorName + ".xml", configuration.getClassLoader()));
}
}
}
configuration.setBeanDefinitionRegistry(reader.getRegistry());
ctx.refresh();
}
configuration.setBeanFactory(ctx);
}
use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.
the class PluginsConfigurationProviderTest method testNullOverwriting.
@Test
public void testNullOverwriting() {
PluginsConfigurationProvider provider = new PluginsConfigurationProvider();
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.load();
Collection<PluginConfig> plugins = conf.getPlugins();
Assert.assertNotNull(plugins);
Assert.assertEquals(1, plugins.size());
}
use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.
the class PluginsConfigurationProviderTest method testInvalidPlugins.
@Test
public void testInvalidPlugins() {
IvyConfigurationProvider provider = new IvyConfigurationProvider();
Configuration conf = new ConfigurationImpl();
provider.init(conf);
PluginConfig pc = new PluginConfigImpl();
pc.setGroupId("foo");
pc.setArtifactId("bar");
pc.setVersion("10");
conf.setPlugins(new LinkedList());
conf.getPlugins().add(pc);
Exception exception = null;
try {
provider.load();
} catch (ConfigurationException e) {
exception = e;
}
Assert.assertNotNull(exception);
}
use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddExternalTransformation.
@Test
public void testAddExternalTransformation() throws Exception {
File aux = new File("src/test/resources/xml");
aux.mkdirs();
File xml = new File(aux, "walkmod.xml");
XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
try {
prov.createConfig();
AddTransformationCommand command = new AddTransformationCommand("com.metricstream:metricstream:AddCurlyBraces", null, false, null, null, null, null, false);
prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
prov.load();
Collection<PluginConfig> plugins = prov.getConfiguration().getPlugins();
boolean containsMetricStream = false;
Iterator<PluginConfig> it = plugins.iterator();
while (it.hasNext() && !containsMetricStream) {
PluginConfig next = it.next();
containsMetricStream = next.getGroupId().equals("com.metricstream") && next.getArtifactId().equals("walkmod-metricstream-plugin");
}
Assert.assertTrue(containsMetricStream);
} finally {
xml.delete();
}
}
Aggregations