Class AutoRegisterLoader
java.lang.Object
de.craftsblock.craftsnet.autoregister.loaders.AutoRegisterLoader
- All Implemented Interfaces:
Closeable,AutoCloseable
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 Summary
FieldsModifier and TypeFieldDescriptionList of package names to skip when processing class files in the JAR. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Perform cleanup for the currentAutoRegisterLoaderwhen it is no longer used.loadFrom(@Nullable ClassLoader loader, @Nullable Collection<Addon> bounding, @NotNull JarFile file) Loads and processes all classes annotated withAutoRegisterfrom the providedJarFileusing the provided class loader.protected List<AutoRegisterInfo>loadFrom(@Nullable ClassLoader loader, @Nullable Collection<Addon> bounding, @NotNull JarFile file, @NotNull Class<? extends Annotation> type) Loads and processes all classes annotated with the specified annotation from the providedJarFile.
-
Field Details
-
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 currentAutoRegisterLoaderwhen it is no longer used.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
loadFrom
public List<AutoRegisterInfo> loadFrom(@Nullable @Nullable ClassLoader loader, @Nullable @Nullable Collection<Addon> bounding, @NotNull @NotNull JarFile file) Loads and processes all classes annotated withAutoRegisterfrom the providedJarFileusing 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 ofAutoRegisterInfo.- 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- TheJarFilefrom which classes will be loaded.- Returns:
- A list of
AutoRegisterInfoobjects 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 providedJarFile.- 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- TheJarFilefrom which classes will be loaded.type- The annotation type that classes should be annotated with.- Returns:
- A list of
AutoRegisterInfoobjects containing metadata about the classes.
-