org.mule.util.scan.annotations
Class AnnotationsScanner

java.lang.Object
  extended by org.objectweb.asm.commons.EmptyVisitor
      extended by org.mule.util.scan.annotations.AnnotationsScanner
All Implemented Interfaces:
ClassScanner, org.objectweb.asm.AnnotationVisitor, org.objectweb.asm.ClassVisitor, org.objectweb.asm.FieldVisitor, org.objectweb.asm.MethodVisitor

public class AnnotationsScanner
extends org.objectweb.asm.commons.EmptyVisitor
implements ClassScanner

Scans a single class and registers all annotations on the class in four collections; class annotations, field annotations method annotations and parameter annotations. This scanner can process interfaces, implementation classes and annotation classes. The scanner uses ASM to read the class bytecode, removing the need to actally load the class which would be expensive.


Field Summary
protected  AnnotationInfo currentAnnotation
           
protected  BitSet currentlyProcessing
           
protected  Log log
           
protected static int PROCESSING_CLASS
           
protected static int PROCESSING_FIELD
           
protected static int PROCESSING_METHOD
           
protected static int PROCESSING_PARAM
           
 
Constructor Summary
AnnotationsScanner()
           
AnnotationsScanner(AnnotationFilter filter)
           
 
Method Summary
 List<AnnotationInfo> getAllAnnotations()
           
 String getAnnotationClassName(String rawName)
           
 List<AnnotationInfo> getClassAnnotations()
           
 String getClassName()
           
 List<AnnotationInfo> getFieldAnnotations()
           
 List<AnnotationInfo> getMethodAnnotations()
           
 List<AnnotationInfo> getParamAnnotations()
           
 boolean isMatch()
           
 void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
          This is the class entry.
 void visit(String name, Object value)
          We get annotation values in this method, but have to track the current context.
 org.objectweb.asm.AnnotationVisitor visitAnnotation(String desc, boolean visible)
           
 void visitEnd()
           
 org.objectweb.asm.FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
           
 org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
           
 org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)
           
 
Methods inherited from class org.objectweb.asm.commons.EmptyVisitor
visitAnnotation, visitAnnotationDefault, visitArray, visitAttribute, visitCode, visitEnum, visitFieldInsn, visitFrame, visitIincInsn, visitInnerClass, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLookupSwitchInsn, visitMaxs, visitMethodInsn, visitMultiANewArrayInsn, visitOuterClass, visitSource, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn, visitVarInsn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.asm.ClassVisitor
visitAttribute, visitInnerClass, visitOuterClass, visitSource
 

Field Detail

log

protected final Log log

currentAnnotation

protected AnnotationInfo currentAnnotation

PROCESSING_FIELD

protected static final int PROCESSING_FIELD
See Also:
Constant Field Values

PROCESSING_METHOD

protected static final int PROCESSING_METHOD
See Also:
Constant Field Values

PROCESSING_CLASS

protected static final int PROCESSING_CLASS
See Also:
Constant Field Values

PROCESSING_PARAM

protected static final int PROCESSING_PARAM
See Also:
Constant Field Values

currentlyProcessing

protected BitSet currentlyProcessing
Constructor Detail

AnnotationsScanner

public AnnotationsScanner()

AnnotationsScanner

public AnnotationsScanner(AnnotationFilter filter)
Method Detail

visitParameterAnnotation

public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int parameter,
                                                                    String desc,
                                                                    boolean visible)
Specified by:
visitParameterAnnotation in interface org.objectweb.asm.MethodVisitor
Overrides:
visitParameterAnnotation in class org.objectweb.asm.commons.EmptyVisitor

visitAnnotation

public org.objectweb.asm.AnnotationVisitor visitAnnotation(String desc,
                                                           boolean visible)
Specified by:
visitAnnotation in interface org.objectweb.asm.ClassVisitor
Specified by:
visitAnnotation in interface org.objectweb.asm.FieldVisitor
Specified by:
visitAnnotation in interface org.objectweb.asm.MethodVisitor
Overrides:
visitAnnotation in class org.objectweb.asm.commons.EmptyVisitor

visit

public void visit(int version,
                  int access,
                  String name,
                  String signature,
                  String superName,
                  String[] interfaces)
This is the class entry.

Specified by:
visit in interface org.objectweb.asm.ClassVisitor
Overrides:
visit in class org.objectweb.asm.commons.EmptyVisitor

visit

public void visit(String name,
                  Object value)
We get annotation values in this method, but have to track the current context.

Specified by:
visit in interface org.objectweb.asm.AnnotationVisitor
Overrides:
visit in class org.objectweb.asm.commons.EmptyVisitor

visitField

public org.objectweb.asm.FieldVisitor visitField(int access,
                                                 String name,
                                                 String desc,
                                                 String signature,
                                                 Object value)
Specified by:
visitField in interface org.objectweb.asm.ClassVisitor
Overrides:
visitField in class org.objectweb.asm.commons.EmptyVisitor

visitMethod

public org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                   String name,
                                                   String desc,
                                                   String signature,
                                                   String[] exceptions)
Specified by:
visitMethod in interface org.objectweb.asm.ClassVisitor
Overrides:
visitMethod in class org.objectweb.asm.commons.EmptyVisitor

visitEnd

public void visitEnd()
Specified by:
visitEnd in interface org.objectweb.asm.AnnotationVisitor
Specified by:
visitEnd in interface org.objectweb.asm.ClassVisitor
Specified by:
visitEnd in interface org.objectweb.asm.FieldVisitor
Specified by:
visitEnd in interface org.objectweb.asm.MethodVisitor
Overrides:
visitEnd in class org.objectweb.asm.commons.EmptyVisitor

getAnnotationClassName

public String getAnnotationClassName(String rawName)

getClassAnnotations

public List<AnnotationInfo> getClassAnnotations()

getFieldAnnotations

public List<AnnotationInfo> getFieldAnnotations()

getMethodAnnotations

public List<AnnotationInfo> getMethodAnnotations()

getParamAnnotations

public List<AnnotationInfo> getParamAnnotations()

getAllAnnotations

public List<AnnotationInfo> getAllAnnotations()

isMatch

public boolean isMatch()
Specified by:
isMatch in interface ClassScanner

getClassName

public String getClassName()
Specified by:
getClassName in interface ClassScanner


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.