Skip to content

Commit

Permalink
Update I18nEndpoint.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed May 22, 2024
1 parent 91130f2 commit cd41c58
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.Selector;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.cglib.core.Local;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource;
Expand Down Expand Up @@ -87,9 +90,14 @@ public class I18nEndpoint {
@Autowired
private ConfigurableEnvironment environment;

@Autowired
@Qualifier(SERVICE_MESSAGE_SOURCE_BEAN_NAME)
public void initServiceMessageSources(ServiceMessageSource serviceMessageSource) {
@EventListener(ApplicationReadyEvent.class)
public void onApplicationReadyEvent(ApplicationReadyEvent event) {
ConfigurableApplicationContext context = event.getApplicationContext();
ServiceMessageSource serviceMessageSource = context.getBean(SERVICE_MESSAGE_SOURCE_BEAN_NAME, ServiceMessageSource.class);
initServiceMessageSources(serviceMessageSource);
}

private void initServiceMessageSources(ServiceMessageSource serviceMessageSource) {
List<ServiceMessageSource> serviceMessageSources = emptyList();
if (serviceMessageSource instanceof DelegatingServiceMessageSource) {
DelegatingServiceMessageSource delegatingServiceMessageSource = (DelegatingServiceMessageSource) serviceMessageSource;
Expand All @@ -108,6 +116,7 @@ public void initServiceMessageSources(ServiceMessageSource serviceMessageSource)

}


@ReadOperation
public Map<String, Map<String, String>> invoke() {
List<ServiceMessageSource> serviceMessageSources = this.serviceMessageSources;
Expand Down

0 comments on commit cd41c58

Please sign in to comment.