use of org.openksavi.sponge.config.ConfigException in project sponge by softelnet.
the class BaseScriptKnowledgeBaseInterpreter method load.
@Override
public final void load(String fileName, Charset charset, boolean required) {
synchronized (interpteterSynchro) {
invalidateCache();
SpongeEngine engine = getEngineOperations().getEngine();
try (Reader reader = engine.getKnowledgeBaseFileProvider().getReader(engine, fileName, charset)) {
if (reader != null) {
doLoad(reader, fileName);
} else {
if (required) {
throw new ConfigException("Knowledge base file " + fileName + " not found");
} else {
logger.warn("Knowledge base file " + fileName + " not found but is set as optional.");
}
}
} catch (IOException e) {
throw SpongeUtils.wrapException("load", e);
}
}
}
use of org.openksavi.sponge.config.ConfigException in project sponge by softelnet.
the class DefaultConfigurationManager method createXmlConfiguration.
protected Pair<XMLConfiguration, URL> createXmlConfiguration(String fileName) {
List<Lookup> lookups = Arrays.asList(new SystemPropertiesLookup(), new HomeLookup(), new ConfigLookup());
Parameters params = new Parameters();
FallbackBasePathLocationStrategy locationStrategy = new FallbackBasePathLocationStrategy(FileLocatorUtils.DEFAULT_LOCATION_STRATEGY, home);
FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(XMLConfiguration.class).configure(params.xml().setDefaultLookups(lookups).setLocationStrategy(locationStrategy).setFileName(fileName).setSchemaValidation(true).setEntityResolver(new ResourceSchemaResolver()));
try {
XMLConfiguration xmlConfiguration = builder.getConfiguration();
return new ImmutablePair<>(xmlConfiguration, locationStrategy.getLocatedUrl());
} catch (ConfigurationException e) {
throw new ConfigException("Error reading configuration file " + fileName, e);
}
}
Aggregations