diff --git a/base/src/main/java/de/staropensource/sosengine/base/internal/reflection/ReflectionScanningHelper.java b/base/src/main/java/de/staropensource/sosengine/base/reflection/ClasspathAccess.java similarity index 76% rename from base/src/main/java/de/staropensource/sosengine/base/internal/reflection/ReflectionScanningHelper.java rename to base/src/main/java/de/staropensource/sosengine/base/reflection/ClasspathAccess.java index ca90b2c..3e67b63 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/internal/reflection/ReflectionScanningHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/reflection/ClasspathAccess.java @@ -17,10 +17,12 @@ * along with this program. If not, see . */ -package de.staropensource.sosengine.base.internal.reflection; +package de.staropensource.sosengine.base.reflection; +import de.staropensource.sosengine.base.logging.Logger; +import de.staropensource.sosengine.base.types.CodePart; +import de.staropensource.sosengine.base.types.logging.LogIssuer; import org.jetbrains.annotations.NotNull; -import org.reflections.Reflections; import java.io.File; import java.net.URL; @@ -30,7 +32,7 @@ import java.util.LinkedHashMap; import java.util.Map; /** - * Helps in scanning the class path. + * Allows getting the classpath as {@link URL}s. *

* This entire class has been stolen from * the Reflections library. @@ -39,9 +41,9 @@ import java.util.Map; * @since v1-alpha2 */ @SuppressWarnings({ "unused" }) -public class ReflectionScanningHelper { +public final class ClasspathAccess { /** - * Returns the classpath as URLs. + * Returns the classpath as a collection of {@link URL}s. * * @return collection of classpath urls * @since v1-alpha2 @@ -50,17 +52,15 @@ public class ReflectionScanningHelper { public static Collection getClasspathURLs() { Collection urls = new ArrayList<>(); String javaClassPath = System.getProperty("java.class.path"); - if (javaClassPath != null) { - for (String path : javaClassPath.split(File.pathSeparator)) { + + if (javaClassPath != null) + for (String path : javaClassPath.split(File.pathSeparator)) try { urls.add(new File(path).toURI().toURL()); - } catch (Exception e) { - if (Reflections.log != null) { - Reflections.log.warn("Could not get URL", e); - } + } catch (Exception exception) { + Logger.crash(new LogIssuer(ClasspathAccess.class, CodePart.ENGINE), "Failed converting classpath to URL", exception); } - } - } + return fixURLs(urls); } @@ -74,7 +74,7 @@ public class ReflectionScanningHelper { * @since v1-alpha2 */ @NotNull - public static Collection fixURLs(@NotNull Collection urls) { + private static Collection fixURLs(@NotNull Collection urls) { Map distinct = new LinkedHashMap<>(urls.size()); for (URL url : urls) { distinct.put(url.toExternalForm(), url);