Interface ModuleProvider
public interface ModuleProvider
The module provider allows access to all loaded modules and the module paths. It keeps track of all known modules and
provides access their module wrapper and changing the module lifecycle for the modules.
- Since:
- 4.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionloadAll()Loads all modules which files are located at the module directory.loadModule(@NonNull URL url) Loads a module from the given url.loadModule(@NonNull Path path) Loads the module by the file provided by the given path.Get a module by the given name.Get the module dependency loader.voidmoduleDependencyLoader(@NonNull ModuleDependencyLoader moduleDependencyLoader) Sets the module dependency loader which should be used by this provider.Get the base directory of this module provider.voidmoduleDirectoryPath(@NonNull Path moduleDirectory) Sets the base directory of this module provider.Get the module provider handler of this provider or null when no handler is specified.voidmoduleProviderHandler(@Nullable ModuleProviderHandler moduleProviderHandler) Sets the module provider handler of this provider.modules()Get all loaded, started, stopped modules provided by this provider.Get all loaded, started, stopped modules provided by this provider which have the specific given group.voidnotifyPostModuleLifecycleChange(@NonNull ModuleWrapper wrapper, @NonNull ModuleLifeCycle lifeCycle) Called by anModuleWrapperwhen the module changed its lifecycle state.booleannotifyPreModuleLifecycleChange(@NonNull ModuleWrapper wrapper, @NonNull ModuleLifeCycle lifeCycle) Called by anModuleWrapperwhen the module is about to change its lifecycle state.Reloads all modules which are loaded by this provided and can change to the started state.startAll()Starts all modules which are loaded by this provided and can change to the started state.stopAll()Stops all modules which are loaded by this provided and can change to the stopped state.Unloads all modules which are loaded by this provided and can change to the unloaded state.
-
Method Details
-
moduleDirectoryPath
-
moduleDirectoryPath
Sets the base directory of this module provider. It will be used to provide the data directory for modules which did not specifically set a data directory.- Parameters:
moduleDirectory- the module directory to use.- Throws:
NullPointerException- if moduleDirectory is null.- See Also:
-
moduleProviderHandler
Get the module provider handler of this provider or null when no handler is specified.- Returns:
- the module provider handler of this provider or null.
- See Also:
-
moduleProviderHandler
Sets the module provider handler of this provider.- Parameters:
moduleProviderHandler- the new module provider to use or null when no handler should be used.- Throws:
NullPointerException- if the given module provider handler is null.- See Also:
-
moduleDependencyLoader
Get the module dependency loader. It's used to load all dependencies of all modules.- Returns:
- the module provider handler used for this provider.
- See Also:
-
moduleDependencyLoader
Sets the module dependency loader which should be used by this provider.- Parameters:
moduleDependencyLoader- the module dependency loader to use.- Throws:
NullPointerException- if moduleDependencyLoader is null.- See Also:
-
modules
Get all loaded, started, stopped modules provided by this provider.- Returns:
- an immutable set of all loaded, started, stopped modules provided by this provider.
- See Also:
-
modules
Get all loaded, started, stopped modules provided by this provider which have the specific given group.- Parameters:
group- the group id of the modules to get.- Returns:
- an immutable set of all loaded, started, stopped modules provided by this provider which have the specific given group.
- Throws:
NullPointerException- if group is null.- See Also:
-
module
Get a module by the given name.- Parameters:
name- the name of the module to get.- Returns:
- the module associated with the name or null if no such module is loaded.
- Throws:
NullPointerException- if name is null.
-
loadModule
Loads a module from the given url.- Parameters:
url- the url to load the module from.- Returns:
- the loaded module or null if checks failed or a module from this url is already loaded.
- Throws:
ModuleConfigurationNotFoundException- if the file associated with the url doesn't contain a module.json.NullPointerException- if required properties are missing in dependency or repository information.AssertionError- if any exception occurs during the load of the module.NullPointerException- if url is null.
-
loadModule
Loads the module by the file provided by the given path.- Parameters:
path- the path to load the module from.- Returns:
- the loaded module or null if checks failed or a module from this path is already loaded.
- Throws:
ModuleConfigurationNotFoundException- if the file associated with the url doesn't contain a module.json.NullPointerException- if required properties are missing in dependency or repository information.AssertionError- if any exception occurs during the load of the module.NullPointerException- if path is null.- See Also:
-
loadAll
Loads all modules which files are located at the module directory.- Returns:
- the same instance of the class, for chaining.
- See Also:
-
startAll
Starts all modules which are loaded by this provided and can change to the started state.- Returns:
- the same instance of the class, for chaining.
- See Also:
-
reloadAll
Reloads all modules which are loaded by this provided and can change to the started state.- Returns:
- the same instance of the class, for chaining.
- See Also:
-
stopAll
Stops all modules which are loaded by this provided and can change to the stopped state.- Returns:
- the same instance of the class, for chaining.
- See Also:
-
unloadAll
Unloads all modules which are loaded by this provided and can change to the unloaded state.- Returns:
- the same instance of the class, for chaining.
- See Also:
-
notifyPreModuleLifecycleChange
boolean notifyPreModuleLifecycleChange(@NonNull @NonNull ModuleWrapper wrapper, @NonNull @NonNull ModuleLifeCycle lifeCycle) Called by anModuleWrapperwhen the module is about to change its lifecycle state.- Parameters:
wrapper- the wrapper which is changing the lifecycle.lifeCycle- the lifecycle the wrapper want's to change to.- Returns:
- If the wrapper is allowed to change the lifecycle to the provided lifecycle.
- Throws:
NullPointerException- if wrapper or lifeCycle is null.
-
notifyPostModuleLifecycleChange
void notifyPostModuleLifecycleChange(@NonNull @NonNull ModuleWrapper wrapper, @NonNull @NonNull ModuleLifeCycle lifeCycle) Called by anModuleWrapperwhen the module changed its lifecycle state.- Parameters:
wrapper- the wrapper which changed the lifecycle.lifeCycle- the lifecycle the wrapper changed to.- Throws:
NullPointerException- if wrapper or lifeCycle is null.
-