Class ApplicationBuilder<T extends ApplicationBuilder<T>>

java.lang.Object
io.github.slimjar.app.builder.ApplicationBuilder<T>
Direct Known Subclasses:
InjectingApplicationBuilder

public abstract class ApplicationBuilder<T extends ApplicationBuilder<T>> extends Object
Serves as a configuration for different components slimjar will use during injection. Allows completely modifying and adding upon onto the default behavior when needed.
  • Field Details

  • Constructor Details

    • ApplicationBuilder

      @Contract(pure=true) protected ApplicationBuilder(@NotNull @NotNull String applicationName)
      Generate an application builder for an application with the given name.
      Parameters:
      applicationName - Name of your application/project. This exists to uniquely identify relocations.
  • Method Details

    • isolated

      @Contract(value="_, _, _ -> new", pure=true) @NotNull public static @NotNull IsolatedApplicationBuilder isolated(@NotNull @NotNull String name, @NotNull @NotNull String applicationClass, @Nullable @Nullable Object @NotNull ... args)
      Creates an ApplicationBuilder that allows jar-in-jar dependency loading.
      Parameters:
      name - Name of your application/project. This exists to uniquely identify relocations.
      applicationClass - the class name of the application to isolate, must not be null
      args - Arguments to pass to created Application class (specified in config).
      Returns:
      ApplicationBuilder that allows jar-in-jar dependency loading.
    • appending

      @Contract(value="_ -> new", pure=true) @NotNull public static @NotNull InjectingApplicationBuilder<?> appending(@NotNull @NotNull String name)
      Creates an ApplicationBuilder that allows loading into the current classloader.
      Parameters:
      name - Name of your application/project. This exists to uniquely identify relocations.
      Returns:
      ApplicationBuilder that allows loading into the current classloader.
    • injecting

      @Contract("_, _ -> new") @NotNull public static @NotNull InjectingApplicationBuilder<?> injecting(@NotNull @NotNull String name, @NotNull @NotNull Injectable injectable)
      Creates an ApplicationBuilder that allows loading into any given Injectable instance. For a simple isolated classloader, use IsolatedInjectableClassLoader Alternatively you can provide a custom implementation of Injectable to specify how the dependencies must be added to the classloader.
      Parameters:
      name - Name of your application/project. This exists to uniquely identify relocations.
      Returns:
      ApplicationBuilder that allows loading into any given Injectable instance.
    • dependencyFileUrl

      @Contract(value="_ -> this", mutates="this") @NotNull public final T dependencyFileUrl(@NotNull @NotNull URL dependencyFileUrl)
      URL to the JSON configuration file that defines the dependencies/repositories/mirrors
      Parameters:
      dependencyFileUrl - URL to the JSON configuration file (Default being slimjar.dat inside jar root generated by the Gradle plugin)
      Returns:
      this
    • preResolutionFileUrl

      @Contract(value="_ -> this", mutates="this") @NotNull public final T preResolutionFileUrl(@NotNull @NotNull URL preResolutionFileUrl)
      URL to the JSON configuration file that defines the resolutions for given dependencies
      Parameters:
      preResolutionFileUrl - URL to the JSON resolution configuration file (Default being slimjar-resolutions.dat inside jar root generated by the Gradle plugin)
      Returns:
      this
    • downloadDirectoryPath

      @Contract(value="_ -> this", mutates="this") @NotNull public final T downloadDirectoryPath(@NotNull @NotNull Path downloadDirectoryPath)
      Directory to which slimjar will attempt to download dependency files into
      Parameters:
      downloadDirectoryPath - the Download directory for dependencies.
      Returns:
      this
    • relocatorFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T relocatorFactory(@NotNull @NotNull RelocatorFactory relocatorFactory)
      Factory class that defines the construction of Relocator This deals with the actual relocation process. The default implementation uses lucko/JarRelocator
      Parameters:
      relocatorFactory - Factory class to create Relocator
      Returns:
      this
    • dataProviderFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T dataProviderFactory(@NotNull @NotNull DependencyDataProviderFactory dataProviderFactory)
      Factory that produces DependencyDataProvider to handle `dependencyFileUrl` (by default slimjar.dat) Used to fetch the `slimjar.dat` file of the current jar-file.
      Parameters:
      dataProviderFactory - Factory that produces DataProvider to handle `dependencyFileUrl`
      Returns:
      this
    • preResolutionDataProviderFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T preResolutionDataProviderFactory(@NotNull @NotNull PreResolutionDataProviderFactory preResolutionDataProviderFactory)
      Factory that produces PreResolutionDataProvider to handle `preResolutionFileUrl` (by default slimjar-resolutions.dat) Used to fetch the `slimjar.dat` file of the current jar-file.
      Parameters:
      preResolutionDataProviderFactory - Factory that produces DataProvider to handle `preResolutionFileUrl`
      Returns:
      this
    • relocationHelperFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T relocationHelperFactory(@NotNull @NotNull RelocationHelperFactory relocationHelperFactory)
      Factory that produces a RelocationHelper using relocator This is an abstraction over Relocator. It decides the output file for relocation and includes extra steps such as jar verification.
      Parameters:
      relocationHelperFactory - Factory that produces a RelocationHelper
      Returns:
      this
    • injectorFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T injectorFactory(@NotNull @NotNull DependencyInjectorFactory injectorFactory)
      Factory that produces a DependencyInjector using relocator DependencyInjector decides how any given DependencyData is injected into an Injectable
      Parameters:
      injectorFactory - Factory that produces a DependencyInjector
      Returns:
      this
    • resolverFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T resolverFactory(@NotNull @NotNull DependencyResolverFactory resolverFactory)
      Factory that produces a DependencyResolverFactory DependencyResolver deals with resolving the URLs to a given dependency from a given collection of repositories
      Parameters:
      resolverFactory - Factory that produces a DependencyResolverFactory
      Returns:
      this
    • enquirerFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T enquirerFactory(@NotNull @NotNull RepositoryEnquirerFactory enquirerFactory)
      Factory that produces a RepositoryEnquirer
      Parameters:
      enquirerFactory - Factory that produces a RepositoryEnquirer
      Returns:
      this
    • downloaderFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T downloaderFactory(@NotNull @NotNull DependencyDownloaderFactory downloaderFactory)
      Parameters:
      downloaderFactory - Factory that produces a DependencyDownloader
      Returns:
      this
    • verifierFactory

      @Contract(value="_ -> this", mutates="this") @NotNull public final T verifierFactory(@NotNull @NotNull DependencyVerifierFactory verifierFactory)
    • mirrorSelector

      @Contract(value="_ -> this", mutates="this") @NotNull public final T mirrorSelector(@NotNull @NotNull MirrorSelector mirrorSelector)
    • logger

      @Contract(value="_ -> this", mutates="this") @NotNull public final T logger(@NotNull @NotNull ProcessLogger logger)
    • getApplicationName

      @Contract(pure=true) @NotNull protected final @NotNull String getApplicationName()
    • getDependencyFileUrl

      @Contract(mutates="this") @Nullable protected final @Nullable URL getDependencyFileUrl()
    • getPreResolutionFileUrl

      @Contract(mutates="this") @Nullable protected final @Nullable URL getPreResolutionFileUrl()
    • getDownloadDirectoryPath

      @Contract(mutates="this") @NotNull protected final @NotNull Path getDownloadDirectoryPath()
    • getRelocatorFactory

      @Contract(mutates="this") @NotNull protected final @NotNull RelocatorFactory getRelocatorFactory()
    • getDataProviderFactory

      @Contract(mutates="this") @NotNull protected final @NotNull DependencyDataProviderFactory getDataProviderFactory()
    • getPreResolutionDataProviderFactory

      @Contract(mutates="this") @NotNull protected final @NotNull PreResolutionDataProviderFactory getPreResolutionDataProviderFactory()
    • getRelocationHelperFactory

      @Contract(mutates="this") @NotNull protected final @NotNull RelocationHelperFactory getRelocationHelperFactory()
    • getInjectorFactory

      @Contract(mutates="this") @NotNull protected final @NotNull DependencyInjectorFactory getInjectorFactory()
    • getResolverFactory

      @Contract(mutates="this") @NotNull protected final @NotNull DependencyResolverFactory getResolverFactory()
    • getEnquirerFactory

      @Contract(mutates="this") @NotNull protected final @NotNull RepositoryEnquirerFactory getEnquirerFactory()
    • getDownloaderFactory

      @Contract(mutates="this") @NotNull protected final @NotNull DependencyDownloaderFactory getDownloaderFactory()
    • getVerifierFactory

      @Contract(mutates="this") @NotNull protected final @NotNull DependencyVerifierFactory getVerifierFactory()
    • getMirrorSelector

      @Contract(mutates="this") @NotNull protected final @NotNull MirrorSelector getMirrorSelector()
    • getLogger

      @Contract(mutates="this") @NotNull protected final @NotNull ProcessLogger getLogger()
    • createInjector

      @Contract(value="-> new", mutates="this") @NotNull protected final @NotNull DependencyInjector createInjector()
    • build

      @Contract(value="-> new", mutates="this") @NotNull public final @NotNull Application build()
    • buildApplication

      @Contract(value="-> new", mutates="this") @NotNull protected abstract @NotNull Application buildApplication()