|
8 | 8 | import com.genexus.xml.GXXMLSerializable; |
9 | 9 |
|
10 | 10 | import jakarta.annotation.PreDestroy; |
11 | | -import jakarta.servlet.Servlet; |
12 | 11 | import org.glassfish.jersey.server.ResourceConfig; |
13 | 12 | import org.glassfish.jersey.servlet.ServletContainer; |
| 13 | +import org.glassfish.jersey.servlet.ServletProperties; |
14 | 14 | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
15 | | -import org.springframework.boot.web.servlet.ServletRegistrationBean; |
16 | 15 | import org.springframework.beans.factory.annotation.Value; |
17 | 16 | import org.springframework.context.annotation.Bean; |
18 | 17 | import org.springframework.context.annotation.Configuration; |
| 18 | +import org.springframework.core.Ordered; |
19 | 19 | import org.springframework.core.io.ClassPathResource; |
20 | 20 | import org.springframework.util.AntPathMatcher; |
21 | 21 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; |
|
24 | 24 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
25 | 25 | import org.tuckey.web.filters.urlrewrite.UrlRewriteFilter; |
26 | 26 |
|
| 27 | +import java.util.HashMap; |
| 28 | +import java.util.Map; |
27 | 29 | import java.util.Set; |
28 | 30 |
|
29 | 31 | @Configuration |
@@ -90,17 +92,26 @@ public FilterRegistrationBean<UrlRewriteFilter> urlRewriteFilter() { |
90 | 92 | } |
91 | 93 |
|
92 | 94 | @Bean |
93 | | - public ServletRegistrationBean<Servlet> jerseyServletRegistration() { |
| 95 | + public FilterRegistrationBean<ServletContainer> jerseyFilter() { |
94 | 96 | ResourceConfig rc = new ResourceConfig(); |
95 | 97 | Set<Class<?>> rrcs = JaxrsResourcesHolder.getAll(); |
96 | 98 | if (!rrcs.isEmpty()) { |
97 | 99 | rc.registerClasses(rrcs.toArray(new Class<?>[0])); |
| 100 | + rc.property(ServletProperties.FILTER_FORWARD_ON_404, true); |
98 | 101 | } |
| 102 | + |
99 | 103 | ServletContainer container = new ServletContainer(rc); |
100 | | - ServletRegistrationBean<Servlet> bean = new ServletRegistrationBean<>(container, "/rest/*"); |
101 | | - bean.setName("jersey-servlet"); |
102 | | - bean.setLoadOnStartup(1); |
103 | | - return bean; |
| 104 | + |
| 105 | + FilterRegistrationBean<ServletContainer> reg = new FilterRegistrationBean<>(container); |
| 106 | + reg.addUrlPatterns("/rest/*"); |
| 107 | + reg.setName("jersey-filter"); |
| 108 | + reg.setOrder(Ordered.HIGHEST_PRECEDENCE + 1); |
| 109 | + |
| 110 | + Map<String, String> initParams = new HashMap<>(); |
| 111 | + initParams.put(ServletProperties.FILTER_CONTEXT_PATH, "/rest"); |
| 112 | + reg.setInitParameters(initParams); |
| 113 | + |
| 114 | + return reg; |
104 | 115 | } |
105 | 116 |
|
106 | 117 | @PreDestroy |
|
0 commit comments