1 package org.apache.commons.ognl.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class ClassCacheHandler
26 {
27
28 private ClassCacheHandler()
29 {
30 }
31
32 public static <T> T getHandler( Class<?> forClass, ClassCache<T> handlers )
33 throws CacheException
34 {
35 T answer;
36
37 synchronized ( handlers )
38 {
39 answer = handlers.get( forClass );
40 if ( answer == null )
41 {
42 Class<?> keyFound;
43
44 if ( forClass.isArray() )
45 {
46 answer = handlers.get( Object[].class );
47 keyFound = null;
48 }
49 else
50 {
51 keyFound = forClass;
52 outer:
53 for ( Class<?> clazz = forClass; clazz != null; clazz = clazz.getSuperclass() )
54 {
55 answer = handlers.get( clazz );
56 if ( answer == null )
57 {
58 Class<?>[] interfaces = clazz.getInterfaces();
59 for ( Class<?> iface : interfaces )
60 {
61 answer = handlers.get( iface );
62 if ( answer == null )
63 {
64
65 answer = getHandler( iface, handlers );
66 }
67 if ( answer != null )
68 {
69 keyFound = iface;
70 break outer;
71 }
72 }
73 }
74 else
75 {
76 keyFound = clazz;
77 break;
78 }
79 }
80 }
81 if ( answer != null )
82 {
83 if ( keyFound != forClass )
84 {
85 handlers.put( forClass, answer );
86 }
87 }
88 }
89 }
90 return answer;
91
92 }
93 }