Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1121

Find all Java classes implementing a given interface.... reflections!

$
0
0
https://code.google.com/p/reflections/

Download the ÜBER JAR here https://code.google.com/p/reflections/downloads/detail?name=reflections-0.9.9-RC1-uberjar.jar&can=2&q=



package pierre.reflections;
import java.net.URL;
import java.util.Set;

import org.reflections.Reflections;



public class FindInterfaceImplementations {
public static void main(String[] args) {
Reflections reflections = new Reflections();
Set<URL> urls = reflections.getConfiguration().getUrls();
for (URL item : urls) {
System.out.println(item.toString());
}
Set<Class<? extends javax.enterprise.inject.spi.InjectionTargetFactory>> classes = reflections.getSubTypesOf(javax.enterprise.inject.spi.InjectionTargetFactory.class);
System.out.println(classes.size());
}

}




Viewing all articles
Browse latest Browse all 1121

Trending Articles