1 package org.apache.onami.cache;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import javax.cache.Cache;
23 import javax.cache.annotation.CacheInvocationContext;
24 import javax.cache.annotation.CacheKey;
25 import javax.cache.annotation.CacheKeyInvocationContext;
26 import javax.cache.annotation.CacheRemoveEntry;
27
28
29
30
31 final class CacheRemoveEntryInterceptor
32 extends AfterBeforeInvocationInterceptor<CacheRemoveEntry>
33 {
34
35 @Override
36 public Class<CacheRemoveEntry> getInterceptedAnnotationType()
37 {
38 return CacheRemoveEntry.class;
39 }
40
41 @Override
42 protected void hitCache( CacheInvocationContext<CacheRemoveEntry> context )
43 {
44 CacheKeyInvocationContext<CacheRemoveEntry> keyedContext = (CacheKeyInvocationContext<CacheRemoveEntry>) context;
45
46 Cache<Object, Object> cache = getCacheResolverFactory( context ).getCacheResolver( context ).resolveCache( context );
47 CacheKey cacheKey = getCacheKeyGenerator( context ).generateCacheKey( keyedContext );
48
49 cache.remove( cacheKey );
50 }
51
52 }