javax.cache.annotation.CacheMethodDetails Java Examples
The following examples show how to use
javax.cache.annotation.CacheMethodDetails.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CachePutOperation.java From spring-analysis-note with MIT License | 6 votes |
public CachePutOperation( CacheMethodDetails<CachePut> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CachePut ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.cacheFor(), ann.noCacheFor()); CacheParameterDetail valueParameterDetail = initializeValueParameterDetail(methodDetails.getMethod(), this.allParameterDetails); if (valueParameterDetail == null) { throw new IllegalArgumentException("No parameter annotated with @CacheValue was found for " + methodDetails.getMethod()); } this.valueParameterDetail = valueParameterDetail; }
Example #2
Source File: AnnotationJCacheOperationSource.java From spring-analysis-note with MIT License | 6 votes |
protected CacheResultOperation createCacheResultOperation(Method method, @Nullable CacheDefaults defaults, CacheResult ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheResult> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); CacheResolver exceptionCacheResolver = null; final String exceptionCacheName = ann.exceptionCacheName(); if (StringUtils.hasText(exceptionCacheName)) { exceptionCacheResolver = getExceptionCacheResolver(cacheResolverFactory, methodDetails); } return new CacheResultOperation(methodDetails, cacheResolver, keyGenerator, exceptionCacheResolver); }
Example #3
Source File: CachePutOperation.java From java-technology-stack with MIT License | 6 votes |
public CachePutOperation( CacheMethodDetails<CachePut> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CachePut ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.cacheFor(), ann.noCacheFor()); CacheParameterDetail valueParameterDetail = initializeValueParameterDetail(methodDetails.getMethod(), this.allParameterDetails); if (valueParameterDetail == null) { throw new IllegalArgumentException("No parameter annotated with @CacheValue was found for " + methodDetails.getMethod()); } this.valueParameterDetail = valueParameterDetail; }
Example #4
Source File: AnnotationJCacheOperationSource.java From lams with GNU General Public License v2.0 | 6 votes |
protected CacheResultOperation createCacheResultOperation(Method method, CacheDefaults defaults, CacheResult ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheResult> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); CacheResolver exceptionCacheResolver = null; final String exceptionCacheName = ann.exceptionCacheName(); if (StringUtils.hasText(exceptionCacheName)) { exceptionCacheResolver = getExceptionCacheResolver(cacheResolverFactory, methodDetails); } return new CacheResultOperation(methodDetails, cacheResolver, keyGenerator, exceptionCacheResolver); }
Example #5
Source File: AnnotationJCacheOperationSource.java From lams with GNU General Public License v2.0 | 5 votes |
protected CacheResolver getExceptionCacheResolver(CacheResolverFactory factory, CacheMethodDetails<CacheResult> details) { if (factory != null) { javax.cache.annotation.CacheResolver cacheResolver = factory.getExceptionCacheResolver(details); return new CacheResolverAdapter(cacheResolver); } else { return getDefaultExceptionCacheResolver(); } }
Example #6
Source File: CacheResultOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void fullGetConfig() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "fullGetConfig", Long.class); CacheResultOperation operation = createDefaultOperation(methodDetails); assertTrue(operation.isAlwaysInvoked()); assertNotNull(operation.getExceptionTypeFilter()); assertTrue(operation.getExceptionTypeFilter().match(IOException.class)); assertFalse(operation.getExceptionTypeFilter().match(NullPointerException.class)); }
Example #7
Source File: CacheRemoveOperation.java From spring4-understanding with Apache License 2.0 | 5 votes |
public CacheRemoveOperation( CacheMethodDetails<CacheRemove> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CacheRemove ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
Example #8
Source File: CachePutOperationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void noCacheValue() { CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, SampleObject.class, "noCacheValue", Long.class); thrown.expect(IllegalArgumentException.class); createDefaultOperation(methodDetails); }
Example #9
Source File: AbstractJCacheKeyOperation.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new instance. * @param methodDetails the {@link CacheMethodDetails} related to the cached method * @param cacheResolver the cache resolver to resolve regular caches * @param keyGenerator the key generator to compute cache keys */ protected AbstractJCacheKeyOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver); this.keyGenerator = keyGenerator; this.keyParameterDetails = initializeKeyParameterDetails(this.allParameterDetails); }
Example #10
Source File: CachePutOperationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void multiCacheValues() { CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, SampleObject.class, "multiCacheValues", Long.class, SampleObject.class, SampleObject.class); thrown.expect(IllegalArgumentException.class); createDefaultOperation(methodDetails); }
Example #11
Source File: CacheResultOperation.java From lams with GNU General Public License v2.0 | 5 votes |
public CacheResultOperation(CacheMethodDetails<CacheResult> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator, CacheResolver exceptionCacheResolver) { super(methodDetails, cacheResolver, keyGenerator); CacheResult ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.cachedExceptions(), ann.nonCachedExceptions()); this.exceptionCacheResolver = exceptionCacheResolver; this.exceptionCacheName = (StringUtils.hasText(ann.exceptionCacheName()) ? ann.exceptionCacheName() : null); }
Example #12
Source File: AbstractJCacheOperation.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new instance. * @param methodDetails the {@link CacheMethodDetails} related to the cached method * @param cacheResolver the cache resolver to resolve regular caches */ protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) { Assert.notNull(methodDetails, "method details must not be null."); Assert.notNull(cacheResolver, "cache resolver must not be null."); this.methodDetails = methodDetails; this.cacheResolver = cacheResolver; this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod()); }
Example #13
Source File: AbstractJCacheOperation.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new instance. * @param methodDetails the {@link CacheMethodDetails} related to the cached method * @param cacheResolver the cache resolver to resolve regular caches */ protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) { Assert.notNull(methodDetails, "method details must not be null."); Assert.notNull(cacheResolver, "cache resolver must not be null."); this.methodDetails = methodDetails; this.cacheResolver = cacheResolver; this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod()); }
Example #14
Source File: AnnotationJCacheOperationSource.java From lams with GNU General Public License v2.0 | 5 votes |
protected CacheResolver getCacheResolver(CacheResolverFactory factory, CacheMethodDetails<?> details) { if (factory != null) { javax.cache.annotation.CacheResolver cacheResolver = factory.getCacheResolver(details); return new CacheResolverAdapter(cacheResolver); } else { return getDefaultCacheResolver(); } }
Example #15
Source File: AnnotationJCacheOperationSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected CacheRemoveOperation createCacheRemoveOperation(Method method, CacheDefaults defaults, CacheRemove ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheRemove> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveOperation(methodDetails, cacheResolver, keyGenerator); }
Example #16
Source File: AnnotationJCacheOperationSource.java From lams with GNU General Public License v2.0 | 5 votes |
protected CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, CacheDefaults defaults, CacheRemoveAll ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); CacheMethodDetails<CacheRemoveAll> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveAllOperation(methodDetails, cacheResolver); }
Example #17
Source File: CacheResolverAdapterTests.java From java-technology-stack with MIT License | 5 votes |
protected DefaultCacheInvocationContext<?> createDummyContext() throws Exception { Method method = Sample.class.getMethod("get", String.class); CacheResult cacheAnnotation = method.getAnnotation(CacheResult.class); CacheMethodDetails<CacheResult> methodDetails = new DefaultCacheMethodDetails<>(method, cacheAnnotation, "test"); CacheResultOperation operation = new CacheResultOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator, defaultExceptionCacheResolver); return new DefaultCacheInvocationContext<>(operation, new Sample(), new Object[] {"id"}); }
Example #18
Source File: CachePutOperationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void fullPutConfig() { CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, SampleObject.class, "fullPutConfig", Long.class, SampleObject.class); CachePutOperation operation = createDefaultOperation(methodDetails); assertTrue(operation.isEarlyPut()); assertNotNull(operation.getExceptionTypeFilter()); assertTrue(operation.getExceptionTypeFilter().match(IOException.class)); assertFalse(operation.getExceptionTypeFilter().match(NullPointerException.class)); }
Example #19
Source File: CacheResultOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void tooManyKeyValues() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "anotherSimpleGet", String.class, Long.class); CacheResultOperation operation = createDefaultOperation(methodDetails); thrown.expect(IllegalStateException.class); operation.getKeyParameters("bar"); // missing one argument }
Example #20
Source File: CacheRemoveAllOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Override protected CacheRemoveAllOperation createSimpleOperation() { CacheMethodDetails<CacheRemoveAll> methodDetails = create(CacheRemoveAll.class, SampleObject.class, "simpleRemoveAll"); return new CacheRemoveAllOperation(methodDetails, defaultCacheResolver); }
Example #21
Source File: CacheResultOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void multiParameterKey() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "multiKeysGet", Long.class, Boolean.class, String.class); CacheResultOperation operation = createDefaultOperation(methodDetails); CacheInvocationParameter[] keyParameters = operation.getKeyParameters(3L, Boolean.TRUE, "Foo"); assertEquals(2, keyParameters.length); assertCacheInvocationParameter(keyParameters[0], Long.class, 3L, 0); assertCacheInvocationParameter(keyParameters[1], String.class, "Foo", 2); }
Example #22
Source File: CacheResultOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Override protected CacheResultOperation createSimpleOperation() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "simpleGet", Long.class); return new CacheResultOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator, defaultExceptionCacheResolver); }
Example #23
Source File: CacheResultOperationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected CacheResultOperation createSimpleOperation() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "simpleGet", Long.class); return new CacheResultOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator, defaultExceptionCacheResolver); }
Example #24
Source File: CachePutOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void multiCacheValues() { CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, SampleObject.class, "multiCacheValues", Long.class, SampleObject.class, SampleObject.class); thrown.expect(IllegalArgumentException.class); createDefaultOperation(methodDetails); }
Example #25
Source File: CachePutOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void noCacheValue() { CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, SampleObject.class, "noCacheValue", Long.class); thrown.expect(IllegalArgumentException.class); createDefaultOperation(methodDetails); }
Example #26
Source File: AbstractCacheOperationTests.java From java-technology-stack with MIT License | 5 votes |
protected <A extends Annotation> CacheMethodDetails<A> create(Class<A> annotationType, Class<?> targetType, String methodName, Class<?>... parameterTypes) { Method method = ReflectionUtils.findMethod(targetType, methodName, parameterTypes); Assert.notNull(method, "requested method '" + methodName + "'does not exist"); A cacheAnnotation = method.getAnnotation(annotationType); return new DefaultCacheMethodDetails<>(method, cacheAnnotation, getCacheName(cacheAnnotation)); }
Example #27
Source File: CacheResultOperation.java From java-technology-stack with MIT License | 5 votes |
public CacheResultOperation(CacheMethodDetails<CacheResult> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator, @Nullable CacheResolver exceptionCacheResolver) { super(methodDetails, cacheResolver, keyGenerator); CacheResult ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.cachedExceptions(), ann.nonCachedExceptions()); this.exceptionCacheResolver = exceptionCacheResolver; this.exceptionCacheName = (StringUtils.hasText(ann.exceptionCacheName()) ? ann.exceptionCacheName() : null); }
Example #28
Source File: AbstractJCacheOperation.java From java-technology-stack with MIT License | 5 votes |
/** * Construct a new {@code AbstractJCacheOperation}. * @param methodDetails the {@link CacheMethodDetails} related to the cached method * @param cacheResolver the cache resolver to resolve regular caches */ protected AbstractJCacheOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver) { Assert.notNull(methodDetails, "CacheMethodDetails must not be null"); Assert.notNull(cacheResolver, "CacheResolver must not be null"); this.methodDetails = methodDetails; this.cacheResolver = cacheResolver; this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod()); }
Example #29
Source File: CacheResultOperationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void annotatedGet() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "annotatedGet", Long.class, String.class); CacheResultOperation operation = createDefaultOperation(methodDetails); CacheInvocationParameter[] parameters = operation.getAllParameters(2L, "foo"); Set<Annotation> firstParameterAnnotations = parameters[0].getAnnotations(); assertEquals(1, firstParameterAnnotations.size()); assertEquals(CacheKey.class, firstParameterAnnotations.iterator().next().annotationType()); Set<Annotation> secondParameterAnnotations = parameters[1].getAnnotations(); assertEquals(1, secondParameterAnnotations.size()); assertEquals(Value.class, secondParameterAnnotations.iterator().next().annotationType()); }
Example #30
Source File: AnnotationJCacheOperationSource.java From java-technology-stack with MIT License | 5 votes |
protected CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, @Nullable CacheDefaults defaults, CacheRemoveAll ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); CacheMethodDetails<CacheRemoveAll> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveAllOperation(methodDetails, cacheResolver); }