use of com.vaadin.flow.internal.DevModeHandler in project flow by vaadin.
the class BootstrapHandler method showWebpackErrors.
protected static void showWebpackErrors(VaadinService service, Document document) {
Optional<DevModeHandler> devServer = DevModeHandlerManager.getDevModeHandler(service);
if (devServer.isPresent()) {
String errorMsg = devServer.get().getFailedOutput();
if (errorMsg != null) {
// Make error lines more prominent
errorMsg = errorMsg.replaceAll("(ERROR.+?\n)", "<b>$1</b>");
Element errorElement = document.createElement("div");
errorElement.setBaseUri("");
errorElement.attr("class", "v-system-error");
errorElement.html("<h3 style=\"display:inline;\">Webpack Error</h3>" + "<h6 style=\"display:inline; padding-left:10px;\" " + "onclick=\"this.parentElement.parentElement.removeChild(this.parentElement)\">Close</h6>" + "<pre>" + errorMsg + "</pre>");
document.body().appendChild(errorElement);
}
}
}
use of com.vaadin.flow.internal.DevModeHandler in project flow by vaadin.
the class VaadinServletService method createRequestHandlers.
@Override
protected List<RequestHandler> createRequestHandlers() throws ServiceException {
List<RequestHandler> handlers = super.createRequestHandlers();
handlers.add(0, new FaviconHandler());
if (isAtmosphereAvailable()) {
try {
handlers.add(new PushRequestHandler(this));
} catch (ServiceException e) {
// Atmosphere init failed. Push won't work but we don't throw a
// service exception as we don't want to prevent non-push
// applications from working
getLogger().warn("Error initializing Atmosphere. Push will not work.", e);
}
}
if (getDeploymentConfiguration().enableDevServer()) {
Optional<DevModeHandler> handlerManager = DevModeHandlerManager.getDevModeHandler(this);
if (handlerManager.isPresent()) {
handlers.add(handlerManager.get());
} else {
getLogger().warn("no DevModeHandlerManager implementation found " + "but dev server enabled. Include the " + "com.vaadin.vaadin-dev-server dependency.");
}
}
addBootstrapHandler(handlers);
return handlers;
}
use of com.vaadin.flow.internal.DevModeHandler in project flow by vaadin.
the class VaadinServletContextInitializerTest method onStartup_devModeAlreadyInitialized_devModeInitializationSkipped.
@Test
public void onStartup_devModeAlreadyInitialized_devModeInitializationSkipped() throws Exception {
initDefaultMocks();
DevModeHandler devModeHandler = Mockito.mock(DevModeHandler.class);
Mockito.when(devModeHandlerManager.getDevModeHandler()).thenReturn(devModeHandler);
Mockito.when(devModeHandlerManager.getHandlesTypes()).thenReturn(new Class<?>[0]);
Mockito.when(appConfig.enableDevServer()).thenReturn(true);
VaadinServletContextInitializer vaadinServletContextInitializer = getStubbedVaadinServletContextInitializer();
// Simulate Spring context start only
vaadinServletContextInitializer.onStartup(servletContext);
// In our case, we want to check if Dev Mode has been started within
// onStartup() call, that means DevModeInitializer.initDevModeHandler()
// should not have been called.
Mockito.verify(devModeHandlerManager, Mockito.never()).initDevModeHandler(Mockito.any(), Mockito.any(VaadinContext.class));
}
Aggregations