Class DiscoveryIndexReader

java.lang.Object
tech.guilhermekaua.spigotboot.core.context.discovery.DiscoveryIndexReader

public final class DiscoveryIndexReader extends Object
Aggregates every DiscoveryIndex found on the classpath into a single lookup table keyed by category. Runtime scan sites query this first and fall back to classpath scanning only when the reader has no indexes available.

Indexes are discovered by enumerating marker files under "META-INF/spigot-boot/discovery"/<GeneratedIndexClassFQCN>. This mirrors the mechanism used by ModuleDiscovery: each jar contributes one or more uniquely-named marker files, so the Maven Shade Plugin merges them without requiring an explicit resource transformer.

  • Constructor Details

    • DiscoveryIndexReader

      public DiscoveryIndexReader(@NotNull @NotNull ClassLoader classLoader)
  • Method Details

    • create

      public static DiscoveryIndexReader create()
      Convenience factory that uses the current thread's context class loader (falling back to this class's loader if the context loader is null).
    • hasAnyIndex

      public boolean hasAnyIndex()
      Returns:
      true if at least one DiscoveryIndex was loaded successfully. When false, callers should fall back to classpath scanning.
    • hasEntriesFor

      public boolean hasEntriesFor(@NotNull @NotNull String category)
      Returns:
      true when any loaded index contains entries for category.
    • classesInCategory

      @NotNull public @NotNull List<Class<?>> classesInCategory(@NotNull @NotNull String category)
      Returns every class registered under category by any loaded index.
    • classesInCategory

      @NotNull public @NotNull List<Class<?>> classesInCategory(@NotNull @NotNull String category, @Nullable @Nullable String packageFilter)
      Returns classes registered under category whose fully-qualified name starts with packageFilter. A null or empty filter means "no filter". The filter matches packageFilter exactly or packageFilter + "." as a prefix, so "com.foo" does not match "com.foobar.Baz".
    • knownCategories

      @NotNull public @NotNull Set<String> knownCategories()
      Returns:
      every category key present across all loaded indexes (unordered).