View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.annotations;
20  
21  import java.util.List;
22  
23  import org.eclipse.jetty.annotations.AnnotationParser.Value;
24  import org.eclipse.jetty.util.log.Log;
25  import org.eclipse.jetty.util.log.Logger;
26  import org.eclipse.jetty.webapp.DiscoveredAnnotation;
27  import org.eclipse.jetty.webapp.WebAppContext;
28  
29  public class WebListenerAnnotationHandler extends AbstractDiscoverableAnnotationHandler
30  {
31      private static final Logger LOG = Log.getLogger(WebListenerAnnotationHandler.class);
32  
33      public WebListenerAnnotationHandler (WebAppContext context)
34      {
35         super(context);
36      }
37      
38      public WebListenerAnnotationHandler (WebAppContext context, List<DiscoveredAnnotation> list)
39      {
40         super(context, list);
41      }
42      
43      /** 
44       * @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)
45       */
46      public void handleClass(String className, int version, int access, String signature, String superName, String[] interfaces, String annotation,
47                              List<Value> values)
48      {
49          WebListenerAnnotation wlAnnotation = new WebListenerAnnotation(_context, className, _resource);
50          addAnnotation(wlAnnotation);
51      }
52  
53      public void handleField(String className, String fieldName, int access, String fieldType, String signature, Object value, String annotation,
54                              List<Value> values)
55      {
56          LOG.warn ("@WebListener is not applicable to fields: "+className+"."+fieldName);
57      }
58  
59      public void handleMethod(String className, String methodName, int access, String params, String signature, String[] exceptions, String annotation,
60                               List<Value> values)
61      {
62          LOG.warn ("@WebListener is not applicable to methods: "+className+"."+methodName+" "+signature);
63      }
64  
65      @Override
66      public String getAnnotationName()
67      {
68          return "javax.servlet.annotation.WebListener";
69      }
70  
71  }