@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
String fileSourceRoot = context.getInitParameter(FILE_SOURCE_ROOT_KEY);
ServletContextFileSource fileSource = new ServletContextFileSource(context, fileSourceRoot);
boolean verboseLoggingEnabled = Boolean.parseBoolean(
fromNullable(sce.getServletContext().getInitParameter("verboseLoggingEnabled"))
.or("true"));
JsonFileMappingsLoader defaultMappingsLoader = new JsonFileMappingsLoader(fileSource.child("mappings"));
MappingsSaver mappingsSaver = new NotImplementedMappingsSaver();
WireMockApp wireMockApp = new WireMockApp(
new NotImplementedRequestDelayControl(),
false,
defaultMappingsLoader,
mappingsSaver,
false,
new NotImplementedContainer()
);
AdminRequestHandler adminRequestHandler = new AdminRequestHandler(wireMockApp, new BasicResponseRenderer());
StubRequestHandler stubRequestHandler = new StubRequestHandler(wireMockApp,
new StubResponseRenderer(fileSource.child(FILES_ROOT),
wireMockApp.getGlobalSettingsHolder(),
new ProxyResponseRenderer()));
context.setAttribute(APP_CONTEXT_KEY, wireMockApp);
context.setAttribute(StubRequestHandler.class.getName(), stubRequestHandler);
context.setAttribute(AdminRequestHandler.class.getName(), adminRequestHandler);