public class ByteCodeFilter extends Object
This class reads Java class files and checks whether they contain references to specific annotations. This allows to check classes for the presence of annotations before instantiating them.
The filter is inspired by the ClassByteCodeAnnotationFilter of Apache MyFaces 2.0. Many thanks go out to
Leonardo Uribe for his great work on this class.
http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html,
http://en.wikipedia.org/wiki/Class_%28file_format%29| Constructor and Description |
|---|
ByteCodeFilter(Set<Class<? extends Annotation>> types)
The filter must be initialized with a list of types to look for when scanning the class files.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(InputStream classFileStream)
Checks whether that supplied
InputStream contains a Java class file that might contain references to
specific annotation types. |
String |
toString() |
public ByteCodeFilter(Set<Class<? extends Annotation>> types)
types - A Set of types to look forpublic boolean accept(InputStream classFileStream) throws IOException
Checks whether that supplied InputStream contains a Java class file that might contain references to
specific annotation types.
The caller of this method is responsible to close the supplied InputStream. This method won't do it!
classFileStream - The stream to read the class file from.true for files that contain at least one reference to one of the "interesting" annotationsIOException - for any kind of IO problemCopyright © 2015 OCPsoft. All Rights Reserved.