Search in sources :

Example 1 with BaseLocationXmlWebApplicationContext

use of com.predic8.membrane.servlet.config.spring.BaseLocationXmlWebApplicationContext in project service-proxy by membrane.

the class MembraneServletContextListener method contextInitialized.

public void contextInitialized(ServletContextEvent sce) {
    try {
        log.info(Constants.PRODUCT_NAME + " starting...");
        log.debug("loading proxies configuration from: " + getProxiesXmlLocation(sce));
        appCtx = new BaseLocationXmlWebApplicationContext();
        Router router = RouterUtil.initializeRoutersFromSpringWebContext(appCtx, sce.getServletContext(), getProxiesXmlLocation(sce));
        if (router != null)
            throw new RuntimeException("A <router> with a <servletTransport> cannot be used with MembraneServletContextListener. Use MembraneServlet instead.");
        log.info(Constants.PRODUCT_NAME + " running.");
    } catch (Exception ex) {
        log.error("Router not started!", ex);
        throw new RuntimeException("Router not started!", ex);
    }
}
Also used : Router(com.predic8.membrane.core.Router) BaseLocationXmlWebApplicationContext(com.predic8.membrane.servlet.config.spring.BaseLocationXmlWebApplicationContext)

Example 2 with BaseLocationXmlWebApplicationContext

use of com.predic8.membrane.servlet.config.spring.BaseLocationXmlWebApplicationContext in project service-proxy by membrane.

the class MembraneServlet method init.

@Override
public void init(ServletConfig config) throws ServletException {
    try {
        appCtx = new BaseLocationXmlWebApplicationContext();
        log.debug("loading beans configuration from: " + getProxiesXmlLocation(config));
        router = RouterUtil.initializeRoutersFromSpringWebContext(appCtx, config.getServletContext(), getProxiesXmlLocation(config));
        if (router == null)
            throw new RuntimeException("No <router> with a <servletTransport> was found. To use <router> with <transport>, use MembraneServletContextListener instead of MembraneServlet.");
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) BaseLocationXmlWebApplicationContext(com.predic8.membrane.servlet.config.spring.BaseLocationXmlWebApplicationContext) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

BaseLocationXmlWebApplicationContext (com.predic8.membrane.servlet.config.spring.BaseLocationXmlWebApplicationContext)2 Router (com.predic8.membrane.core.Router)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1