diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java index e3e0f6a6ab..7b2cc8518a 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/BundleReflections.java @@ -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. * * * @@ -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 Set> getSubTypesOf(final Class type) { - return reflections.getSubTypesOf(type); + if (reflections == null) { + return Collections.emptySet(); + } else { + return reflections.getSubTypesOf(type); + } } public Set> getSubTypesOf(Class... types) { diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java index 49de8e9701..c375f7a8ec 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/reflect/SubClassLocator.java @@ -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. */