11/*
2- * Copyright 2014-2024 the original author or authors.
2+ * Copyright 2014-2026 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package de .codecentric .boot .admin .server .config ;
1818
19+ import org .reactivestreams .Publisher ;
20+ import org .springframework .beans .factory .ObjectProvider ;
1921import org .springframework .boot .autoconfigure .AutoConfigureAfter ;
22+ import org .springframework .boot .autoconfigure .condition .ConditionalOnBean ;
2023import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
24+ import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
2125import org .springframework .boot .autoconfigure .condition .ConditionalOnWebApplication ;
2226import org .springframework .boot .webmvc .autoconfigure .WebMvcAutoConfiguration ;
2327import org .springframework .context .ApplicationEventPublisher ;
2731import org .springframework .web .reactive .accept .RequestedContentTypeResolver ;
2832import tools .jackson .databind .module .SimpleModule ;
2933
34+ import de .codecentric .boot .admin .server .domain .events .InstanceEvent ;
3035import de .codecentric .boot .admin .server .eventstore .InstanceEventStore ;
3136import de .codecentric .boot .admin .server .services .ApplicationRegistry ;
3237import de .codecentric .boot .admin .server .services .InstanceRegistry ;
3338import de .codecentric .boot .admin .server .utils .jackson .AdminServerModule ;
3439import de .codecentric .boot .admin .server .web .ApplicationsController ;
40+ import de .codecentric .boot .admin .server .web .HttpHeaderFilter ;
41+ import de .codecentric .boot .admin .server .web .InstanceWebProxy ;
3542import de .codecentric .boot .admin .server .web .InstancesController ;
43+ import de .codecentric .boot .admin .server .web .cache .ActuatorResponseCache ;
44+ import de .codecentric .boot .admin .server .web .cache .CacheInvalidationTrigger ;
45+ import de .codecentric .boot .admin .server .web .cache .InMemoryActuatorResponseCache ;
3646import de .codecentric .boot .admin .server .web .client .InstanceWebClient ;
3747
3848@ Configuration (proxyBeanMethods = false )
@@ -62,6 +72,21 @@ public ApplicationsController applicationsController(ApplicationRegistry applica
6272 return new ApplicationsController (applicationRegistry , applicationEventPublisher );
6373 }
6474
75+ @ Bean
76+ @ ConditionalOnMissingBean (ActuatorResponseCache .class )
77+ @ ConditionalOnProperty (prefix = "spring.boot.admin.endpoint-cache" , name = "enabled" , matchIfMissing = true )
78+ public InMemoryActuatorResponseCache actuatorResponseCache () {
79+ return new InMemoryActuatorResponseCache (this .adminServerProperties .getEndpointCache ());
80+ }
81+
82+ @ Bean (initMethod = "start" , destroyMethod = "stop" )
83+ @ ConditionalOnBean (ActuatorResponseCache .class )
84+ @ ConditionalOnMissingBean (CacheInvalidationTrigger .class )
85+ public CacheInvalidationTrigger cacheInvalidationTrigger (ActuatorResponseCache responseCache ,
86+ Publisher <InstanceEvent > events ) {
87+ return new CacheInvalidationTrigger (events , responseCache );
88+ }
89+
6590 @ Configuration (proxyBeanMethods = false )
6691 @ ConditionalOnWebApplication (type = ConditionalOnWebApplication .Type .REACTIVE )
6792 public static class ReactiveRestApiConfiguration {
@@ -75,11 +100,14 @@ public ReactiveRestApiConfiguration(AdminServerProperties adminServerProperties)
75100 @ Bean
76101 @ ConditionalOnMissingBean
77102 public de .codecentric .boot .admin .server .web .reactive .InstancesProxyController instancesProxyController (
78- InstanceRegistry instanceRegistry , InstanceWebClient .Builder instanceWebClientBuilder ) {
103+ InstanceRegistry instanceRegistry , InstanceWebClient .Builder instanceWebClientBuilder ,
104+ ObjectProvider <ActuatorResponseCache > responseCache ) {
105+ HttpHeaderFilter headerFilter = new HttpHeaderFilter (
106+ this .adminServerProperties .getInstanceProxy ().getIgnoredHeaders ());
107+ InstanceWebProxy instanceWebProxy = new InstanceWebProxy (instanceWebClientBuilder .build (),
108+ responseCache .getIfAvailable (), headerFilter );
79109 return new de .codecentric .boot .admin .server .web .reactive .InstancesProxyController (
80- this .adminServerProperties .getContextPath (),
81- this .adminServerProperties .getInstanceProxy ().getIgnoredHeaders (), instanceRegistry ,
82- instanceWebClientBuilder .build ());
110+ this .adminServerProperties .getContextPath (), headerFilter , instanceRegistry , instanceWebProxy );
83111 }
84112
85113 @ Bean
@@ -108,11 +136,14 @@ public ServletRestApiConfiguration(AdminServerProperties adminServerProperties)
108136 @ Bean
109137 @ ConditionalOnMissingBean
110138 public de .codecentric .boot .admin .server .web .servlet .InstancesProxyController instancesProxyController (
111- InstanceRegistry instanceRegistry , InstanceWebClient .Builder instanceWebClientBuilder ) {
139+ InstanceRegistry instanceRegistry , InstanceWebClient .Builder instanceWebClientBuilder ,
140+ ObjectProvider <ActuatorResponseCache > responseCache ) {
141+ HttpHeaderFilter headerFilter = new HttpHeaderFilter (
142+ this .adminServerProperties .getInstanceProxy ().getIgnoredHeaders ());
143+ InstanceWebProxy instanceWebProxy = new InstanceWebProxy (instanceWebClientBuilder .build (),
144+ responseCache .getIfAvailable (), headerFilter );
112145 return new de .codecentric .boot .admin .server .web .servlet .InstancesProxyController (
113- this .adminServerProperties .getContextPath (),
114- this .adminServerProperties .getInstanceProxy ().getIgnoredHeaders (), instanceRegistry ,
115- instanceWebClientBuilder .build ());
146+ this .adminServerProperties .getContextPath (), headerFilter , instanceRegistry , instanceWebProxy );
116147 }
117148
118149 @ Bean
0 commit comments