|
17 | 17 | package org.springframework.boot.actuate.autoconfigure.health; |
18 | 18 |
|
19 | 19 | import java.util.Collection; |
20 | | -import java.util.Collections; |
21 | | -import java.util.HashSet; |
22 | | -import java.util.Objects; |
23 | 20 |
|
24 | | -import org.glassfish.jersey.server.ResourceConfig; |
25 | | -import org.glassfish.jersey.server.model.Resource; |
26 | | -import org.glassfish.jersey.servlet.ServletContainer; |
27 | | - |
28 | | -import org.springframework.beans.factory.ObjectProvider; |
29 | 21 | import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; |
30 | 22 | import org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure; |
31 | | -import org.springframework.boot.actuate.endpoint.web.EndpointMapping; |
32 | 23 | import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint; |
33 | 24 | import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier; |
34 | 25 | import org.springframework.boot.actuate.endpoint.web.WebServerNamespace; |
35 | | -import org.springframework.boot.actuate.endpoint.web.jersey.JerseyHealthEndpointAdditionalPathResourceFactory; |
36 | 26 | import org.springframework.boot.actuate.endpoint.web.servlet.AdditionalHealthEndpointPathsWebMvcHandlerMapping; |
37 | 27 | import org.springframework.boot.actuate.health.HealthContributorRegistry; |
38 | 28 | import org.springframework.boot.actuate.health.HealthEndpoint; |
39 | 29 | import org.springframework.boot.actuate.health.HealthEndpointGroups; |
40 | 30 | import org.springframework.boot.actuate.health.HealthEndpointWebExtension; |
41 | 31 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
42 | | -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
43 | 32 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
44 | | -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; |
45 | 33 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
46 | 34 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; |
47 | | -import org.springframework.boot.context.properties.EnableConfigurationProperties; |
48 | | -import org.springframework.boot.jersey.autoconfigure.DefaultJerseyApplicationPath; |
49 | | -import org.springframework.boot.jersey.autoconfigure.JerseyApplicationPath; |
50 | | -import org.springframework.boot.jersey.autoconfigure.JerseyProperties; |
51 | | -import org.springframework.boot.jersey.autoconfigure.ResourceConfigCustomizer; |
52 | | -import org.springframework.boot.web.servlet.ServletRegistrationBean; |
53 | 35 | import org.springframework.context.annotation.Bean; |
54 | 36 | import org.springframework.context.annotation.Configuration; |
55 | 37 | import org.springframework.web.servlet.DispatcherServlet; |
@@ -96,81 +78,4 @@ AdditionalHealthEndpointPathsWebMvcHandlerMapping healthEndpointWebMvcHandlerMap |
96 | 78 |
|
97 | 79 | } |
98 | 80 |
|
99 | | - @Configuration(proxyBeanMethods = false) |
100 | | - @ConditionalOnClass(ResourceConfig.class) |
101 | | - @ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet") |
102 | | - static class JerseyAdditionalHealthEndpointPathsConfiguration { |
103 | | - |
104 | | - @Bean |
105 | | - JerseyAdditionalHealthEndpointPathsResourcesRegistrar jerseyAdditionalHealthEndpointPathsResourcesRegistrar( |
106 | | - WebEndpointsSupplier webEndpointsSupplier, HealthEndpointGroups healthEndpointGroups) { |
107 | | - ExposableWebEndpoint health = getHealthEndpoint(webEndpointsSupplier); |
108 | | - return new JerseyAdditionalHealthEndpointPathsResourcesRegistrar(health, healthEndpointGroups); |
109 | | - } |
110 | | - |
111 | | - @Configuration(proxyBeanMethods = false) |
112 | | - @ConditionalOnMissingBean(ResourceConfig.class) |
113 | | - @EnableConfigurationProperties(JerseyProperties.class) |
114 | | - static class JerseyInfrastructureConfiguration { |
115 | | - |
116 | | - @Bean |
117 | | - @ConditionalOnMissingBean |
118 | | - JerseyApplicationPath jerseyApplicationPath(JerseyProperties properties, ResourceConfig config) { |
119 | | - return new DefaultJerseyApplicationPath(properties.getApplicationPath(), config); |
120 | | - } |
121 | | - |
122 | | - @Bean |
123 | | - ResourceConfig resourceConfig(ObjectProvider<ResourceConfigCustomizer> resourceConfigCustomizers) { |
124 | | - ResourceConfig resourceConfig = new ResourceConfig(); |
125 | | - resourceConfigCustomizers.orderedStream().forEach((customizer) -> customizer.customize(resourceConfig)); |
126 | | - return resourceConfig; |
127 | | - } |
128 | | - |
129 | | - @Bean |
130 | | - ServletRegistrationBean<ServletContainer> jerseyServletRegistration( |
131 | | - JerseyApplicationPath jerseyApplicationPath, ResourceConfig resourceConfig) { |
132 | | - return new ServletRegistrationBean<>(new ServletContainer(resourceConfig), |
133 | | - jerseyApplicationPath.getUrlMapping()); |
134 | | - } |
135 | | - |
136 | | - } |
137 | | - |
138 | | - } |
139 | | - |
140 | | - static class JerseyAdditionalHealthEndpointPathsResourcesRegistrar implements ResourceConfigCustomizer { |
141 | | - |
142 | | - private final ExposableWebEndpoint endpoint; |
143 | | - |
144 | | - private final HealthEndpointGroups groups; |
145 | | - |
146 | | - JerseyAdditionalHealthEndpointPathsResourcesRegistrar(ExposableWebEndpoint endpoint, |
147 | | - HealthEndpointGroups groups) { |
148 | | - this.endpoint = endpoint; |
149 | | - this.groups = groups; |
150 | | - } |
151 | | - |
152 | | - @Override |
153 | | - public void customize(ResourceConfig config) { |
154 | | - register(config); |
155 | | - } |
156 | | - |
157 | | - private void register(ResourceConfig config) { |
158 | | - EndpointMapping mapping = new EndpointMapping(""); |
159 | | - JerseyHealthEndpointAdditionalPathResourceFactory resourceFactory = new JerseyHealthEndpointAdditionalPathResourceFactory( |
160 | | - WebServerNamespace.SERVER, this.groups); |
161 | | - Collection<Resource> endpointResources = resourceFactory |
162 | | - .createEndpointResources(mapping, |
163 | | - (this.endpoint != null) ? Collections.singletonList(this.endpoint) : Collections.emptyList()) |
164 | | - .stream() |
165 | | - .filter(Objects::nonNull) |
166 | | - .toList(); |
167 | | - register(endpointResources, config); |
168 | | - } |
169 | | - |
170 | | - private void register(Collection<Resource> resources, ResourceConfig config) { |
171 | | - config.registerResources(new HashSet<>(resources)); |
172 | | - } |
173 | | - |
174 | | - } |
175 | | - |
176 | 81 | } |
0 commit comments