01: //========================================================================
02: //$Id: PostConstructCallback.java 1448 2006-12-29 20:46:57Z janb $
03: //Copyright 2006 Mort Bay Consulting Pty. Ltd.
04: //------------------------------------------------------------------------
05: //Licensed under the Apache License, Version 2.0 (the "License");
06: //you may not use this file except in compliance with the License.
07: //You may obtain a copy of the License at
08: //http://www.apache.org/licenses/LICENSE-2.0
09: //Unless required by applicable law or agreed to in writing, software
10: //distributed under the License is distributed on an "AS IS" BASIS,
11: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: //See the License for the specific language governing permissions and
13: //limitations under the License.
14: //========================================================================
15:
16: package org.mortbay.jetty.plus.annotation;
17:
18: import java.lang.reflect.Method;
19: import java.lang.reflect.Modifier;
20:
21: /**
22: * PostConstructCallback
23: *
24: *
25: */
26: public class PostConstructCallback extends LifeCycleCallback {
27:
28: /**
29: * Commons Annotation Specification section 2.5
30: * - no params
31: * - must be void return
32: * - no checked exceptions
33: * - cannot be static
34: * @see org.mortbay.jetty.plus.annotation.LifeCycleCallback#validate(java.lang.Class, java.lang.reflect.Method)
35: */
36: public void validate(Class clazz, Method method) {
37: if (method.getExceptionTypes().length > 0)
38: throw new IllegalArgumentException(clazz.getName() + "."
39: + method.getName()
40: + " cannot not throw a checked exception");
41:
42: if (!method.getReturnType().equals(Void.TYPE))
43: throw new IllegalArgumentException(clazz.getName() + "."
44: + method.getName()
45: + " cannot not have a return type");
46:
47: if (Modifier.isStatic(method.getModifiers()))
48: throw new IllegalArgumentException(clazz.getName() + "."
49: + method.getName() + " cannot be static");
50: }
51:
52: public void callback(Object instance) throws Exception {
53: super.callback(instance);
54: }
55:
56: }
|