I use org.reflections
library to scan ClassPath and get classes. Here is my code:
Reflections ref = new Reflections();
Set<Class<? extends Service>> classes = new HashSet<>();
for (Class<? extends Service> subType : ref.getSubTypesOf(Service.class)) {
if (!Modifier.isAbstract(subType.getModifiers())) {
classes.add(subType);
}
}
But I faced a problem. It takes too much time. At the same time I can't set a package
new Reflections("my.pack");
because I want to save an ability to add Service classes in the future. Hot can I accelerate this process? Is it possible to exclude rt.jar
packs?
Aucun commentaire:
Enregistrer un commentaire