@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { BasicOperation operation = context.getOperation(); if (!(operation instanceof CacheResultOperation)) { throw new IllegalStateException("Could not extract exception cache name from " + operation); } CacheResultOperation cacheResultOperation = (CacheResultOperation) operation; String exceptionCacheName = cacheResultOperation.getExceptionCacheName(); if (exceptionCacheName != null) { return Collections.singleton(exceptionCacheName); } return null; }
@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { BasicOperation operation = context.getOperation(); if (!(operation instanceof CacheResultOperation)) { throw new IllegalStateException("Could not extract exception cache name from " + operation); } CacheResultOperation cacheResultOperation = (CacheResultOperation) operation; String exceptionCacheName = cacheResultOperation.getExceptionCacheName(); if (exceptionCacheName != null) { return Collections.singleton(exceptionCacheName); } return null; }
@Test public void cacheWithException() { CacheResultOperation op = getDefaultCacheOperation(CacheResultOperation.class, String.class, boolean.class); assertDefaults(op); assertEquals(defaultExceptionCacheResolver, op.getExceptionCacheResolver()); assertEquals("exception", op.getExceptionCacheName()); }
@Test public void simpleGet() { CacheResultOperation operation = createSimpleOperation(); assertNotNull(operation.getKeyGenerator()); assertNotNull(operation.getExceptionCacheResolver()); assertNull(operation.getExceptionCacheName()); assertEquals(defaultExceptionCacheResolver, operation.getExceptionCacheResolver()); CacheInvocationParameter[] allParameters = operation.getAllParameters(2L); assertEquals(1, allParameters.length); assertCacheInvocationParameter(allParameters[0], Long.class, 2L, 0); CacheInvocationParameter[] keyParameters = operation.getKeyParameters(2L); assertEquals(1, keyParameters.length); assertCacheInvocationParameter(keyParameters[0], Long.class, 2L, 0); }
@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { BasicOperation operation = context.getOperation(); if (!(operation instanceof CacheResultOperation)) { throw new IllegalStateException("Could not extract exception cache name from " + operation); } CacheResultOperation cacheResultOperation = (CacheResultOperation) operation; String exceptionCacheName = cacheResultOperation.getExceptionCacheName(); if (exceptionCacheName != null) { return Collections.singleton(exceptionCacheName); } return null; }