use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class DroolsCorrelationEngineBuilder method locatePluginConfigurations.
private PluginConfiguration[] locatePluginConfigurations() throws Exception {
List<PluginConfiguration> pluginConfigs = new LinkedList<>();
// first we see if the config is etc exists
if (m_configResource != null && m_configResource.isReadable()) {
LOG.info("Found Drools Plugin config file {}.", m_configResource);
pluginConfigs.add(new PluginConfiguration(m_configResource));
}
// then we look in each plugin dir for a config
File[] pluginDirs = getPluginDirs();
for (File pluginDir : pluginDirs) {
File configFile = new File(pluginDir, PLUGIN_CONFIG_FILE_NAME);
if (!configFile.exists()) {
LOG.error("Drools Plugin directory {} does not contains a {} config file. Ignoring plugin.", pluginDir, PLUGIN_CONFIG_FILE_NAME);
} else {
LOG.info("Found Drools Plugin directory {} containing a {} config file.", pluginDir, PLUGIN_CONFIG_FILE_NAME);
pluginConfigs.add(new PluginConfiguration(new FileSystemResource(configFile)));
}
}
return pluginConfigs.toArray(new PluginConfiguration[0]);
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class PollOutagesConfigFactory method init.
/**
* Load the config from the default config file and create the singleton
* instance of this factory.
*
* @exception java.io.IOException
* Thrown if the specified config file cannot be read
* @throws java.io.IOException
* if any.
*/
public static synchronized void init() throws IOException {
if (m_loaded) {
// to reload, reload() will need to be called
return;
}
PollOutagesConfigFactory factory = new PollOutagesConfigFactory(new FileSystemResource(ConfigFileConstants.getFile(ConfigFileConstants.POLL_OUTAGES_CONFIG_FILE_NAME)));
factory.afterPropertiesSet();
setInstance(factory);
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class SnmpPeerFactory method init.
public static synchronized void init() throws IOException {
if (!s_loaded.get()) {
final File cfgFile = getFile();
LOG.debug("init: config file path: {}", cfgFile.getPath());
final FileSystemResource resource = new FileSystemResource(cfgFile);
s_singleton = new SnmpPeerFactory(resource);
s_loaded.set(true);
}
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class SyslogdConfigFactory method parseIncludedFiles.
/**
* Parse import-file tags and add all uei-matchs and hide-messages.
*
* @throws IOException
*/
private void parseIncludedFiles() throws IOException {
final File configDir;
try {
configDir = ConfigFileConstants.getFile(ConfigFileConstants.SYSLOGD_CONFIG_FILE_NAME).getParentFile();
} catch (final Throwable t) {
LOG.warn("Error getting default syslogd configuration location. <import-file> directives will be ignored. This should really only happen in unit tests.");
return;
}
for (final String fileName : m_config.getImportFiles()) {
final File configFile = new File(configDir, fileName);
final SyslogdConfigurationGroup includeCfg = JaxbUtils.unmarshal(SyslogdConfigurationGroup.class, new FileSystemResource(configFile));
if (includeCfg.getUeiMatches() != null) {
for (final UeiMatch ueiMatch : includeCfg.getUeiMatches()) {
if (m_config.getUeiMatches() == null) {
m_config.setUeiMatches(new ArrayList<>());
}
m_config.addUeiMatch(ueiMatch);
}
}
if (includeCfg.getHideMatches() != null) {
for (final HideMatch hideMatch : includeCfg.getHideMatches()) {
if (m_config.getHideMatches() == null) {
m_config.setHideMatches(new ArrayList<>());
}
m_config.addHideMatch(hideMatch);
}
}
}
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class DroolsNorthbounderIT method setUp.
/**
* Sets up the test.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
// Setup the Drools northbounder configuration DAO
System.setProperty("opennms.home", "src/test/resources");
DroolsNorthbounderConfigDao configDao = new DroolsNorthbounderConfigDao();
configDao.setConfigResource(new FileSystemResource(new File("src/test/resources/etc/drools-northbounder-config.xml")));
configDao.afterPropertiesSet();
// Setup the northbounder
nbi = new DroolsNorthbounder(null, configDao, null, "JUnit");
nbi.afterPropertiesSet();
}
Aggregations