View Javadoc

1   // ========================================================================
2   // Copyright (c) 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.annotations;
15  
16  import java.util.List;
17  
18  import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler;
19  import org.eclipse.jetty.annotations.AnnotationParser.Value;
20  import org.eclipse.jetty.util.log.Log;
21  import org.eclipse.jetty.util.log.Logger;
22  import org.eclipse.jetty.webapp.DiscoveredAnnotation;
23  import org.eclipse.jetty.webapp.WebAppContext;
24  
25  /**
26   * WebServletAnnotationHandler
27   *
28   * Process a WebServlet annotation on a class.
29   * 
30   */
31  public class WebServletAnnotationHandler extends AbstractDiscoverableAnnotationHandler
32  {
33      private static final Logger LOG = Log.getLogger(WebServletAnnotationHandler.class);
34      
35      public WebServletAnnotationHandler (WebAppContext context)
36      {
37          super(context);
38      }
39      
40      
41      /** 
42       * Handle discovering a WebServlet annotation.
43       * 
44       *  
45       * @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)
46       */
47      public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotationName,
48                              List<Value> values)
49      {
50          if (!"javax.servlet.annotation.WebServlet".equals(annotationName))
51              return;    
52         
53          WebServletAnnotation annotation = new WebServletAnnotation (_context, className);
54          addAnnotation(annotation);
55      }
56  
57      public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
58                              List<Value> values)
59      {
60          LOG.warn ("@WebServlet annotation not supported for fields");
61      }
62  
63      public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
64                               List<Value> values)
65      {
66          LOG.warn ("@WebServlet annotation not supported for methods");
67      }    
68  }