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.Method;
17  import java.lang.reflect.Modifier;
18  
19  /**
20   * PostConstructCallback
21   *
22   *
23   */
24  public class PostConstructCallback extends LifeCycleCallback
25  {
26  
27      /** 
28       * Commons Annotation Specification section 2.5
29       *  - no params
30       *  - must be void return 
31       *  - no checked exceptions
32       *  - cannot be static
33       * @see org.eclipse.jetty.plus.annotation.LifeCycleCallback#validate(java.lang.Class, java.lang.reflect.Method)
34       */
35      public void validate(Class clazz, Method method)
36      {
37          if (method.getExceptionTypes().length > 0)
38              throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not throw a checked exception");
39          
40          if (!method.getReturnType().equals(Void.TYPE))
41              throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not have a return type");
42          
43          if (Modifier.isStatic(method.getModifiers()))
44              throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot be static");
45      }
46      
47      
48      public void callback (Object instance)
49      throws Exception
50      {
51          super.callback(instance);
52      }
53  
54      public boolean equals (Object o)
55      {
56          if (super.equals(o) && (o instanceof PostConstructCallback))
57              return true;
58          return false;
59      }
60  }