public static Map<String, String> urlByClass(final IAnnotationFinder finder) { final IAnnotationFinder limitedFinder; if (finder instanceof FinderFactory.ModuleLimitedFinder) { limitedFinder = ((FinderFactory.ModuleLimitedFinder) finder).getDelegate(); } else { limitedFinder = finder; } if (limitedFinder instanceof AnnotationFinder) { final Archive archive = ((AnnotationFinder) limitedFinder).getArchive(); if (archive instanceof WebappAggregatedArchive) { final Map<URL, List<String>> index = ((WebappAggregatedArchive) archive).getClassesMap(); final Map<String, String> urlByClasses = new HashMap<String, String>(); for (final Map.Entry<URL, List<String>> entry : index.entrySet()) { final String url = entry.getKey().toExternalForm(); for (final String current : entry.getValue()) { urlByClasses.put(current, url); } } return urlByClasses; } } return Collections.emptyMap(); }
private List<String> getBeanClasses(final IAnnotationFinder finder) { // What we're hoping in this method is to get lucky and find // that our 'finder' instances is an AnnotationFinder that is // holding an AggregatedArchive so we can get the classes that // that pertain to each URL for CDI purposes. // // If not we call finder.getAnnotatedClassNames() which may return // more classes than actually apply to CDI. This can "pollute" // the CDI class space and break injection points // force cast otherwise we would be broken final IAnnotationFinder delegate = FinderFactory.ModuleLimitedFinder.class.isInstance(finder) ? FinderFactory.ModuleLimitedFinder.class.cast(finder).getDelegate() : finder; final AnnotationFinder annotationFinder = AnnotationFinder.class.cast(delegate); final Archive archive = annotationFinder.getArchive(); final List<String> classes = new ArrayList<String>(500); if (!WebappAggregatedArchive.class.isInstance(archive)) { return annotationFinder.getAnnotatedClassNames(); } final WebappAggregatedArchive aggregatedArchive = (WebappAggregatedArchive) archive; final Map<URL, List<String>> map = aggregatedArchive.getClassesMap(); for (final Map.Entry<URL, List<String>> entry : map.entrySet()) { final URL beansXml = hasBeansXml(entry.getKey()); if (beansXml != null) { classes.addAll(entry.getValue()); } } return classes; }
FinderFactory.ModuleLimitedFinder.class.cast(finder).getDelegate() : finder; if (!AnnotationFinder.class.isInstance(delegate)) { return; // only few tests
final IAnnotationFinder limitedFinder = ((FinderFactory.ModuleLimitedFinder) finder).getDelegate(); if (limitedFinder instanceof AnnotationFinder) { final Archive archive = ((AnnotationFinder) limitedFinder).getArchive();