The repository reveals the "magic" behind Spring Framework. As a demo it automatically configures JMX MBeans for spring beans that are annotated with @JmxExporter
.
IMPORTANT: the application is built on top of Spring Boot 3.1.2, which supports only Java 17, so JAVA_HOME
should point at a JDK 17 distribution.
- Set
JAVA_HOME
to point at JDK17; - Clone the repository:
git clone https://github.com/neshkeev/spring-proxy-demo && cd spring-proxy-demo
- Start the application:
./mvnw spring-boot:run
- Add a consumer:
curl http://localhost:8080/customers \
-X POST \
-H "Content-type: application/json" \
-d '{"id":0,"name":"Hello, World!", "active": true}'
- Start
jconsole
:
jconsole
- Find the
com.github.neshkeev.spring.proxy.Main
process and connect to it; - Go to
MBeans
; - In the left panel unfold
com.github.neshkeev.spring.proxy.rest
|basic
|customerController
|Operations
|get
; - Click on the
get
button.
The repository contains tests that can be executed with maven:
- Run all tests:
./mvnw clean test
- Run a specific test:
./mvnw clean test -Dtest=com.github.neshkeev.spring.proxy.rest.CustomerControllerJMXTest
If you open the repository in Intellij IDEA you can run the application and it's tests with predefined run configurations:
Main
starts the Spring Boot application with a rest controller and registered MBeans;HelloWorldInvocationHandlerTest
starts a Spring Boot test that demonstrates the simplest proxy;PasswordGeneratorInvocationHandlerTest
starts a Spring Boot test for password generators;LoggerWrapperInvocationHandlerTest
CustomerControllerJMXTest
starts Spring Boot tests that checks registered JMX MBeans;