use of com.predic8.membrane.servlet.embedded.ServletTransport 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);
}
}
use of com.predic8.membrane.servlet.embedded.ServletTransport in project service-proxy by membrane.
the class RouterUtil method initializeRoutersFromSpringWebContext.
public static Router initializeRoutersFromSpringWebContext(XmlWebApplicationContext appCtx, final ServletContext ctx, String configLocation) {
appCtx.setServletContext(ctx);
appCtx.setConfigLocation(configLocation);
appCtx.refresh();
Collection<Router> routers = appCtx.getBeansOfType(Router.class).values();
Router theOne = null;
for (Router r : routers) {
r.getResolverMap().addSchemaResolver(new FileSchemaWebAppResolver(ctx));
if (r.getTransport() instanceof ServletTransport) {
if (theOne != null)
throw new RuntimeException("Only one <router> may have a <servletTransport> defined.");
theOne = r;
}
}
appCtx.start();
return theOne;
}
use of com.predic8.membrane.servlet.embedded.ServletTransport 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);
}
}
Aggregations