Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Setting VaadinServlet Init-Parameters when using vaadin-spring (and no web.

Samuel Nitsche
6 years ago May 17, 2015 10:02pm
Mikael Grankvist
6 years ago May 18, 2015 7:06am
Samuel Nitsche
6 years ago May 18, 2015 7:38am
Mikael Grankvist
6 years ago May 18, 2015 8:21am
Samuel Nitsche
6 years ago May 18, 2015 8:34am
Mikael Grankvist
6 years ago May 18, 2015 8:40am
Samuel Nitsche
6 years ago May 18, 2015 9:35am
Samuel Nitsche
6 years ago May 18, 2015 3:50pm

Overriding DeploymentConfiguration didn't do the trick in the end.
Though I have a feeling about being not very clean the following approach worked for me:

@Configuration
@EnableConfigurationProperties(VaadinServletConfigurationProperties.class)
@Import(VaadinServletConfiguration.class)
public class MyVaadinServletConfiguration extends VaadinServletConfiguration
{
    @Bean
    ServletRegistrationBean vaadinServletRegistration()
    {
        return createServletRegistrationBean();
    }

    @Override
    protected void addInitParameters(
            ServletRegistrationBean servletRegistrationBean)
    {
        super.addInitParameters(servletRegistrationBean);
        
        addInitParameter(servletRegistrationBean, "org.atmosphere.cpr.AtmosphereInterceptor", "acolson.atmosphere.RecoverSecurityContextAtmosphereInterceptor");    
        addInitParameter(servletRegistrationBean, ApplicationConfig.JSR356_MAPPING_PATH, "/VAADIN");
    }
    
    private void addInitParameter(
            ServletRegistrationBean servletRegistrationBean, String paramName,
            String propertyValue) {
        if (propertyValue != null) {
            getLogger().info("Set servlet init parameter [{}] = [{}]",
                    paramName, propertyValue);
            servletRegistrationBean.addInitParameter(paramName, propertyValue);
        }
    }
}

It would be absolutely great if one of the guys working on vaadin-spring / vaadin-spring-boot addon could give feedback on that solution.
Is it intended to add Init-Parameters that way to SpringVaadinServlet?