org.springframework.cloud.context.restart.RestartEndpoint Java Examples

The following examples show how to use org.springframework.cloud.context.restart.RestartEndpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigReloadAutoConfiguration.java    From spring-cloud-kubernetes with Apache License 2.0 5 votes vote down vote up
/**
 * @param properties config reload properties
 * @param ctx application context
 * @param restarter restart endpoint
 * @param refresher context refresher
 * @return provides the action to execute when the configuration changes.
 */
@Bean
@ConditionalOnMissingBean
public ConfigurationUpdateStrategy configurationUpdateStrategy(
		ConfigReloadProperties properties, ConfigurableApplicationContext ctx,
		@Autowired(required = false) RestartEndpoint restarter,
		ContextRefresher refresher) {
	switch (properties.getStrategy()) {
	case RESTART_CONTEXT:
		Assert.notNull(restarter, "Restart endpoint is not enabled");
		return new ConfigurationUpdateStrategy(properties.getStrategy().name(),
				() -> {
					wait(properties);
					restarter.restart();
				});
	case REFRESH:
		return new ConfigurationUpdateStrategy(properties.getStrategy().name(),
				refresher::refresh);
	case SHUTDOWN:
		return new ConfigurationUpdateStrategy(properties.getStrategy().name(),
				() -> {
					wait(properties);
					ctx.close();
				});
	}
	throw new IllegalStateException("Unsupported configuration update strategy: "
			+ properties.getStrategy());
}
 
Example #2
Source File: ConfigReloadAutoConfiguration.java    From spring-cloud-kubernetes with Apache License 2.0 5 votes vote down vote up
/**
 * Provides the action to execute when the configuration changes.
 */
@Bean
@ConditionalOnMissingBean
public ConfigurationUpdateStrategy configurationUpdateStrategy(ConfigReloadProperties properties, ConfigurableApplicationContext ctx, RestartEndpoint restarter, ContextRefresher refresher) {
    switch (properties.getStrategy()) {
    case RESTART_CONTEXT:
        return new ConfigurationUpdateStrategy(properties.getStrategy().name(), restarter::restart);
    case REFRESH:
        return new ConfigurationUpdateStrategy(properties.getStrategy().name(), refresher::refresh);
    case SHUTDOWN:
        return new ConfigurationUpdateStrategy(properties.getStrategy().name(), ctx::close);
    }
    throw new IllegalStateException("Unsupported configuration update strategy: " + properties.getStrategy());
}
 
Example #3
Source File: RefreshEndpointAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnAvailableEndpoint
@ConditionalOnMissingBean
public RestartEndpoint restartEndpoint() {
	RestartEndpoint endpoint = new RestartEndpoint();
	if (this.exporter != null) {
		endpoint.setIntegrationMBeanExporter(this.exporter);
	}
	return endpoint;
}
 
Example #4
Source File: RefreshEndpointAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(RestartEndpoint.class)
@ConditionalOnMissingBean
@ConditionalOnAvailableEndpoint
public RestartEndpoint.PauseEndpoint pauseEndpoint(RestartEndpoint restartEndpoint) {
	return restartEndpoint.getPauseEndpoint();
}
 
Example #5
Source File: RefreshEndpointAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(RestartEndpoint.class)
@ConditionalOnMissingBean
@ConditionalOnAvailableEndpoint
public RestartEndpoint.ResumeEndpoint resumeEndpoint(
		RestartEndpoint restartEndpoint) {
	return restartEndpoint.getResumeEndpoint();
}
 
Example #6
Source File: LifecycleMvcAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void pauseEndpointEnabled() {
	beanCreatedAndEndpointEnabled("pauseEndpoint",
			RestartEndpoint.PauseEndpoint.class, RestartEndpoint.PauseEndpoint::pause,
			"management.endpoint.restart.enabled=true",
			"management.endpoints.web.exposure.include=restart,pause",
			"management.endpoint.pause.enabled=true");
}
 
Example #7
Source File: LifecycleMvcAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void resumeEndpointEnabled() {
	beanCreatedAndEndpointEnabled("resumeEndpoint",
			RestartEndpoint.ResumeEndpoint.class,
			RestartEndpoint.ResumeEndpoint::resume,
			"management.endpoint.restart.enabled=true",
			"management.endpoint.resume.enabled=true",
			"management.endpoints.web.exposure.include=restart,resume");
}
 
Example #8
Source File: RefreshEndpointAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnAvailableEndpoint
@ConditionalOnMissingBean
public RestartEndpoint restartEndpointWithoutIntegration() {
	return new RestartEndpoint();
}
 
Example #9
Source File: LifecycleMvcAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 4 votes vote down vote up
@Test
public void restartEndpointEnabled() {
	beanCreatedAndEndpointEnabled("restartEndpoint", RestartEndpoint.class,
			RestartEndpoint::restart, "management.endpoint.restart.enabled=true",
			"management.endpoints.web.exposure.include=restart");
}