Slide 16
Slide 16 text
Blender’s Filter Implementaton details
Pruning hierarchy traversal
Filters are used to prune hierarchy traversal during injecton point lookup :
while (current.getRawType() != Object.class)
while (filter.isWorthScanning(@Inject.class.getName(), current.getRawType())
Filter have a simple interface, similar to :
• public boolean isWorthScanning(Class> c)
• public boolean isWorthScanningForFields(String AnnotationClassName, Class> c)
• public Set getAllFields(String annotationClassName, Class> c)
• public boolean isWorthScanningForMethods(String AnnotationClassName, Class> c)
• public Set getAllMethods(String annotationClassName, Class> c)
• public boolean isWorthScanningForConstructors(String AnnotationClassName, Class> c)
• public Set> getAllConstructors(String annotationClassName, Class> c)
• public void reset()
The default flter
By default, Guice hierarchy flter doesn’t discard any class. All classes appear to be « worth scanning » for any annotaton.
An extension point
Filters are an extension point in Guice. For instance, RoboGuice uses its own flter to keep all classes that extend RoboGuice classes and
discard any of their superclasses.