View Javadoc

1   // ========================================================================
2   // Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.plus.annotation;
15  
16  import java.lang.reflect.InvocationTargetException;
17  import java.lang.reflect.Method;
18  import java.lang.reflect.Modifier;
19  
20  /**
21   * PostConstructCallback
22   *
23   *
24   */
25  public class PostConstructCallback extends LifeCycleCallback
26  {
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.eclipse.jetty.plus.annotation.LifeCycleCallback#validate(java.lang.Class, java.lang.reflect.Method)
35       */
36      public void validate(Class clazz, Method method)
37      {
38          if (method.getExceptionTypes().length > 0)
39              throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not throw a checked exception");
40          
41          if (!method.getReturnType().equals(Void.TYPE))
42              throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not have a return type");
43          
44          if (Modifier.isStatic(method.getModifiers()))
45              throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot be static");
46      }
47      
48      
49      public void callback (Object instance) 
50      throws SecurityException, IllegalArgumentException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException
51      {
52          super.callback(instance);
53      }
54  
55      public boolean equals (Object o)
56      {
57          if (super.equals(o) && (o instanceof PostConstructCallback))
58              return true;
59          return false;
60      }
61  }