Class AutoRegisterLoader

java.lang.Object
de.craftsblock.craftsnet.autoregister.loaders.AutoRegisterLoader
All Implemented Interfaces:
Closeable, AutoCloseable

public class AutoRegisterLoader extends Object implements Closeable
A loader class responsible for loading classes from a JAR file that are annotated with a specific annotation (default is AutoRegister) and collecting relevant information about these classes.

This class uses an ExecutorService to parallelize the processing of classes in a JAR file.

Since:
3.2.0-SNAPSHOT
See Also:
  • Field Details

    • SKIP_PACKAGES

      public static final List<String> SKIP_PACKAGES
      List of package names to skip when processing class files in the JAR.
  • Constructor Details

    • AutoRegisterLoader

      public AutoRegisterLoader()
  • Method Details

    • close

      public void close()
      Perform cleanup for the current AutoRegisterLoader when it is no longer used.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • loadFrom

      public List<AutoRegisterInfo> loadFrom(@Nullable @Nullable ClassLoader loader, @Nullable @Nullable Collection<Addon> bounding, @NotNull @NotNull JarFile file)
      Loads and processes all classes annotated with AutoRegister from the provided JarFile using the provided class loader.

      This method finds all classes in the jar that are annotated with AutoRegister, collects metadata about these classes, and returns it as a list of AutoRegisterInfo.

      Parameters:
      loader - The class loader to use (can be null for the system class loader).
      bounding - The list of addons that the auto register info is from. Nullable if the register info does not come from an addon.
      file - The JarFile from which classes will be loaded.
      Returns:
      A list of AutoRegisterInfo objects containing metadata about the classes.
      Since:
      1.0.0
    • loadFrom

      protected List<AutoRegisterInfo> loadFrom(@Nullable @Nullable ClassLoader loader, @Nullable @Nullable Collection<Addon> bounding, @NotNull @NotNull JarFile file, @NotNull @NotNull Class<? extends Annotation> type)
      Loads and processes all classes annotated with the specified annotation from the provided JarFile.
      Parameters:
      loader - The class loader to use (can be null for the system class loader).
      bounding - The list of addons that the auto register info is from. Nullable if the register info does not come from an addon.
      file - The JarFile from which classes will be loaded.
      type - The annotation type that classes should be annotated with.
      Returns:
      A list of AutoRegisterInfo objects containing metadata about the classes.