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 java.lang.annotation.Annotation;
23 import java.lang.reflect.Method;
24 import java.util.Set;
25
26 import javax.cache.annotation.CacheInvocationParameter;
27 import javax.cache.annotation.CacheKeyInvocationContext;
28
29 import com.google.inject.Injector;
30
31 final class DefaultCacheKeyInvocationContext<A extends Annotation>
32 implements CacheKeyInvocationContext<A>
33 {
34
35 private final Injector injector;
36
37 private final String cacheName;
38
39 private final Object target;
40
41 protected final Method method;
42
43 private final CacheInvocationParameter[] allParameters;
44
45 private final CacheInvocationParameter[] keyParameters;
46
47 private final CacheInvocationParameter valueParameter;
48
49 private final Set<Annotation> methodAnnotations;
50
51 private final A interceptedAnnotation;
52
53 public DefaultCacheKeyInvocationContext( Injector injector,
54 String cacheName,
55 Object target,
56 Method method,
57 CacheInvocationParameter[] allParameters,
58 CacheInvocationParameter[] keyParameters,
59 CacheInvocationParameter valueParameter,
60 Set<Annotation> methodAnnotations,
61 A interceptedAnnotation )
62 {
63 this.injector = injector;
64 this.cacheName = cacheName;
65 this.target = target;
66 this.method = method;
67 this.allParameters = allParameters;
68 this.keyParameters = keyParameters;
69 this.valueParameter = valueParameter;
70 this.methodAnnotations = methodAnnotations;
71 this.interceptedAnnotation = interceptedAnnotation;
72 }
73
74 public final Method getMethod()
75 {
76 return method;
77 }
78
79 public final Set<Annotation> getAnnotations()
80 {
81 return methodAnnotations;
82 }
83
84 public final A getCacheAnnotation()
85 {
86 return interceptedAnnotation;
87 }
88
89 public final String getCacheName()
90 {
91 return cacheName;
92 }
93
94 public final Object getTarget()
95 {
96 return target;
97 }
98
99 public final CacheInvocationParameter[] getAllParameters()
100 {
101 return allParameters;
102 }
103
104 public final <T> T unwrap( Class<T> cls )
105 {
106 return injector.getInstance( cls );
107 }
108
109 public CacheInvocationParameter[] getKeyParameters()
110 {
111 return keyParameters;
112 }
113
114 public CacheInvocationParameter getValueParameter()
115 {
116 return valueParameter;
117 }
118
119 }