View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.webservice.generator.bcm;
9   
10  import it.imolinfo.jbi4corba.Logger;
11  import it.imolinfo.jbi4corba.LoggerFactory;
12  
13  import java.util.HashMap;
14  import java.util.Map;
15  
16  import org.objectweb.asm.AnnotationVisitor;
17  import org.objectweb.asm.commons.EmptyVisitor;
18  
19  /**
20   * XXX javadoc.
21   */
22  public class AnnotationCollectorMethodVisitor extends EmptyVisitor {
23  
24    /**
25     * Logger.
26     */
27    private static final Logger LOG
28      = LoggerFactory.getLogger(AnnotationCollectorMethodVisitor.class);
29  
30    protected String methodName = null;
31    protected AnnotationsMaps tracer;
32  
33      /**
34       * XXX javadoc.
35       * 
36       * @param tracer  The annotations maps
37       * @param methodName  The method name
38       */
39      public AnnotationCollectorMethodVisitor(AnnotationsMaps tracer,
40        String methodName) {
41  
42        super();
43  
44        this.methodName = methodName;
45        this.tracer = (tracer == null) ? new AnnotationsMaps() : tracer;
46      }
47  
48      /**
49       * Override.
50       * @param desc     The descriptor
51       * @param visible  The visible
52       * @return         The return
53       */
54      @Override
55      public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
56        LOG.info("CRB000602_ANNOTATION", new Object[]{desc, visible});
57  
58        AnnotationCollectorVisitor visitor
59          = new AnnotationCollectorVisitor();
60  
61        AnnotationCollectorVisitor av = (AnnotationCollectorVisitor)
62          visitor.visitAnnotation(desc, visible);
63  
64        AnnotationVisibleAndValue avv
65          = new AnnotationVisibleAndValue(visible, av.list);
66  
67        if (tracer.annotationOnMethod.get(methodName) == null) {
68          Map<String, AnnotationVisibleAndValue> annotations
69            = new HashMap<String, AnnotationVisibleAndValue>();
70  
71          tracer.annotationOnMethod.put(methodName, annotations);
72        }
73        tracer.annotationOnMethod.get(methodName).put(desc, avv);
74  
75        return av;
76      }
77  
78  }