Package io.github.slimjar.app.builder
Class ApplicationBuilder<T extends ApplicationBuilder<T>>
java.lang.Object
io.github.slimjar.app.builder.ApplicationBuilder<T>
- Direct Known Subclasses:
InjectingApplicationBuilder
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedApplicationBuilder(@NotNull String applicationName) Generate an application builder for an application with the given name. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull InjectingApplicationBuilder<?>Creates an ApplicationBuilder that allows loading into the current classloader.final @NotNull Applicationbuild()protected abstract @NotNull Applicationprotected final @NotNull DependencyInjectorfinal TdataProviderFactory(@NotNull DependencyDataProviderFactory dataProviderFactory) Factory that producesDependencyDataProviderto handle `dependencyFileUrl` (by default slimjar.dat) Used to fetch the `slimjar.dat` file of the current jar-file.final TdependencyFileUrl(@NotNull URL dependencyFileUrl) URL to the JSON configuration file that defines the dependencies/repositories/mirrorsfinal TdownloadDirectoryPath(@NotNull Path downloadDirectoryPath) Directory to which slimjar will attempt to download dependency files intofinal TdownloaderFactory(@NotNull DependencyDownloaderFactory downloaderFactory) final TenquirerFactory(@NotNull RepositoryEnquirerFactory enquirerFactory) Factory that produces aRepositoryEnquirerprotected final @NotNull Stringprotected final @NotNull DependencyDataProviderFactoryprotected final @Nullable URLprotected final @NotNull Pathprotected final @NotNull DependencyDownloaderFactoryprotected final @NotNull RepositoryEnquirerFactoryprotected final @NotNull DependencyInjectorFactoryprotected final @NotNull ProcessLoggerprotected final @NotNull MirrorSelectorprotected final @NotNull PreResolutionDataProviderFactoryprotected final @Nullable URLprotected final @NotNull RelocationHelperFactoryprotected final @NotNull RelocatorFactoryprotected final @NotNull DependencyResolverFactoryprotected final @NotNull DependencyVerifierFactorystatic @NotNull InjectingApplicationBuilder<?>injecting(@NotNull String name, @NotNull Injectable injectable) Creates an ApplicationBuilder that allows loading into any givenInjectableinstance.final TinjectorFactory(@NotNull DependencyInjectorFactory injectorFactory) Factory that produces aDependencyInjectorusingrelocatorDependencyInjectordecides how any givenDependencyDatais injected into anInjectablestatic @NotNull IsolatedApplicationBuilderisolated(@NotNull String name, @NotNull String applicationClass, @Nullable Object @NotNull ... args) Creates an ApplicationBuilder that allows jar-in-jar dependency loading.final Tlogger(@NotNull ProcessLogger logger) final TmirrorSelector(@NotNull MirrorSelector mirrorSelector) final TpreResolutionDataProviderFactory(@NotNull PreResolutionDataProviderFactory preResolutionDataProviderFactory) Factory that producesPreResolutionDataProviderto handle `preResolutionFileUrl` (by default slimjar-resolutions.dat) Used to fetch the `slimjar.dat` file of the current jar-file.final TpreResolutionFileUrl(@NotNull URL preResolutionFileUrl) URL to the JSON configuration file that defines the resolutions for given dependenciesfinal TrelocationHelperFactory(@NotNull RelocationHelperFactory relocationHelperFactory) final TrelocatorFactory(@NotNull RelocatorFactory relocatorFactory) Factory class that defines the construction ofRelocatorThis deals with the actual relocation process.final TresolverFactory(@NotNull DependencyResolverFactory resolverFactory) Factory that produces aDependencyResolverFactoryDependencyResolverdeals with resolving the URLs to a given dependency from a given collection of repositoriesfinal TverifierFactory(@NotNull DependencyVerifierFactory verifierFactory)
-
Field Details
-
self
-
-
Constructor Details
-
ApplicationBuilder
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 nullargs- Arguments to pass to created Application class (specified inconfig).- 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 givenInjectableinstance. For a simple isolated classloader, useIsolatedInjectableClassLoaderAlternatively you can provide a custom implementation ofInjectableto 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
Injectableinstance.
-
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 ofRelocatorThis 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 producesDependencyDataProviderto 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 producesPreResolutionDataProviderto 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 aRelocationHelperusingrelocatorThis is an abstraction overRelocator. 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 aDependencyInjectorusingrelocatorDependencyInjectordecides how any givenDependencyDatais injected into anInjectable- 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 aDependencyResolverFactoryDependencyResolverdeals 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 aRepositoryEnquirer- 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
-
getDependencyFileUrl
-
getPreResolutionFileUrl
-
getDownloadDirectoryPath
-
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
-
getLogger
-
createInjector
@Contract(value="-> new", mutates="this") @NotNull protected final @NotNull DependencyInjector createInjector() -
build
-
buildApplication
@Contract(value="-> new", mutates="this") @NotNull protected abstract @NotNull Application buildApplication()
-