1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.util;
20
21 import org.eclipse.jetty.util.log.Log;
22 import org.eclipse.jetty.util.log.Logger;
23
24 public class DeprecationWarning implements Decorator
25 {
26 private static final Logger LOG = Log.getLogger(DeprecationWarning.class);
27
28 @Override
29 public <T> T decorate(T o)
30 {
31 if (o == null)
32 {
33 return null;
34 }
35
36 Class<?> clazz = o.getClass();
37
38 try
39 {
40 Deprecated depr = clazz.getAnnotation(Deprecated.class);
41 if (depr != null)
42 {
43 LOG.warn("Using @Deprecated Class {}",clazz.getName());
44 }
45 }
46 catch (Throwable t)
47 {
48 LOG.ignore(t);
49 }
50
51 verifyIndirectTypes(clazz.getSuperclass(),clazz,"Class");
52 for (Class<?> ifaceClazz : clazz.getInterfaces())
53 {
54 verifyIndirectTypes(ifaceClazz,clazz,"Interface");
55 }
56
57 return o;
58 }
59
60 private void verifyIndirectTypes(Class<?> superClazz, Class<?> clazz, String typeName)
61 {
62 try
63 {
64
65 while (superClazz != null && superClazz != Object.class)
66 {
67 Deprecated supDepr = superClazz.getAnnotation(Deprecated.class);
68 if (supDepr != null)
69 {
70 LOG.warn("Using indirect @Deprecated {} {} - (seen from {})",typeName,superClazz.getName(),clazz);
71 }
72
73 superClazz = superClazz.getSuperclass();
74 }
75 }
76 catch (Throwable t)
77 {
78 LOG.ignore(t);
79 }
80 }
81
82 @Override
83 public void destroy(Object o)
84 {
85 }
86 }