neshkeev / spring-proxy-demo

The project reveals the mechanics behind Spring Framework's magic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gitpod

Overview

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.

Quick start

  1. Set JAVA_HOME to point at JDK17;
  2. Clone the repository:
git clone https://github.com/neshkeev/spring-proxy-demo && cd spring-proxy-demo
  1. Start the application:
./mvnw spring-boot:run
  1. Add a consumer:
curl http://localhost:8080/customers \
    -X POST \
    -H "Content-type: application/json" \
    -d '{"id":0,"name":"Hello, World!", "active": true}'
  1. Start jconsole:
jconsole
  1. Find the com.github.neshkeev.spring.proxy.Main process and connect to it;
  2. Go to MBeans;
  3. In the left panel unfold com.github.neshkeev.spring.proxy.rest | basic | customerController | Operations | get;
  4. Click on the get button.

Run tests with maven

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

Run the application with Intellij IDEA

If you open the repository in Intellij IDEA you can run the application and it's tests with predefined run configurations:

  1. Main starts the Spring Boot application with a rest controller and registered MBeans;
  2. HelloWorldInvocationHandlerTest starts a Spring Boot test that demonstrates the simplest proxy;
  3. PasswordGeneratorInvocationHandlerTest starts a Spring Boot test for password generators;
  4. LoggerWrapperInvocationHandlerTest
  5. CustomerControllerJMXTest starts Spring Boot tests that checks registered JMX MBeans;

About

The project reveals the mechanics behind Spring Framework's magic

License:Apache License 2.0


Languages

Language:Java 100.0%