Reflect grouping in directory structure
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.example.cache.simple;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.smoketest.support.assertj.AssertableOutput;
|
||||
import org.springframework.aot.smoketest.support.junit.ApplicationTest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ApplicationTest
|
||||
class CacheSimpleApplicationAotTests {
|
||||
|
||||
@Test
|
||||
void methodIsCached(AssertableOutput output) {
|
||||
Awaitility.await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> {
|
||||
assertThat(output).hasSingleLineContaining("invoke: 1").hasNoLinesContaining("invoke: 2");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
21
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/CLR.java
vendored
Normal file
21
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/CLR.java
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.example.cache.simple;
|
||||
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
class CLR implements CommandLineRunner {
|
||||
|
||||
private final TestService testService;
|
||||
|
||||
public CLR(TestService testService) {
|
||||
this.testService = testService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
this.testService.invoke();
|
||||
this.testService.invoke();
|
||||
}
|
||||
|
||||
}
|
||||
10
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/CacheConfiguration.java
vendored
Normal file
10
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/CacheConfiguration.java
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.example.cache.simple;
|
||||
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableCaching
|
||||
class CacheConfiguration {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.cache.simple;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CacheSimpleApplication {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
SpringApplication.run(CacheSimpleApplication.class, args);
|
||||
Thread.currentThread().join(); // To be able to measure memory consumption
|
||||
}
|
||||
|
||||
}
|
||||
10
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/TestService.java
vendored
Normal file
10
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/TestService.java
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.example.cache.simple;
|
||||
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
interface TestService {
|
||||
|
||||
@Cacheable(cacheNames = "invoke")
|
||||
void invoke();
|
||||
|
||||
}
|
||||
16
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/TestServiceImpl.java
vendored
Normal file
16
framework/cache-simple-jdk-proxy/src/main/java/com/example/cache/simple/TestServiceImpl.java
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.example.cache.simple;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
class TestServiceImpl implements TestService {
|
||||
|
||||
private int counter = 1;
|
||||
|
||||
@Override
|
||||
public void invoke() {
|
||||
System.out.printf("invoke: %d%n", this.counter);
|
||||
this.counter++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
spring.aop.proxy-target-class=false
|
||||
Reference in New Issue
Block a user