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
15 package org.eclipse.jetty.annotations;
16
17 import java.util.List;
18
19 import javax.servlet.annotation.HandlesTypes;
20
21 import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
22 import org.eclipse.jetty.annotations.AnnotationParser.Value;
23 import org.eclipse.jetty.plus.annotation.ContainerInitializer;
24 import org.eclipse.jetty.util.Loader;
25 import org.eclipse.jetty.util.log.Log;
26
27 /**
28 * ContainerInitializerAnnotationHandler
29 *
30 * Discovers classes that contain the specified annotation, either at class or
31 * method level. The specified annotation is derived from an @HandlesTypes on
32 * a ServletContainerInitializer class.
33 */
34 public class ContainerInitializerAnnotationHandler implements DiscoverableAnnotationHandler
35 {
36 ContainerInitializer _initializer;
37 Class _annotation;
38
39 public ContainerInitializerAnnotationHandler (ContainerInitializer initializer, Class annotation)
40 {
41 _initializer = initializer;
42 _annotation = annotation;
43 }
44
45 /**
46 * Handle finding a class that is annotated with the annotation we were constructed with.
47 * @see org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler#handleClass(java.lang.String, int, int, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, java.util.List)
48 */
49 public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotationName,
50 List<Value> values)
51 {
52 _initializer.addAnnotatedTypeName(className);
53 }
54
55 public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
56 List<Value> values)
57 {
58 _initializer.addAnnotatedTypeName(className);
59 }
60
61 public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
62 List<Value> values)
63 {
64 _initializer.addAnnotatedTypeName(className);
65 }
66
67 }