1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.jetty.plus.annotation;
15
16 import java.lang.reflect.Method;
17 import java.lang.reflect.Modifier;
18
19 import org.eclipse.jetty.util.log.Log;
20
21
22
23
24
25
26 public class PreDestroyCallback extends LifeCycleCallback
27 {
28
29
30
31
32
33
34
35
36
37 public void validate(Class clazz, Method method)
38 {
39
40 if (method.getExceptionTypes().length > 0)
41 throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not throw a checked exception");
42
43 if (!method.getReturnType().equals(Void.TYPE))
44 throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not have a return type");
45
46 if (Modifier.isStatic(method.getModifiers()))
47 throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot be static");
48
49 }
50
51
52 public void callback(Object instance)
53 {
54 try
55 {
56 super.callback(instance);
57 }
58 catch (Exception e)
59 {
60 Log.warn("Ignoring exception thrown on preDestroy call to "+getTargetClass()+"."+getTarget().getName(), e);
61 }
62 }
63
64 public boolean equals(Object o)
65 {
66 if (super.equals(o) && (o instanceof PreDestroyCallback))
67 return true;
68 return false;
69 }
70 }