@Test public void shouldScanBasePackages() { ClassLoader classLoader = new URLClassLoader(new URL[] {ScannotationComponentScannerTest.class.getResource("/test-fixture.jar")}); when(classPathResolver.findBasePackages()).thenReturn(Arrays.asList("br.com.caelum.vraptor.ioc")); when(classPathResolver.getClassLoader()).thenReturn(classLoader); when(classPathResolver.findWebInfClassesLocation()).thenReturn(classLoader.getResource("br/com/caelum/vraptor/test/")); ScannotationComponentScanner scanner = new ScannotationComponentScanner(); Collection<String> classes = scanner.scan(classPathResolver); assertThat(classes, hasItem(ResourceInTheClasspath.class.getName())); }
public Collection<String> scan(ClasspathResolver resolver) { final URL webInfClasses = resolver.findWebInfClassesLocation(); final List<String> basePackages = resolver.findBasePackages(); HashSet<String> results = new HashSet<String>(); Map<String, Set<String>> webInfClassesAnnotationMap = scanWebInfClasses(webInfClasses); Map<String, Set<String>> basePackagesAnnotationMap = scanBasePackages(basePackages, resolver); Set<String> stereotypeNames = findStereotypes(webInfClassesAnnotationMap, basePackagesAnnotationMap, basePackages); findComponentsFromWebInfClasses(webInfClassesAnnotationMap, stereotypeNames, results); findComponentsFromBasePackages(basePackagesAnnotationMap, basePackages, results); return results; }
ScannotationComponentScanner implements ComponentScanner { public Collection<String> scan(ClasspathResolver resolver) { final URL webInfClasses = resolver.findWebInfClassesLocation(); final List<String> basePackages = resolver.findBasePackages(); HashSet<String> results = new HashSet<String>(); Map<String, Set<String>> webInfClassesAnnotationMap = scanWebInfClasses(webInfClasses); Map<String, Set<String>> basePackagesAnnotationMap = scanBasePackages(basePackages, resolver); Set<String> stereotypeNames = findStereotypes(webInfClassesAnnotationMap, basePackagesAnnotationMap, basePackages); findComponentsFromWebInfClasses(webInfClassesAnnotationMap, stereotypeNames, results); findComponentsFromBasePackages(basePackagesAnnotationMap, basePackages, results); return results; } }
ScannotationComponentScanner implements ComponentScanner { public Collection<String> scan(ClasspathResolver resolver) { final URL webInfClasses = resolver.findWebInfClassesLocation(); final List<String> basePackages = resolver.findBasePackages(); HashSet<String> results = new HashSet<String>(); Map<String, Set<String>> webInfClassesAnnotationMap = scanWebInfClasses(webInfClasses); Map<String, Set<String>> basePackagesAnnotationMap = scanBasePackages(basePackages, resolver); Set<String> stereotypeNames = findStereotypes(webInfClassesAnnotationMap, basePackagesAnnotationMap, basePackages); findComponentsFromWebInfClasses(webInfClassesAnnotationMap, stereotypeNames, results); findComponentsFromBasePackages(basePackagesAnnotationMap, basePackages, results); return results; }  }
ScannotationComponentScanner implements ComponentScanner { public Collection<String> scan(ClasspathResolver resolver) { final URL webInfClasses = resolver.findWebInfClassesLocation(); final List<String> basePackages = resolver.findBasePackages(); HashSet<String> results = new HashSet<String>(); Map<String, Set<String>> webInfClassesAnnotationMap = scanWebInfClasses(webInfClasses); Map<String, Set<String>> basePackagesAnnotationMap = scanBasePackages(basePackages, resolver); Set<String> stereotypeNames = findStereotypes(webInfClassesAnnotationMap, basePackagesAnnotationMap, basePackages); findComponentsFromWebInfClasses(webInfClassesAnnotationMap, stereotypeNames, results); findComponentsFromBasePackages(basePackagesAnnotationMap, basePackages, results); return results; }  Collection<String> scan(ClasspathResolver resolver); }
ScannotationComponentScanner implements ComponentScanner { public Collection<String> scan(ClasspathResolver resolver) { final URL webInfClasses = resolver.findWebInfClassesLocation(); final List<String> basePackages = resolver.findBasePackages(); HashSet<String> results = new HashSet<String>(); Map<String, Set<String>> webInfClassesAnnotationMap = scanWebInfClasses(webInfClasses); Map<String, Set<String>> basePackagesAnnotationMap = scanBasePackages(basePackages, resolver); Set<String> stereotypeNames = findStereotypes(webInfClassesAnnotationMap, basePackagesAnnotationMap, basePackages); findComponentsFromWebInfClasses(webInfClassesAnnotationMap, stereotypeNames, results); findComponentsFromBasePackages(basePackagesAnnotationMap, basePackages, results); return results; }  Collection<String> scan(ClasspathResolver resolver);  }