Search in sources :

Example 1 with XmlConfigLoader

use of com.revolsys.ui.web.config.XmlConfigLoader in project com.revolsys.open by revolsys.

the class IafServletFilter method init.

@Override
public void init(final FilterConfig filterConfig) throws ServletException {
    String config = filterConfig.getInitParameter("config");
    if (config == null) {
        config = "/WEB-INF/iaf-config.xml";
    }
    final ServletContext servletContext = filterConfig.getServletContext();
    WebUiContext.setServletContext(servletContext);
    final WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    try {
        final URL configResource = servletContext.getResource(config);
        final XmlConfigLoader configLoader = new XmlConfigLoader(configResource, servletContext);
        this.rsWebUiConfig = configLoader.loadConfig();
        servletContext.setAttribute("rsWebUiConfig", this.rsWebUiConfig);
    } catch (final InvalidConfigException e) {
        log.error(e.getErrors().toString(), e);
        throw new UnavailableException("Cannot load a rsWebUiConfig resource from '" + config + "' due to " + e.getErrors());
    } catch (final Exception e) {
        log.error(e.getMessage(), e);
        throw new UnavailableException("Cannot load a rsWebUiConfig resource from '" + config + "' due to " + e.getMessage());
    }
}
Also used : XmlConfigLoader(com.revolsys.ui.web.config.XmlConfigLoader) UnavailableException(javax.servlet.UnavailableException) ServletContext(javax.servlet.ServletContext) InvalidConfigException(com.revolsys.ui.web.config.InvalidConfigException) URL(java.net.URL) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException) InvalidConfigException(com.revolsys.ui.web.config.InvalidConfigException) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 2 with XmlConfigLoader

use of com.revolsys.ui.web.config.XmlConfigLoader in project com.revolsys.open by revolsys.

the class WebUiFilter method loadIafConfig.

private void loadIafConfig(final String config, final FilterConfig filterConfig) throws UnavailableException {
    final ServletContext servletContext = filterConfig.getServletContext();
    WebUiContext.setServletContext(servletContext);
    this.applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    try {
        final URL configResource = servletContext.getResource(config);
        final XmlConfigLoader configLoader = new XmlConfigLoader(configResource, servletContext);
        this.rsWebUiConfig = configLoader.loadConfig();
        servletContext.setAttribute("rsWebUiConfig", this.rsWebUiConfig);
    } catch (final InvalidConfigException e) {
        Logs.error(this, e.getErrors().toString(), e);
        throw new UnavailableException("Cannot load a rsWebUiConfig resource from '" + config + "' due to " + e.getErrors());
    } catch (final Exception e) {
        Logs.error(this, e.getMessage(), e);
        throw new UnavailableException("Cannot load a rsWebUiConfig resource from '" + config + "' due to " + e.getMessage());
    }
}
Also used : XmlConfigLoader(com.revolsys.ui.web.config.XmlConfigLoader) UnavailableException(javax.servlet.UnavailableException) ServletContext(javax.servlet.ServletContext) InvalidConfigException(com.revolsys.ui.web.config.InvalidConfigException) URL(java.net.URL) ServletException(javax.servlet.ServletException) InvalidConfigException(com.revolsys.ui.web.config.InvalidConfigException) PageNotFoundException(com.revolsys.ui.web.exception.PageNotFoundException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Example 3 with XmlConfigLoader

use of com.revolsys.ui.web.config.XmlConfigLoader in project com.revolsys.open by revolsys.

the class IafServlet method init.

/**
 * Initialise the servlet. Loads the configuration from the
 * /WEB-INF/nice-config.xml file.
 *
 * @param config The servlet configuration parameters
 * @exception ServletException if there was a problem initialising the servlet
 */
@Override
public void init(final ServletConfig config) throws ServletException {
    super.init(config);
    try {
        this.servletContext = config.getServletContext();
        final URL configResource = this.servletContext.getResource("/WEB-INF/iaf-config.xml");
        WebUiContext.setServletContext(this.servletContext);
        final XmlConfigLoader configLoader = new XmlConfigLoader(configResource, this.servletContext);
        this.applicationConfig = configLoader.loadConfig();
        this.servletContext.setAttribute("rsWebUiConfig", this.applicationConfig);
    } catch (final InvalidConfigException ice) {
        ice.printStackTrace();
        log.error(ice.getErrors().toString());
        throw new UnavailableException(ice.getMessage() + ":" + ice.getErrors());
    } catch (final MalformedURLException mue) {
        log.error(mue.getMessage(), mue);
        throw new UnavailableException("Failed to initialise Servlet");
    } catch (final Throwable t) {
        t.printStackTrace();
        log.error(t.getMessage(), t);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) XmlConfigLoader(com.revolsys.ui.web.config.XmlConfigLoader) UnavailableException(javax.servlet.UnavailableException) InvalidConfigException(com.revolsys.ui.web.config.InvalidConfigException) URL(java.net.URL)

Aggregations

InvalidConfigException (com.revolsys.ui.web.config.InvalidConfigException)3 XmlConfigLoader (com.revolsys.ui.web.config.XmlConfigLoader)3 URL (java.net.URL)3 UnavailableException (javax.servlet.UnavailableException)3 IOException (java.io.IOException)2 ServletContext (javax.servlet.ServletContext)2 ServletException (javax.servlet.ServletException)2 PageNotFoundException (com.revolsys.ui.web.exception.PageNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1