1 //======================================================================== 2 //$Id: PostConstructCallback.java 1540 2007-01-19 12:24:10Z janb $ 3 //Copyright 2006 Mort Bay Consulting Pty. Ltd. 4 //------------------------------------------------------------------------ 5 //Licensed under the Apache License, Version 2.0 (the "License"); 6 //you may not use this file except in compliance with the License. 7 //You may obtain a copy of the License at 8 //http://www.apache.org/licenses/LICENSE-2.0 9 //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 import org.mortbay.log.Log; 22 23 /** 24 * PostConstructCallback 25 * 26 * 27 */ 28 public class PostConstructCallback extends LifeCycleCallback 29 { 30 31 /** 32 * Commons Annotation Specification section 2.5 33 * - no params 34 * - must be void return 35 * - no checked exceptions 36 * - cannot be static 37 * @see org.mortbay.jetty.plus.annotation.LifeCycleCallback#validate(java.lang.Class, java.lang.reflect.Method) 38 */ 39 public void validate(Class clazz, Method method) 40 { 41 if (method.getExceptionTypes().length > 0) 42 throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not throw a checked exception"); 43 44 if (!method.getReturnType().equals(Void.TYPE)) 45 throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not have a return type"); 46 47 if (Modifier.isStatic(method.getModifiers())) 48 throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot be static"); 49 } 50 51 52 public void callback (Object instance) 53 throws Exception 54 { 55 super.callback(instance); 56 } 57 58 public boolean equals (Object o) 59 { 60 if (super.equals(o) && (o instanceof PostConstructCallback)) 61 return true; 62 return false; 63 } 64 }