Skip to content

io microsphere spring cloud fault tolerance tomcat event TomcatDynamicConfigurationListener

github-actions[bot] edited this page Apr 8, 2026 · 2 revisions

TomcatDynamicConfigurationListener

Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.fault.tolerance.tomcat.event | Since: 1.0.0

Source: microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/fault/tolerance/tomcat/event/TomcatDynamicConfigurationListener.java

Overview

An ApplicationListener of EnvironmentChangeEvent to change the Tomcat's configuration dynamically at the runtime.

Declaration

public class TomcatDynamicConfigurationListener implements ApplicationListener<EnvironmentChangeEvent>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.9-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

onApplicationEvent

TomcatWebServer tomcatWebServer = ...;
ServerProperties serverProperties = ...;
ConfigurableApplicationContext context = ...;
TomcatDynamicConfigurationListener listener =
    new TomcatDynamicConfigurationListener(tomcatWebServer, serverProperties, context);
context.addApplicationListener(listener);
// Automatically invoked by Spring when an EnvironmentChangeEvent is published.
// Reconfigures Tomcat settings such as thread pool size, connection timeout, etc.

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-cloud-commons</artifactId>
    <version>${microsphere-spring-cloud.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-cloud-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.cloud.fault.tolerance.tomcat.event.TomcatDynamicConfigurationListener;

API Reference

Public Methods

Method Description
onApplicationEvent Create a new TomcatDynamicConfigurationListener to dynamically reconfigure

Method Details

onApplicationEvent

public void onApplicationEvent(EnvironmentChangeEvent event)

Create a new TomcatDynamicConfigurationListener to dynamically reconfigure the given TomcatWebServer when EnvironmentChangeEvent EnvironmentChangeEvents are published.

Example Usage:

`TomcatWebServer tomcatWebServer = ...;
ServerProperties serverProperties = ...;
ConfigurableApplicationContext context = ...;
TomcatDynamicConfigurationListener listener =
    new TomcatDynamicConfigurationListener(tomcatWebServer, serverProperties, context);
context.addApplicationListener(listener);
`

This documentation was auto-generated from the source code of microsphere-spring-cloud.

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally