|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.scannotation.AnnotationDB
public class AnnotationDB
The class allows you to scan an arbitrary set of "archives" for .class files. These class files are parsed to see what annotations they use. Two indexes are created. The javax, java, sun, com.sun, and javassist packages will not be scanned by default.
One is a map of annotations and what classes use those annotations. This could be used, for example, by an EJB deployer to find all the EJBs contained in the archive
Another is a mpa of classes and what annotations those classes use.
Nested Class Summary | |
---|---|
class |
AnnotationDB.CrossReferenceException
|
Field Summary | |
---|---|
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
annotationIndex
|
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
classIndex
|
protected java.lang.String[] |
ignoredPackages
|
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
implementsIndex
|
protected boolean |
scanClassAnnotations
|
protected boolean |
scanFieldAnnotations
|
protected boolean |
scanMethodAnnotations
|
protected boolean |
scanParameterAnnotations
|
Constructor Summary | |
---|---|
AnnotationDB()
|
Method Summary | |
---|---|
void |
addIgnoredPackages(java.lang.String... ignored)
|
void |
crossReferenceImplementedInterfaces()
Sometimes you want to see if a particular class implements an interface with certain annotations After you have loaded all your classpaths with the scanArchive() method, call this method to cross reference a class's implemented interfaces. |
void |
crossReferenceMetaAnnotations()
This method will cross reference annotations in the annotation index with any meta-annotations that they have and create additional entries as needed. |
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
getAnnotationIndex()
returns a map keyed by the fully qualified string name of a annotation class. |
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
getClassIndex()
returns a map keyed by the list of classes scanned. |
java.lang.String[] |
getIgnoredPackages()
|
void |
outputAnnotationIndex(java.io.PrintWriter writer)
Prints out annotationIndex |
protected void |
populate(javassist.bytecode.annotation.Annotation[] annotations,
java.lang.String className)
|
void |
scanArchives(java.net.URL... urls)
Scan a url that represents an "archive" this is a classpath directory or jar file |
protected void |
scanClass(javassist.bytecode.ClassFile cf)
|
void |
scanClass(java.io.InputStream bits)
Parse a .class file for annotations |
protected void |
scanFields(javassist.bytecode.ClassFile cf)
|
protected void |
scanMethods(javassist.bytecode.ClassFile cf)
Scanns both the method and its parameters for annotations. |
void |
setIgnoredPackages(java.lang.String[] ignoredPackages)
Override/overwrite any ignored packages |
void |
setScanClassAnnotations(boolean scanClassAnnotations)
Whether or not you want AnnotationDB to scan for class level annotations |
void |
setScanFieldAnnotations(boolean scanFieldAnnotations)
Whether or not you want AnnotationDB to scan for parameter level annotations |
void |
setScanMethodAnnotations(boolean scanMethodAnnotations)
Wheter or not you want AnnotationDB to scan for method level annotations |
void |
setScanParameterAnnotations(boolean scanParameterAnnotations)
Whether or not you want AnnotationDB to scan for parameter level annotations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> annotationIndex
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> implementsIndex
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> classIndex
protected transient boolean scanClassAnnotations
protected transient boolean scanMethodAnnotations
protected transient boolean scanParameterAnnotations
protected transient boolean scanFieldAnnotations
protected transient java.lang.String[] ignoredPackages
Constructor Detail |
---|
public AnnotationDB()
Method Detail |
---|
public java.lang.String[] getIgnoredPackages()
public void setIgnoredPackages(java.lang.String[] ignoredPackages)
ignoredPackages
- cannot be nullpublic void addIgnoredPackages(java.lang.String... ignored)
public void crossReferenceMetaAnnotations() throws AnnotationDB.CrossReferenceException
AnnotationDB.CrossReferenceException
public void crossReferenceImplementedInterfaces() throws AnnotationDB.CrossReferenceException
ignoredPackages
- var arg list of packages to ignore
AnnotationDB.CrossReferenceException
- an Exception thrown if referenced interfaces haven't been scannedpublic java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getAnnotationIndex()
public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getClassIndex()
public void setScanClassAnnotations(boolean scanClassAnnotations)
scanClassAnnotations
- public void setScanMethodAnnotations(boolean scanMethodAnnotations)
scanMethodAnnotations
- public void setScanParameterAnnotations(boolean scanParameterAnnotations)
scanParameterAnnotations
- public void setScanFieldAnnotations(boolean scanFieldAnnotations)
scanFieldAnnotations
- public void scanArchives(java.net.URL... urls) throws java.io.IOException
urls
- variable list of URLs to scan as archives
java.io.IOException
public void scanClass(java.io.InputStream bits) throws java.io.IOException
bits
- input stream pointing to .class file bits
java.io.IOException
protected void scanClass(javassist.bytecode.ClassFile cf)
protected void scanMethods(javassist.bytecode.ClassFile cf)
cf
- protected void scanFields(javassist.bytecode.ClassFile cf)
protected void populate(javassist.bytecode.annotation.Annotation[] annotations, java.lang.String className)
public void outputAnnotationIndex(java.io.PrintWriter writer)
writer
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |