Search in sources :

Example 1 with ModuleAnnotatedMethodScannerBinding

use of com.google.inject.spi.ModuleAnnotatedMethodScannerBinding in project guice by google.

the class Modules method extractScanners.

private static Module extractScanners(Iterable<Element> elements) {
    final List<ModuleAnnotatedMethodScannerBinding> scanners = Lists.newArrayList();
    ElementVisitor<Void> visitor = new DefaultElementVisitor<Void>() {

        @Override
        public Void visit(ModuleAnnotatedMethodScannerBinding binding) {
            scanners.add(binding);
            return null;
        }
    };
    for (Element element : elements) {
        element.acceptVisitor(visitor);
    }
    return new AbstractModule() {

        @Override
        protected void configure() {
            for (ModuleAnnotatedMethodScannerBinding scanner : scanners) {
                scanner.applyTo(binder());
            }
        }
    };
}
Also used : DefaultElementVisitor(com.google.inject.spi.DefaultElementVisitor) Element(com.google.inject.spi.Element) ModuleAnnotatedMethodScannerBinding(com.google.inject.spi.ModuleAnnotatedMethodScannerBinding) AbstractModule(com.google.inject.AbstractModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 DefaultElementVisitor (com.google.inject.spi.DefaultElementVisitor)1 Element (com.google.inject.spi.Element)1 ModuleAnnotatedMethodScannerBinding (com.google.inject.spi.ModuleAnnotatedMethodScannerBinding)1