diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java index bcbbc2a491ca2..9368790bf7509 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java @@ -23,11 +23,13 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.function.Consumer; import org.jboss.logging.Logger; import io.quarkus.commons.classloading.ClassLoaderHelper; import io.quarkus.paths.ManifestAttributes; +import io.quarkus.paths.PathVisit; /** * The ClassLoader used for non production Quarkus applications (i.e. dev and test mode). @@ -48,14 +50,42 @@ public class QuarkusClassLoader extends ClassLoader implements Closeable { registerAsParallelCapable(); } + private static RuntimeException nonQuarkusClassLoaderError() { + return new IllegalStateException("The current classloader is not an instance of " + + QuarkusClassLoader.class.getName() + " but " + + Thread.currentThread().getContextClassLoader().getClass().getName()); + } + + /** + * Visits every found runtime resource with a given name. If a resource is not found, the visitor will + * simply not be called. + *
+ * IMPORTANT: this method works only when the current class loader is an instance of {@link QuarkusClassLoader},
+ * otherwise it throws an error with the corresponding message.
+ *
+ * @param resourceName runtime resource name to visit
+ * @param visitor runtime resource visitor
+ */
+ public static void visitRuntimeResources(String resourceName, Consumer