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