Issue #2602 Don't try to load classes from uninstalled bundles.

Former-commit-id: ea5298c561 [formerly f1de2aaded] [formerly c7357863b9] [formerly c7357863b9 [formerly 0c4fc0dd01]] [formerly ea5298c561 [formerly f1de2aaded] [formerly c7357863b9] [formerly c7357863b9 [formerly 0c4fc0dd01]] [formerly 3187754736 [formerly c7357863b9 [formerly 0c4fc0dd01] [formerly 3187754736 [formerly 30ca0135046851884e4a07b36559fce086ccd3f2]]]]]
Former-commit-id: 3187754736
Former-commit-id: d79daa8399 [formerly 159642b200] [formerly 32bac228db] [formerly 7269c263a43e448efb884252ec8dc44a52c58cff [formerly 983c7624df570de47db5a313760f0b69fec21954] [formerly 32bac228db [formerly d1dbd0c9b6]]]
Former-commit-id: 6d376abc1cc9f019a38aa297c78e8b51dd107ac2 [formerly fefd0b88a3ec29be5c62491680dd70324b14dee9] [formerly 6b7e12df21 [formerly 5c14bbf179]]
Former-commit-id: 6b7e12df21
Former-commit-id: b2796fad17
This commit is contained in:
Ben Steffensmeier 2014-01-22 15:46:51 -06:00
parent 723402d691
commit ccdc03dacf
2 changed files with 25 additions and 6 deletions

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.viz.core.reflect;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@ -45,6 +46,7 @@ import org.reflections.util.ConfigurationBuilder;
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Oct 21, 2013 2491 bsteffen Initial creation
* Jan 22, 2014 2062 bsteffen Handle bundles with no wiring.
*
* </pre>
*
@ -54,19 +56,28 @@ import org.reflections.util.ConfigurationBuilder;
public class BundleReflections {
private Reflections reflections;
private final Reflections reflections;
public BundleReflections(Bundle bundle, Scanner scanner) throws IOException {
ConfigurationBuilder cb = new ConfigurationBuilder();
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
cb.addClassLoader(bundleWiring.getClassLoader());
cb.addUrls(FileLocator.getBundleFile(bundle).toURI().toURL());
cb.setScanners(scanner);
reflections = cb.build();
if (bundleWiring != null) {
cb.addClassLoader(bundleWiring.getClassLoader());
cb.addUrls(FileLocator.getBundleFile(bundle).toURI().toURL());
cb.setScanners(scanner);
reflections = cb.build();
} else {
reflections = null;
}
}
public <T> Set<Class<? extends T>> getSubTypesOf(final Class<T> type) {
return reflections.getSubTypesOf(type);
if (reflections == null) {
return Collections.emptySet();
} else {
return reflections.getSubTypesOf(type);
}
}
public Set<Class<?>> getSubTypesOf(Class<?>... types) {

View file

@ -145,6 +145,14 @@ public class SubClassLocator implements ISubClassLocator {
*/
return Collections.emptySet();
}
if(bundle.getState() == Bundle.UNINSTALLED){
/*
* We won't be able to get a class loader for uninstalled bundles so
* don't process them.
*/
return Collections.emptySet();
}
if (includeRequiredSubclasses) {
/* Short circut if we already did this. */