public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
try {
String configFileName = context.getInitParameter("config-file");
if (configFileName == null) {
throw new ConfigurationException("Missing context parameter \"config-file\" in /WEB-INF/web.xml");
}
File configFile = new File(configFileName);
if (!configFile.isAbsolute()) {
configFile = new File(context.getRealPath("/") + "/WEB-INF/" + configFileName);
}
String url = configFile.getAbsoluteFile().toURI().toString();
try {
Model m = FileManager.get().loadModel(url);
Configuration conf = Configuration.create(m);
context.setAttribute(SERVER_CONFIGURATION, conf);
} catch (JenaException ex) {
throw new ConfigurationException(
"Error parsing configuration file <" + url + ">: " +
ex.getMessage());
}
} catch (ConfigurationException ex) {
log(ex, context);