Class PluginDataProvider

java.lang.Object
net.regsirius06.engine.plugins.files.PluginDataProvider

public class PluginDataProvider extends Object
A utility class responsible for generating files that contain information about classes annotated with ImplementationOf. The generated files are placed in the META-INF/services directory, following the ServiceLoader pattern.

This class scans the provided root directory for annotated classes and generates the appropriate service files. These files are used to load plugins during runtime.

It handles both file creation and writing, ensuring that the necessary directories and files are present and up to date.

  • Field Details

    • log

      public static final org.slf4j.Logger log
      Logger instance for logging important events and error messages.

      Uses SLF4J to provide logging functionality. Messages include information about file generation progress, errors encountered, and successful operations.

  • Method Details

    • of

      @Contract(value="_ -> new", pure=true) @NotNull public static @NotNull PluginDataProvider of(String root)
      Creates a new instance of PluginDataProvider with the specified root directory.
      Parameters:
      root - the root directory to scan for classes
      Returns:
      a new PluginDataProvider instance
    • createDataFiles

      public void createDataFiles()
      Scans for classes annotated with ImplementationOf and generates service files in the META-INF/services directory.

      This method ensures that all necessary directories are created and any existing files are properly cleared and updated with the new class names.

    • finishMessage

      protected static void finishMessage()
      Final message after file generation is completed.