From 547c4f69a4c4041dd28163f8d847dec0487df6b9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 27 Apr 2017 11:34:10 +0200 Subject: [PATCH] Add getTargetDataSource to TransactionAwareCacheDecorator Issue: SPR-15479 --- .../cache/transaction/TransactionAwareCacheDecorator.java | 6 ++++++ .../transaction/TransactionAwareCacheDecoratorTests.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java index e4b045b231..a7c843ddb6 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java +++ b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java @@ -53,6 +53,12 @@ public class TransactionAwareCacheDecorator implements Cache { this.targetCache = targetCache; } + /** + * Return the target Cache that this Cache should delegate to. + */ + public Cache getTargetCache() { + return this.targetCache; + } @Override public String getName() { diff --git a/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java b/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java index ea1c194fee..16ee78c915 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java @@ -46,6 +46,13 @@ public class TransactionAwareCacheDecoratorTests { new TransactionAwareCacheDecorator(null); } + @Test + public void getTargetCache() { + Cache target = new ConcurrentMapCache("testCache"); + TransactionAwareCacheDecorator cache = new TransactionAwareCacheDecorator(target); + assertSame(target, cache.getTargetCache()); + } + @Test public void regularOperationsOnTarget() { Cache target = new ConcurrentMapCache("testCache");