Skip to content

Commit

Permalink
feat: enable easier override for SpringServlet (#20276) (#20298)
Browse files Browse the repository at this point in the history
Fixes #19994

Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
  • Loading branch information
vaadin-bot and tepi authored Oct 22, 2024
1 parent cc752d4 commit a840fcc
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ public ServletContextInitializer contextInitializer() {
public ServletRegistrationBean<SpringServlet> servletRegistrationBean(
ObjectProvider<MultipartConfigElement> multipartConfig,
VaadinConfigurationProperties configurationProperties) {
boolean rootMapping = RootMappedCondition
.isRootMapping(configurationProperties.getUrlMapping());
return configureServletRegistrationBean(multipartConfig,
configurationProperties,
new SpringServlet(context, rootMapping));
}

public static ServletRegistrationBean<SpringServlet> configureServletRegistrationBean(
ObjectProvider<MultipartConfigElement> multipartConfig,
VaadinConfigurationProperties configurationProperties,
SpringServlet servletInstance) {

String mapping = configurationProperties.getUrlMapping();
Map<String, String> initParameters = new HashMap<>();
boolean rootMapping = RootMappedCondition.isRootMapping(mapping);

Map<String, String> initParameters = new HashMap<>();
if (rootMapping) {
mapping = VaadinServletConfiguration.VAADIN_SERVLET_MAPPING;
initParameters.put(
Expand All @@ -105,7 +116,7 @@ public ServletRegistrationBean<SpringServlet> servletRegistrationBean(
initParameters.put(ApplicationConfig.JSR356_MAPPING_PATH, pushUrl);

ServletRegistrationBean<SpringServlet> registration = new ServletRegistrationBean<>(
new SpringServlet(context, rootMapping), mapping);
servletInstance, mapping);
registration.setInitParameters(initParameters);
registration
.setAsyncSupported(configurationProperties.isAsyncSupported());
Expand Down

0 comments on commit a840fcc

Please sign in to comment.