Search in sources :

Example 1 with SystemMessagesProvider

use of com.vaadin.flow.server.SystemMessagesProvider in project flow by vaadin.

the class ApplicationRunnerServlet method createServletService.

@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException {
    VaadinServletService service = super.createServletService(deploymentConfiguration);
    final SystemMessagesProvider provider = service.getSystemMessagesProvider();
    service.setSystemMessagesProvider((SystemMessagesProvider) systemMessagesInfo -> {
        if (systemMessagesInfo.getRequest() == null) {
            return provider.getSystemMessages(systemMessagesInfo);
        }
        Object messages = systemMessagesInfo.getRequest().getAttribute(CUSTOM_SYSTEM_MESSAGES_PROPERTY);
        if (messages instanceof SystemMessages) {
            return (SystemMessages) messages;
        }
        return provider.getSystemMessages(systemMessagesInfo);
    });
    return service;
}
Also used : Proxy(java.lang.reflect.Proxy) ServletException(javax.servlet.ServletException) SystemMessagesProvider(com.vaadin.flow.server.SystemMessagesProvider) URL(java.net.URL) CurrentInstance(com.vaadin.flow.internal.CurrentInstance) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) DeploymentConfiguration(com.vaadin.flow.function.DeploymentConfiguration) HttpServletRequest(javax.servlet.http.HttpServletRequest) DefaultDeploymentConfiguration(com.vaadin.flow.server.DefaultDeploymentConfiguration) Map(java.util.Map) VaadinServletRequest(com.vaadin.flow.server.VaadinServletRequest) URI(java.net.URI) Method(java.lang.reflect.Method) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) HttpSession(javax.servlet.http.HttpSession) VaadinSession(com.vaadin.flow.server.VaadinSession) SystemMessages(com.vaadin.flow.server.SystemMessages) Properties(java.util.Properties) Logger(org.slf4j.Logger) ServletConfig(javax.servlet.ServletConfig) MalformedURLException(java.net.MalformedURLException) Files(java.nio.file.Files) VaadinServlet(com.vaadin.flow.server.VaadinServlet) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) IOException(java.io.IOException) File(java.io.File) Serializable(java.io.Serializable) WebServlet(javax.servlet.annotation.WebServlet) FileVisitResult(java.nio.file.FileVisitResult) Conf(com.vaadin.flow.uitest.servlet.CustomDeploymentConfiguration.Conf) VaadinService(com.vaadin.flow.server.VaadinService) InvocationHandler(java.lang.reflect.InvocationHandler) ServiceException(com.vaadin.flow.server.ServiceException) Collections(java.util.Collections) VaadinServletService(com.vaadin.flow.server.VaadinServletService) SystemMessagesProvider(com.vaadin.flow.server.SystemMessagesProvider) VaadinServletService(com.vaadin.flow.server.VaadinServletService) SystemMessages(com.vaadin.flow.server.SystemMessages)

Aggregations

DeploymentConfiguration (com.vaadin.flow.function.DeploymentConfiguration)1 CurrentInstance (com.vaadin.flow.internal.CurrentInstance)1 DefaultDeploymentConfiguration (com.vaadin.flow.server.DefaultDeploymentConfiguration)1 ServiceException (com.vaadin.flow.server.ServiceException)1 SystemMessages (com.vaadin.flow.server.SystemMessages)1 SystemMessagesProvider (com.vaadin.flow.server.SystemMessagesProvider)1 VaadinService (com.vaadin.flow.server.VaadinService)1 VaadinServlet (com.vaadin.flow.server.VaadinServlet)1 VaadinServletRequest (com.vaadin.flow.server.VaadinServletRequest)1 VaadinServletService (com.vaadin.flow.server.VaadinServletService)1 VaadinSession (com.vaadin.flow.server.VaadinSession)1 Conf (com.vaadin.flow.uitest.servlet.CustomDeploymentConfiguration.Conf)1 File (java.io.File)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 Proxy (java.lang.reflect.Proxy)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1